Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can xcodebuild manage automatic signing?

SUMMARY:

If you open a project in Xcode 8 with "Automatically manage signing" enabled and a new bundle ID, it will automatically create and download a provisioning profile for it. But how can I make the same thing happen with xcodebuild, so I can use it on a remote build server?

DETAILS:

I'm trying to build a Cordova app on a Mac. Cordova configures the Xcode project to use "Automatically manage signing", so I'm trying to use that.

I change the bundle ID often, so I want Cordova to be able to build it with a new bundle ID, that hasn't been used before.

But when I run cordova build ios --release --device --buildConfig build.json, I get a return code 65 and the following error:

Check dependencies No profiles for 'com.my.bundle.id' were found:  Xcode couldn't find a provisioning profile matching 'com.my.bundle.id'. Code signing is required for product type 'Application' in SDK 'iOS 10.3'  ** ARCHIVE FAILED **  The following build commands failed:     Check dependencies (1 failure) Error: Error code 65 for command: xcodebuild with args: -xcconfig,/cordova-project/platforms/ios/cordova/build-debug.xcconfig,-workspace,MyApp.xcworkspace,-scheme,MyApp,-configuration,Debug,-destination,generic/platform=iOS,-archivePath,MyApp.xcarchive,archive,CONFIGURATION_BUILD_DIR=/cordova-project/platforms/ios/build/device,SHARED_PRECOMPS_DIR=/cordova-project/platforms/ios/build/sharedpch 

(I can manually run that xcodebuild command and get the same error, so it's probably not a Cordova issue.)

My build.json file looks like this:

{     "ios": {         "debug": {             "codeSignIdentity": "iPhone Developer",             "developmentTeam": "MY_TEAM_ID",             "packageType": "development"         },         "release": {             "codeSignIdentity": "iPhone Developer",             "developmentTeam": "MY_TEAM_ID",             "packageType": "enterprise"         }     } } 

I'm using cordova 7.0.1, cordova-ios 4.4.0, Xcode 8.3.3, and MacOS 10.12.5. I have an Apple Enterprise account.

WHAT I TRIED:

If I open the generated project in Xcode, it fixes the automatic signing, and from then on I can run cordova successfully with that bundle ID. But if I try to run it with a different bundle ID, it will fail again.

I tried using security unlock-keychain ~/Library/Keychains/login.keychain-db first, since that's worked in the past, but it didn't help.

I also tried opening my private signing key in Keychain Access and setting it to "Allow all applications to access this item", without any luck.

I get the same error regardless of whether I pass --debug or --release to cordova.

like image 469
JW. Avatar asked Jun 09 '17 22:06

JW.


People also ask

What does Xcodebuild archive do?

It archives your Xcode project by running the xcodebuild archive command and exports the archive into an . ipa file with the xcodebuild -exportArchive command. This . ipa file can be shared and installed on test devices, or uploaded to App Store Connect.

What is automatic code signing?

Automatic code signing means automatically managing the provisioning profiles that are available on your Apple Developer Portal account. If you set up some form of authentication to your Apple account, Bitrise can download and install the provisioning profile for your app during the build process.

How does Xcode signing work?

Code signing your app assures users that it's from a known source and hasn't been modified since it was last signed. Before your app can integrate app services, be installed on a device, or be submitted to the App Store, it must be signed with a certificate issued by Apple.

What is allowProvisioningUpdates?

Since Xcode 9, Apple provides automatic code signing identity management from the command line by using the xcodebuild command. Using the “allowprovisioningupdates” flag, you can enable code signing; however you may get errors like: Your session has expired.


1 Answers

This isn't directly supported in Xcode 8. In Xcode 9, however, you can pass -allowProvisioningUpdates to xcodebuild and automatic signing will work just as in the Xcode UI, without needing any additional tools.

e.g. cordova run ios --buildFlag="-allowProvisioningUpdates"

like image 119
itai195 Avatar answered Oct 02 '22 16:10

itai195