I know this subject was many times debated on SO, but I didn't find all the informations.
I'm making an external script that build and archive my project.
I found some good documentation here and here but I can't figure out how to get the xcode variables, like ${PROJECT_NAME}
, ${TARGET_SDK}
, and so on.
I also saw this line which could be interesting for sourcing those vars:
."$WORKSPACE/autobuild/build.config"
but i cannot find any "autobuild" folder nor "build.config" file on my mac.
I have the feeling i missed something straitforward, but i don't know what...
Any idea ?
Make sure you've installed The XCode command line tools (via XCode preferences).
Then, what I use is a simple shell script:
#!/bin/sh
source "build.cfg"
xcodebuild -target "${XCODE_BUILD_TARGET}" -sdk "${XCODE_BUILD_SDK}" -configuration Release CODE_SIGN_IDENTITY="${XCODE_BUILD_CODE_SIGN_AUTHORITY}"
EXIT_CODE=$?
if [ ! $EXIT_CODE -eq 0 ];then
exit $EXIT_CODE
fi
xcrun -sdk "${XCODE_BUILD_SDK}" PackageApplication -v "${XCODE_ABS_BUILD_APP_PATH}" -o "${XCODE_ARCHIVE_OUTPUT_PATH}" --sign "${XCODE_BUILD_CODE_SIGN_AUTHORITY}" --embed "${XCODE_ABS_PROVISIONING_CERTIFICATE_PATH}"
EXIT_CODE=$?
if [ ! $EXIT_CODE -eq 0 ];then
exit $EXIT_CODE
fi
There is a bunch else I have but that is the key part. Then build.cfg just has the vars above in them:
#!/bin/sh
export XCODE_PROJECT_DIR="Builds/iOS"
export XCODE_BUILD_TARGET="Demo-iPhone"
export XCODE_BUILD_SDK="iphoneos"
export XCODE_BUILD_PLIST="Info.plist"
export XCODE_BUILD_APP_NAME="demo.app"
export XCODE_BUILD_APP_DIR="build"
export XCODE_BUILD_CODE_SIGN_AUTHORITY="iPhone Distribution: ABC"
export XCODE_ARCHIVE_OUTPUT_IPA_FILENAME="demo.ipa"
export XCODE_ARCHIVE_OUTPUT_IPA_DIR="build/release"
export XCODE_ARCHIVE_PROVISIONING_CERTIFICATE="demo_adhoc.mobileprovision"
...