UPDATE:
The correct answer is probably this one: Xcode 6.1 error while building IPA
Using Jenkins to build iOS projects from repositories since a few years. Suddenly today a new error occurs, stopping builds.
I think I based most of this setup on this tutorial way back:
http://www.raywenderlich.com/22816/beginning-automated-testing-with-xcode-part-22
This step causes the error:
# 4
echo "*** Post build step 4"
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-o "${IPA_DIR}/${PROJECT}.ipa" \
-verbose "${APP}" \
-sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
It's a bit tricky to look at the logs where the error occurs, but here it is:
### Codesigning '/Users/Shared/Jenkins/Home/jobs/myapp/workspace/myapp_adhoc_7.mobileprovision' with 'iPhone Distribution: mycompany Inc.'
+ /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone Distribution: mycompany Inc. --resource-rules=/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist --entitlements /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/entitlements_plistYdluSmqT /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app
Program /usr/bin/codesign returned 1 : [Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
Warning: --resource-rules has been deprecated in Mac OS X >= 10.10!
/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist: cannot read resources
]
error: /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone Distribution: mycompany Inc. --resource-rules=/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist --entitlements /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/entitlements_plistYdluSmqT /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app failed with error 1. Output: Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
Warning: --resource-rules has been deprecated in Mac OS X >= 10.10!
/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist: cannot read resources
I'll try to fix this myself and later add the solution here, but in case anyone is faster than me please go ahead.
I have not specified --resource-rules in any settings. I guess xcrun uses this setting on its own, even though it is deprecated.
Instead of using xcrun, you can use xcodebuild to create an archive and then run xcodebuild again to create the IPA file.
# Create an archive
xcodebuild -alltargets -configuration "${CONFIGURATION}" -scheme "${SCHEME}" -archivePath "${APP_PATH}/${PROJECT}.xcarchive" archive
# Create the IPA file from the archive
xcodebuild -exportProvisioningProfile "${PROVISIONING_PROFILE_NAME}" -exportArchive -exportFormat IPA -archivePath "${APP_PATH}/${PROJECT}.xcarchive" -exportPath "${IPA_DIR}/${PROJECT}.ipa" CODE_SIGN_IDENTITY="${SIGNING_IDENTITY}"
Note that ${PROVISIONING_PROFILE_NAME} should contain the name of the provisional profile, and not the path to the file itself.
Found the answer.
The problem that occurred now was the "xcrun PackageApplication" something something line. I had to remove the "-sign some profile" parameter, then things started working again.
That said I don't know why signing was necessary before, and why it isn't now so can't tell if this is going to cause some problem later.
Related
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"
So I am using Unity to generate the xcode project. What I did to fix it:
In Unity, disable the automatic signing and specify the Provisioning profile hash, (I got the hash from using the editor view, and copied the value to the script):
private static readonly string UDIDProfileHash = "HASH";
PlayerSettings.iOS.appleEnableAutomaticSigning = false;
PlayerSettings.iOS.appleDeveloperTeamID = "TEAMID";
PlayerSettings.iOS.iOSManualProvisioningProfileID = UDIDProfileHash;
For the Xcodebuild syntax I removed specifying the Provisioning profile:
PROVISIONING_PROFILE_SPECIFIER="ENVIRONMENT_PP"
I'm trying to export an ipa file through xcodebuild but I always receive this error.
IDEDistribution: Step failed: : Error Domain=IDEDistributionErrorDomain Code=14 "No
applicable devices found." UserInfo={NSLocalizedDescription=No
applicable devices found.} error: exportArchive: No applicable devices
found.
Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices
found." UserInfo={NSLocalizedDescription=No applicable devices found.}
** EXPORT FAILED **
Any hint?
This is the shell script I'm using (run in terminal through sh export_script.sh)
xcodebuild clean -project 'MyProject.xcodeproj' -configuration Debug -scheme MyProject -alltargets
xcodebuild -project 'MyProject.xcodeproj' -scheme MyProject archive -archivePath 'MyProject.xcarchive'
xcodebuild -exportArchive -archivePath 'MyProject.xcarchive' -exportPath 'Export' -exportOptionsPlist 'Options.plist'
P.S. Point me out any error in my scripts, if present.
I'm not sure, but probably you should specify you need a build for a device.
You need to add -sdk with proper value (depends on iphoneos with version number)
The old way to do it seems to do the job.
xcodebuild -exportArchive -archivePath $XCODE_ARCHIVE -exportPath $EXPORT_PATH -exportFormat ipa -exportProvisioningProfile "$PROVISIONING_PROFILE" -configuration $CONFIGURATION
where $PROVISIONING_PROFILE is for example iOS Development. The archive is created correctly. The shell will print out a deprecation log. You can safely ignore it.
The new way, introduced with Xcode does not work (at least for me). See xcodebuild's new exportOptionsPlist flag.
If you have any hint to use the new way, please post it.
Edit
There is an open radar for it Open Radar. In addition, also Fastlane provides a fallback mechanism for this problem (see Export Failed with Xcode 7 - No applicable devices found).
In my case the issue was related to using RVM. Switching to the system Ruby solved the issue:
rvm use system
Seams like some parts of xcodebuild are relying on the system version of Ruby and don't play nice with RVM.
I use to automate the build of my Adhoc and Distrib release of my apps with a simple script:
echo "***** xcodebuild: compile project"
xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release CONFIGURATION_BUILD_DIR="${PROJECT_BUILDDIR}"
echo "***** xcrun Package app (ipa file) - Adhoc release"
/usr/bin/xcrun -sdk iphoneos PackageApplication "${PROJECT_BUILDDIR}/${PROJECT_NAME}.app" -o
"${PROJECT_BUILDDIR}/${PROJECT_NAME}_adhoc.ipa" --sign
"${DEVELOPPER_NAME}" --embed "${ADHOC_PROVISONNING_PROFILE}"
echo "* xcrun Package app (ipa file) - AppStore release"
/usr/bin/xcrun -sdk iphoneos PackageApplication "${PROJECT_BUILDDIR}/${PROJECT_NAME}.app" -o
"${PROJECT_BUILDDIR}/${PROJECT_NAME}_appstore.ipa" --sign
"${DEVELOPPER_NAME}" --embed "${APPSTORE_PROVISONNING_PROFILE}"
It was working fine before. But then I installed Mac OS Maverik and I also updated my expired certificates & prov profiles. And since then, when I try to upload the generated IPA to iTunes Connect (for the Distribution release) or TestFlight (for the Adhoc release), I get this error message:
ERROR ITMS-9000: "Invalid Code Signing. The executable
'Payload/mosa_en_it.app/mosa_en_it' must be signed with the
certificate that is contained in the provisioning profile." at
SoftwareAssets/SoftwareAsset (MZItmspSoftwareAssetPackage)
But it's working when I do it manually on XCode (Archive->Distribute..).
Also, I don't know if it's related but I have lots of duplicates certificates: screenshot
(but I don't know how to delete them)
Thanks in advance for your help
I'm getting errors when trying to run /usr/bin/xcrun
/usr/bin/xcrun -sdk iphoneos PackageApplication /Users/xxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/archive.xcarchive/Products/Applications/MyApp.app -o /Users/xxxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/MyApp.ipa --sign "iPhone Distribution: MyComp" --embed /Users/xxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision
and error is like this:
error: Unable to copy '/Users/xxxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision'
to '/var/folders/1t/pgh7fy550vl8nrvtmqhvn_780000gn/T/cjftmH0k7i/Payload/MyApp.app/embedded.mobileprovision'
Any idea?
What's wrong with this case?
The provisioning file has been already embedded in your application (MyApp.app)
You can check this by extracting the .app using Archive Utility.
Remove the part --embed /Users/xxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision from the command line and try again.
I have tried every available solution over here and on the internet.
I am trying to automate the iOS build process, and the clean, build and archive process succeed with these 5 warnings (errors) failing code sign validation.
warning: The CodeResources file is missing and it must be a symbolic link to _CodeSignature/CodeResources. Make certain that the bundle is on a locally-mounted volume (not a remote SMB volume), and be certain to use the Mac OS X Finder to compress it (-19062)
Unable to validate your application. - (null)
warning: iPhone/iPod Touch: application executable is missing a required architecture. At least one of the following architecture(s) must be present: armv6 (-19033)
Unable to validate your application. - (null)
warning: Icon specified in the Info.plist not found under the top level app wrapper: (-19007)
Unable to validate your application. - (null)
warning: iPhone/iPod Touch: Info.plist: Unable to verify icon dimensions, no icon found. Your MinimumOSVersion is below 3.2, so you must define CFBundleIconFile or provide a default Icon.png that is 57x57. (-19013)
Unable to validate your application. - (null)
warning: Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)
If i try to ignore the warning or use the debug config to skip validating the codesign, xcrun to package the .app to .ipa fails with following error
env SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication -v
/Users/XXXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_11_31_23.app -o
/Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_11_31_23.ipa
--sign iPhone\ Distribution
--embed/Users/XXXXXXX/source/digital_hub/cms/cms_local_repo/6072/76/XXXXXXXX_AppStore_11_07_1373971044.mobileprovision
error: Failed to read entitlements from '/var/folders/n6/8tsx1pss5v3fq3sfpz8379r0ms3b7m/T/Rm5MudWNER/Payload/Test_22_07_13_11_31_23.app'
My xcodebuild command is following as I am working with workspaces
/usr/bin/xcodebuild -verbose
-workspace /Users/XXXXX/source/digital_hub/cms/git_local_repo/11330/80/PDFReader.git/XXXXXX.xcworkspace
-scheme _DEFAULT -sdk iphoneos -configuration Release CODE_SIGN_IDENTITY="iPhone Distribution:"
PROVISIONING_PROFILE=73DE6F20-FAB9-46A2-9825-35D7DE82CD4D
CONFIGURATION_BUILD_DIR=/Users/ahsandar/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.app
OTHER_CODE_SIGN_FLAGS="--keychain /tmp/xcoder1374496105" clean
My xcrun command looks like this
/usr/bin/xcrun -log -sdk iphoneos PackageApplication -v
"/Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.app" -o
"/Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.ipa" --sign "iPhone Distribution:"
--embed "/Users/XXXXX/source/digital_hub/cms/cms_local_repo/11330/80/XXXXXX_AppStore_11_07_1373
I am using xcoder gem to create temporary keychain to add my p12 in it. all verification on the archive are successful using the command line tools for codesign.
Looks like you have set minimus os smaller than possible in project settings, possible your icons have wrong size. Please read again your first log.
And be sure that you provide correct params to xcodebuild command.
For me clean works good with these args:
xcodebuild clean -sdk iphoneos5.1 -project '${PBXPROJ}.xcodeproj' -configuration '${MCONFIG}' -alltargets DSTROOT="${RELEASE_BUILDDIR}" PROVISIONING_PROFILE="${kPROVISONING_PROFILE}" CODE_SIGN_IDENTITY="${DEVELOPER_NAME}"
And build works good like that:
xcodebuild install -sdk iphoneos5.1 -project "${PBXPROJ}.xcodeproj" -configuration "${MCONFIG}" -target "${TARGET}" DSTROOT="${RELEASE_BUILDDIR}" PROVISIONING_PROFILE="${kPROVISONING_PROFILE}" CODE_SIGN_IDENTITY="${DEVELOPER_NAME}"
Hope it helps.