Setting a provisioning profile from within xcodebuild when making iPhone apps

前端 未结 5 1406
广开言路
广开言路 2021-01-29 18:25

I\'m using xcodebuild to compile my iPhone app from the command line. Is there a way to pass in some sort of option to set the provisioning profile? There seems to

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 19:02

    My solution isn't elegant but it does do the job and let me automate everything on the build server:

    #!/bin/bash
    
    TARGET="Your App"
    CONFIGURATION="Release"
    SDK="iphoneos"
    PROFILE_PATH="/Users/jkp/Desktop/foo.mobileprovision"
    IDENTITY="iPhone Distribution: Your Company Ltd"
    KEYCHAIN="/Users/jkp/Desktop/keychain"
    PASSWORD="foobar"
    
    open "${PROFILE_PATH}"
    sleep 5
    osascript -e "tell application \"Xcode\" to quit"
    security unlock-keychain -p ${PASSWORD} ${KEYCHAIN}
    xcodebuild \
      -target "${TARGET}" \
      -configuration ${CONFIGURATION} \
      -sdk iphoneos \
      CODE_SIGN_IDENTITY="${IDENTITY}" \    
      OTHER_CODE_SIGN_FLAGS="--keychain ${KEYCHAIN}"
    

    The key thing here is that I didn't need to install the provisioning profile first. I actually have another script that uses mechanize to download the latest copy of the provisioning profile before each build which means we can update the profile (adding new devices for example) remotely and have those changes picked up by our CI server without any extra work.

    Note: I've since found a way to install or update a provisioning profile without needing to involve Xcode at all - much cleaner! See here for full details.

提交回复
热议问题