I have to start by saying if I build using Xcode, everything is fine. My goal is to use xcodebuild with Jenkins so that I can have automated builds with multiple environments. I am really confused with how Xcode 8 works with automated signing.
I started by looking at this: Use xcodebuild (Xcode 8) and automatic signing in CI (Travis/Jenkins) environments
Things started to work when I did this. However, now when I added a new bundle ID and PP, I started to get the following errors. Also, the previous build ID doesn't work either:
Building
23:06:50 Check dependencies
23:06:50 [BCEROR]No profiles for 'com.x.y.z' were found: Xcode couldn't find a provisioning profile matching 'com.x.y.z'.
23:06:50 [BCEROR]Code signing is required for product type 'Application' in SDK 'iOS 10.3'
Archiving
23:06:51 No profiles for 'com.x.y.z' were found: Xcode couldn't find a provisioning profile matching 'com.x.y.z'.
23:06:51 Code signing is required for product type 'Application' in SDK 'iOS 10.3'
23:06:51 ** ARCHIVE FAILED **
This is what I am doing:
#if the directory exist, run the command
if [ -d "~/Library/Developer/Xcode/DerivedData" ]; then
xattr -rc ~/Library/Developer/Xcode/DerivedData
fi
#Unlock keychain
security unlock-keychain -p xxx ~/Library/Keychains/login.keychain
#Build .xarchive
xcodebuild -project ${WORKSPACE}/PATH.xcodeproj \
-scheme X \
-configuration Release \
clean \
archive -archivePath ${WORKSPACE}/.../archive.xcarchive \
DEVELOPMENT_TEAM=XXX
#Unlock keychain
security unlock-keychain -p x ~/Library/Keychains/login.keychain
#Exporting to .ipa
xcodebuild -exportArchive -archivePath ${WORKSPACE}/XXX/archive.xcarchive \
-exportOptionsPlist /XXXX/exportOptions.plist \
-exportPath ${WORKSPACE}/XXXX/Output/${Environment} \
PROVISIONING_PROFILE_SPECIFIER="ENVIRONMENT_PP"