1

I'm trying to export my Mac App via Commandline, it works if I go through the Xcode interface, but I want to automate it. I'm confused by the signing steps I need to go through as a Mac App has two certificates, one for the installer, and one for the main app, so far I have the following, but when I come to export, how do I specify what certificate goes where?

xcodebuild -project "App.xcodeproj" -scheme "App" -configuration "Release" -destination "generic/platform=macOS,name=Any Mac" clean archive -archivePath export/App.xcarchive -verbose CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

codesign --entitlements "/Production.entitlements" -f -s "Apple Distribution: Company LTD (CompanyID)" "export/App.xcarchive/Products/Applications/App.app"

xcodebuild -exportArchive -archivePath export/App.xcarchive -exportOptionsPlist "Support/ExportOptions.plist" -exportPath "export"

productbuild --component "export/App.xcarchive/Products/Applications/App.app" /Applications "export/App_unsigned.pkg"
productsign --sign "3rd Party Mac Developer Installer: Company LTD (CompanyID)" "export/App_unsigned.pkg" "export/App.pkg"

I wish I could see how Archiving works in Xcode to see what I'm missing here

Chris
  • 2,739
  • 4
  • 29
  • 57

1 Answers1

0

Thanks to this question Exporting as macOS app using xcodebuild I was able to find the answer:

      - name: Build archive
        run: xcodebuild -scheme '${{ matrix.run-config['scheme'] }}' -destination '${{ matrix.run-config['destination'] }}' -skipPackagePluginValidation -showBuildTimingSummary -archivePath App.xcarchive archive

      - name: Export Archive
        run: xcodebuild -archivePath App.xcarchive -exportArchive -exportPath 'App-export' -exportOptionsPlist App-target-name/exportOptions.plist

Note: do not give an .app extension to the exported archive. I made that terrible mistake and it was a mess because I thought (mistakenly) that it was just generating the .app, but it was instead generating a folder with the .app inside.

Markon
  • 4,480
  • 1
  • 27
  • 39