How to use xcodebuild command line to do automatic signing with Xcode9?

Viewed 13812

I have Xcode9 installed on my OSX machine. I am using xcodebuild command line to sign my app which of course uses the latest Xcode9 based commaline tools.

Following is the way I am trying to sign my app:

xcodebuild -project "MyProject.xcodeproj" -scheme "MyProject" -sdk "iphoneos" -configuration Release PROVISIONING_PROFILE="MyProject_ProvisioningProfile" DEVELOPEMENT_TEAM="MY_TEAM_ID"

But, it gives the following error.

Code Signing Error: Provisioning profile "profile_name" is Xcode managed, but signing settings require a manually managed profile.
Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.0'

But when I build using Xcode9 UI IDE selecting "Automatic signing", it works. I want to replicate the same using xcodebuild command line.

I read that with Xcode 9 installed, we can do automatic signing from command line just like Xcode UI does.

Question:
How should I modify xcodebuild command to do automatic signing just the way it is done on Xcode UI based tool?

I understand from official documentation that one should prefer automatic signing. But how to do this with xcodebuild command line

Looking at this discussion, I tried switching it on the project.pbxproj file using sed.

sed -i '' 's/ProvisioningStyle = Manual;/ProvisioningStyle = Automatic;/' <ProjectName>.xcodeproj/project.pbxproj

But that didn't help

4 Answers

Try adding export_xcargs: "-allowProvisioningUpdates", that will work

On my project I use gradle-xcodePlugin utility. It's not typical for iOS development to use Gradle :), but it's quite good instrument. It's a wrapper under xcodebuild tool. It's very easy to setup, configuration is in the build.gradle file. It's enough documentation on GitHub to setup it. It does automatically building, exporting, delivering to TestFlight beta testing and more. I use it for a year.

You will forget syntax of xcodebuild -project ... for always. Just keep this plugin up to date.

I run building by executing $ ./gradlew xcodebuild

Maybe this tool help you to avoid spending time for solving issues with each Xcode update, as it did for me ;)

xcodebuild -project -scheme WebDriverAgentRunner -destination id=7b7ba65e1f3bbb87460aef17866efe6f6e473c24 -configuration Release -xcconfig -allowProvisioningUpdates build-for-testing

XCODE CONFIG FILE : Create a file that contains following details

  • DEVELOPMENT_TEAM = "MY_TEAM_ID"
  • CODE_SIGN_IDENTITY = iPhone Developer
Related