Search code examples
iosxcodeprovisioning-profile

Setting Provisioning Profile, Team, and Signing Certificate Without Opening XCode


For unqiue reasons, I need to set the Provisioning Profile, the Team, and the Signing Certificate without opening XCode. Therefore, I would like to set these values at the command line using xcodebuild or fastlane. How would one do that?

Attached is a picture of the fields that I am trying to set without opening XCode.

enter image description here


Solution

  • I would use xcconfig files for that.

    Let's say your build configuration is release.

    Create a MyRelease.xcconfig file in Xcode and add the following lines:

    #include "../Pods/Target Support Files/Pods-YourApp/Pods-YourApp.release.xcconfig"
    DEVELOPMENT_TEAM = 12345678
    CODE_SIGN_IDENTITY = iPhone Distribution: YourCompany (12345678)
    PROVISIONING_PROFILE_SPECIFIER = YourApp Provisioning Name
    

    You can easily copy those lines from the UI of your build settings in Xcode.

    Then open the Tab General of your project in Xcode. Under configurations choose the name of your xcconfig file. Then you delete the settings which you have set in Xcode directly so that only those from the xxconfig file are taken.

    When you build, you can exchange the xcconfig file (i.e. cp someOther.xcconfig release.xcconfig) before running any other commands.