Skip to content

heleny/xcode-continuous-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 

Repository files navigation

Xcode Continuous Integration

Notes for myself

Here is Apple's guide on Xcode Continuous Integration Guide.

How to setup Xcode continuous integration using Xcode Server

  • Install and configure OS X Server
  • Install the latest Xcode
  • Create a Bot in Xcode
  • Upload the ipa to Amazon S3 or TestFlight using s3cmd
  • Set up access_key and secret_key of the aws account
		$s3cmd --configuration
		s3cmd="python ${HOME_DIRECTORY}/dev/s3cmd-master/s3cmd --access_key=xxxxxxxxxx --secret_key=xxxxxxxxxx"
		$s3cmd put ${XCS_OUTPUT_DIR}/${XCS_BOT_NAME}.ipa s3://${FOLDER_NAME}/${APPLICATION_NAME}.ipa	
  • For uploading *.ipa to TestFlight, see details here Upload Xcode Build to TestFlight

  • If bot build fails somehow, make sure to check out Xcode Bots Common Problems And Workarounds.

    My bots kept failing when I forgot to copy my keys to System instead of Login on Keychain.
    Make sure to download the Apple Production IOS Push Services certificate to the Keychain Access.

  • In order to enable Apple Push Notification for Bot builds, make sure you have setup 'Code Signing Entitlements'

  • Create Entitlements.plist if not available, it would look like something similar to the following:

<?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>com.apple.developer.team-identifier</key>
        	<string>${APPLE_DEVELOPER_ACCOUNT_TEAM_ID}</string> 
		<key>application-identifier</key>
       		<string>${APP_ID_PREFIX}.${XCODE_PROJECT_BUNDLE_IDENTIFIER}</string>  // project target -> General -> Identify -> Bundle Identifier 
        	<key>aps-environment</key>
        	<string>production</string> // or development
        	<key>keychain-access-groups</key>
        	<array>
                	<string>${APP_ID_PREFIX}.*</string>
        	</array>
	</dict>
	</plist>
  • Click on project target -> Build Settings -> Code Signing -> add the path of Entitlements.plist to 'Code Signing Entitlements'.

    It took me a couple of days to figure this out. Thanks to these posts on stackoverflow here and there.

  • Steps to verify entitlements is picked by the code signing process:

    • unzip *.ipa file
    • cd Payload/*.app/
    • open your app binary file and look for aps-environment
    • if aps-environment is not in the binary file but it's found in the embedded.mobileprovision, double check Entitlements.plist
  • If push notification still doesn't work, you can try to re-sign your ipa

		SIGNING_IDENTITY="xxxxxxxxxxxxxxxx.mobileprovision"
		PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/xxxxx_adhoc.mobileprovision"
		/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${SIGNING_IDENTITY}" --embed "${PROVISONING_PROFILE}"
		set
  • Once the build is done, click on Logs, all the env are listed there

Notes: You don’t need the entitlements file for a development build using a development provisioning profile unless you want to use push notifications, iCloud storage, or keychain sharing.
To enable these features you must specify an entitlements file during code signing. Entitlements file must contain the application-identifier and aps-environment keys.

Upload ipa to Apple iTune Connect TestFlight

  • Download deliver
  • after script looks like the following
deliver testflight -u ${APPLE_USER_ID} -a ${APP_APPLE_ID} ${XCS_OUTPUT_DIR}/${XCS_BOT_NAME}.ipa
/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool --upload-app -f ${XCS_OUTPUT_DIR}/${XCS_BOT_NAME}.ipa -u APPLE_ID -p APPLE_ID_PASSWORD

FAQ on Xcode Server and Bot

Q: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”, however, no such provisioning profile was found. CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'.
A: Copy provisioning profiles from ~/Library/MobileDevice/Provisioning\ Profiles/ to /Library/Developer/XcodeServer/ProvisioningProfiles/.

Q: How to remove all traces of ever running Xcode Server on your system?
A: sudo xcrun xcscontrol --reset

Q: If you're hosting the Xcode server on a mac mini, what is the easiest and quickest way to remote access your Server?
A: ssh into your server, and then run the following

		sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw appname -restart -agent -privs -all
		open /System/Library/CoreServices/Screen\ Sharing.app/

Once done, turn it off

		sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off

Q: How to fix xcode build server's internal-checkout-error?
A: A couple of things need to check:

  • submodule detached from HEAD

    • check Xcode -> Source Control
    • make sure all working branch are pointing to master branch
  • Error Domain=XCSBuildServiceDomain Code=-1 "SCM dictionary scmType is nil"

    • make sure all working copies under Xcode -> Source Control are from the same workspace
    • make sure all submodules are in the same workspace of the project
    • otherwise, clean it up
    • if it still doesn't work, clean server cache:
		rm -rf ~/Library/Developer/Xcode/DerivedData/
		rm -rf /Library/Server/Xcode/Data/BotRuns
		rm -f /Library/Server/Xcode/Data/BotRuns/Cache

Q: Why Bot doesn't show up correctly on Xcode?
A: Try to delete all the repos and server via Xcode -> Preferences -> Accounts, and then add them back, do a clean on /Library/Server cache and bots, and flush out Xcode's DerivedData.

Q: Where is the ipa created by Xcode Bot?
A:

/Library/Server/Xcode/Data/BotRuns/BotRun-ec531f8a-8501-486a-84ad-98045f03f0a2.bundle/output/ibot.ipa

Q: Xcode 6 for Enterprise Deployment does not create plist for ipa anymore. Why and how to solve it? A: Don't know why. I would use the old plist from Xcode 5

		<?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>items</key>
        			<array>
                			<dict>
                        			<key>assets</key>
                        			<array>
                                			<dict>
                                        			<key>kind</key>
  			                                        <string>software-package</string>
			                                        <key>url</key>
                       				                <string>[INSERT URL HERE]</string>
                                			</dict>
                        			</array>
                        			<key>metadata</key>
                        			<dict>
                                			<key>bundle-identifier</key>
                                			<string>[INSERT BUNDLE ID HERE]</string>
			                                <key>bundle-version</key>
			                                <string>[INSERT VERSION HERE]</string>
                                			<key>kind</key>
			                                <string>software</string>
                       				        <key>title</key>
                                			<string>[INSERT APP TITLE HERE]</string>
                        			</dict>
                			</dict>
        			</array>
			</dict>
		</plist>

Q: How to switch to a different branch for a Xcode Bot?
A: 'git co new_branch_name' won't work. This is what I do to make it work and then need to create a new bot (apply this change to an existing bot won't work 😦 source is from Xcode Service - Choose a git branch):

		Xcode -> Source Control -> [PROJECT_NAME] -> Switch to Branch

Q How to auto-increment the build verison number? Hint: http://blog.jaredsinclair.com/post/97193356620/the-best-of-all-possible-xcode-automated-build

About

How to setup Xcode continuous integration using Xcode Server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published