Skip to content

Instantly share code, notes, and snippets.

@joelso
Last active December 17, 2015 05:08
Show Gist options
  • Save joelso/5555143 to your computer and use it in GitHub Desktop.
Save joelso/5555143 to your computer and use it in GitHub Desktop.
Jenkins build script for iOS app using Cocoapods
#!/usr/bin/env bash
source ~/.bash_profile
BUILD_DIR=$(PWD)/build
APP_NAME="FooApp"
CODE_SIGN_IDENTITY="iPhone Distribution: Foo & Bar"
PROVISIONING_PROFILE_ID="7637D74D-F0A0-42EC-8466-0F81978AFFEE"
PROVISIONING_PROFILE="/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles/${PROVISIONING_PROFILE_ID}.mobileprovision"
KEYCHAIN_PASSWORD="verysecret"
# Clean old build
rm -rf "$WORKSPACE/build"
# Download pods
pod repo update
pod install
# Unlock keychain
security unlock-keychain -p $KEYCHAIN_PASSWORD ~/Library/Keychains/login.keychain
xcodebuild -verbose \
-workspace $APP_NAME.xcworkspace \
-scheme $APP_NAME \
-configuration "Release" \
CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" \
PROVISIONING_PROFILE="${PROVISIONING_PROFILE_ID}" \
OTHER_CODE_SIGN_FLAGS="--keychain /Users/Shared/Jenkins/Library/Keychains/login.keychain" \
OBJROOT="$BUILD_DIR" SYMROOT="$BUILD_DIR"
# Package and sign IPA
/usr/bin/xcrun -sdk iphoneos PackageApplication -v \
"$BUILD_DIR/Release-iphoneos/$APP_NAME.app" \
-o "$BUILD_DIR/Release-iphoneos/$APP_NAME.ipa" \
--sign "${CODE_SIGN_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
@sergii-frost
Copy link

Note: To be able to run unit tests from command line separate scheme should be created and shared.
Additional flags should be set for this scheme and appropriate target.
More information to be found here:
http://jonboydell.blogspot.com/2013/01/i-have-previously-written-couple-of.html
http://www.stewgleadow.com/blog/2012/02/09/running-ocunit-and-kiwi-tests-on-the-command-line/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment