xcodebuild 8 and code signing for iOS Distribution

I'm trying to automate the building of an ipa via jenkins for testflight/app store with automatic code signing enabled.

Note: Switching to manual code signing does not work. This post explains that issue perfectly.

https://forums.developer.apple.com/message/181305#181305

No solution provided.


Googling around the recommended way appears to be, build an archive and then export.

I can do this via xcode and the ipa can be successfully uploaded to testflight. But that does not lend itself to

automating the process. I found xcodebuild can be use to automate the archive and export.

The following commands results in a ipa. But uploading fails because a subproject/Extensions is not properly signed. Which unfortunately is

consisted with the manual signing issue.


xcodebuild archive -project myapp.xcodeproj -scheme "myapp" -archivePath build/archive/name.xcarchive

xcodebuild -exportArchive -archivePath build/archive/Name.xcarchive -exportPath build/"Name" -exportFormat ipa -exportProvisioningProfile "Valid Dist profile"

Few other details that might be relevant

1. when I open the xcodebuild ipa and check how its sigend with "codesign -dv --verbose=4", it shows the correct "iphone Distribution" cert.

2. when I compare the output from "codesign -dv --verbose=4" on both xcode generated ipa and xcodebuild generate ipa the xcode version

shows significant more files. Which suggest xcodebuild archive or export does not properly recurse to subprojects.


So how does a subproject get included?

I believe I found the solution. That is to include -exportOptionsPlist exportPlist.plist.

so the export becomes


xcodebuild -exportArchive -archivePath build/archive/Name.xcarchive -exportPath build/"Name" -exportOptionsPlist exportPlist.plist


There is some conflicting info google found. That arg is documented as being needed but other folks are exporting without it.

So. I guess it depends 🙂

xcodebuild 8 and code signing for iOS Distribution
 
 
Q