LATEST_SIMULATOR_SDK=$(xcodebuild -showsdks | grep "Simulator - iOS" | grep -o '\d*\.\d*' | head -n 1)
This will allow Jenkins to run windowed processes like the iOS Simulator. Stop the Jenkins service and move to launch agents:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/
Remove the following lines from the moved org.jenkins-ci.plist:
<key>SessionCreate</key
<true />
Restart the Jenkins service:
sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist
Without unlocking the keychain CI users like Jenkins will not be able to access the certificates for resigning:
security unlock-keychain -p "$KEYCHAINPASS" /Users/Shared/Jenkins/Library/Keychains/login.keychain
In order to codesign for distribution, both a developer and distribution certificate must be installed in the keychain. Codesign will not warn you of this.
Sometimes some of the integrated libraries in Xcode can stop builds from working. Update the the latest Xcode to ensure everything is up to date.