Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild different provisioning profile for target dependency

I'm trying to build my app with xcodebuild:

xcodebuild -workspace "RG.xcworkspace" -scheme "Production" -configuration "Release" build CONFIGURATION_BUILD_DIR="${TEMP_DIR}" PROVISIONING_PROFILE="1234-5678-9098-7654-3210"

My scheme has two targets. One target is the app, the other is the app extension (I built an extension for Safari). The app extension is a target dependency. Each target requires a separate provisioning profile. I don't know how to specify the PROVISIONING_PROFILE for the dependency. I'm getting this error, as expected:

CodeSign error: code signing is required for product type 'App Extension' in SDK 'iOS 8.1'

StackOverflow and the man page for xcodebuild don't seem to come up with anything. Does anyone know how to build a project with xcodebuild that relies on two provisioning profiles?

like image 259
Rey Gonzales Avatar asked Jan 15 '15 21:01

Rey Gonzales


People also ask

What is Allowprovisioningupdates?

Aug 14, 2020. 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.

What is Xcodebuild command?

The XcodeBuild build helper is a wrapper around the command line invocation of Xcode. It will abstract the calls like xcodebuild -project app.

What is Xcode provisioning profile?

A provisioning profile links your signing certificate and App ID so that you can sign apps to install and launch on iOS devices. You must have a development provisioning profile to sign apps for use with iOS Gateway version 3.4 and later.

How do I create a provisioning profile in Xcode 11?

Sign in to your Apple Developer account and navigate to Certificates, IDs & Profiles > Identifiers > Provisioning Profiles. Add a new provisioning profile. Activate App Store. Click Continue.


2 Answers

Months later... Found a solution that doesn't involve settings values within Xcode: Within sigh there is a script that is capable of resigning an ipa file with given profiles. The following works for me:

bash resign.sh Experiments-AdHocProd.ipa "iPhone Distribution: Company Pty Ltd" output.ipa -p com.company.experiments.AudioPlugin=Experiments-AdHocProd_com.company.experiments.AudioPlugin.mobileprovision -p com.company.experiments=Experiments-AdHocProd.mobileprovision --verbose

where:

  • Experiments-AdHocProd.ipa is the existing ipa
  • com.company.experiments.AudioPlugin is the extension bundle ID
  • Experiments-AdHocProd_com.company.experiments.AudioPlugin.mobileprovision is the extension profile
  • com.company.experiments is the main app bundle identifier
  • Experiments-AdHocProd.mobileprovision is the main app profile

Each profile's bundle identifier must match that of the app it will be signed with.

Something I found that is important to note is that if a bundle identifier has a wildcard (in my case Experiments-AdHocProd.mobileprovision does) then the profiles with explicit IDs must be passed into -p first.


Alternatively, you could use sigh to perform the resign. Unfortunately, sigh --help doesn't say anything about resigning binaries with extensions, however sigh resign --help does.

like image 164
Max Chuquimia Avatar answered Nov 14 '22 20:11

Max Chuquimia


Solution Without Variable

There is an option, -exportSigningIdentity which can help you, because provisioning profiles of Application & Extension/Widget may be different, but signing identities of app & extension are supposed to be same.

For example, you will see that,

  • TargetApp -> Build Settings -> "Code Signing Identity (id)" (Release)
  • TargetExtension -> Build Settings -> "Code Signing Identity (id)" (Release)

are essentially same string, lets say this identity is "Code Signing Identity (id)". So to build & export archive, what you can run, are simply,

Cleaning

xcodebuild clean -workspace HelloWorld.xcworkspace -scheme HelloWorld

Building

xcodebuild -workspace HelloWorld.xcworkspace -scheme HelloWorld archive -archivePath ~/output/HelloWorld.xcarchive

Exporting

xcodebuild -exportArchive -exportFormat ipa -archivePath ~/output/HelloWorld.xcarchive -exportPath "HelloWorld.ipa" -exportSigningIdentity "Code Signing Identity (id)"

Reference: xcodebuild documentation

like image 1
Sazzad Hissain Khan Avatar answered Nov 14 '22 19:11

Sazzad Hissain Khan