简体   繁体   中英

Xcode - command line build

I've been working on creating a shell script which will let me archive and extract the ipa file from my working project.

#!/bin/sh
cd `dirname $0`
xcodebuild -scheme appName clean archive -archivePath ./build/AppName
xcodebuild -exportArchive -exportOptionsPlist ./build/exportOptions.plist -archivePath  ./build/AppName.xcarchive -exportPath ./build/appName

The exportOptions.plist is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>method</key>
        <string>ad-hoc</string>
    </dict>
</plist>

I will further need a way to change the Bundle identifier and the Team to the customer's. Adding PRODUCT_BUNDLE_IDENTIFIER=$com.changed.appname to the first line of the xcodebuild will it change the Bundle identifier to what I need ?

ie xcodebuild -scheme appName PRODUCT_BUNDLE_IDENTIFIER=$com.changed.appname clean archive -archivePath ./build/AppName

Is this right ? What about the team ? Or should I use the exportOptions.plist for these settings ?

Thank you.

You can use these commands to manipulate the project files directly. From my experience, the xcodebuild commands sometimes don't accept the parameters we pass as provisioning profiles, team ID, etc..

So the best way to guarantee it's changed the way you want is to manipulate the xcodeproj file

  1. Changing provisioning style to manual

sed -ie "s/ProvisioningStyle = \\".*\\"/ProvisioningStyle = \\"Manual\\"/" <project_name>.xcodeproj/project.pbxproj

  1. Changing the code signing identity

sed -ie "s/CODE_SIGN_IDENTITY = \\".*\\"/CODE_SIGN_IDENTITY = \\"<signing_identity_name>\\"/g" <project_name>.xcodeproj/project.pbxproj

  1. Changing provisioning profile

sed -ie "s/PROVISIONING_PROFILE = \\".*\\"/PROVISIONING_PROFILE = \\"<provisioning_profile_udid>\\"/g" <project_name>.xcodeproj/project.pbxproj

sed -ie "s/PROVISIONING_PROFILE_SPECIFIER = \\".*\\"/PROVISIONING_PROFILE_SPECIFIER = \\"<provisioning_profile_name>\\”/g" <project_name>.xcodeproj/project.pbxproj

Note: Please be mindful of the spaces, this method use regexs to match and replace values in your project file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM