xcrun Unable to copy to /var/folders - ios

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.

Related

xcrun: How do we sign the application along with an extension?

On our jenkins, we use the xcrun to package the application and pass the provisioning profile with embed option.
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}"
Now, we have an extension that's included with the application. How do I specify the provisioning profile to build the app with extension?

PackageApplication stopped working with OS X 10.10 (Yosemite) today

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.

ios application generation ipa from termminal

I am trying to build IPA from terminal. I tried the following steps:
Step 1:
/usr/bin/xcodebuild -target "appname" -sdk "iphoneos" -configuration Release
Step 2:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "appname" -o "/Users/Pictures/" -sign "iPhone Developer:xxxxx" --embed /Users//Library/MobileDevice/Provisioning\ Profiles/xxxxxx.mobileprovision"
I didn't get any error but I am not getting any response. I have been waiting for more than 30 minutes. What am I missing here?
I have given a brief description of steps to follow, and parameters to pass while generating an ipa using terrminal below:
1) Go to the folder which contains the MyApp.xcodeproject file in terminal
2) By using the command given below you will get all the Targets of the application
/usr/bin/xcodebuild -list
3) After the above command is executed, you will get a list of targets of which you should select a specific target you need to generate .ipa
/usr/bin/xcodebuild -target $TARGET -sdk iphoneos -configuration Release
4) The above command builds the project and creates a .app file.The path to locate the .app file is"./build/Release-iphoneos/MyApp.app"
5) After Build gets succeeded then execute the following command to generate .ipa of the application using Developer Name and Provisioning Profile using the syntax below:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v “${TARGET}.app” -o “${OUTDIR}/${TARGET}.ipa” –sign “${IDENTITY}” –embed “${PROVISONING_PROFILE}”
Explanation of each Parameter in the above syntax:
${TARGET}.app == Target path (ex :/Users/XXXXXX/desktop/Application/build/Release-iphoneos/MyApp.app) ${OUTDIR} == Select the output directory(Where you want to save .ipa file) ${IDENTITY} == iPhone Developer: XXXXXXX (XXXXXXXXXX)(which can be obtained from Keychain access) ${PROVISONING_PROFILE} == Path to the provisioning profile(/Users/XXXXXX/Library/MobileDevice/Provisioning Profiles/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.mobileprovision”)
6)ipa will be generated at selected output directory "${OUTDIR}"

How to pack ipa with signer for phonegap project

I have create a phonegap project for ios. And I use phonegap command line to build ./cordova/build. Then I use xcrun to generate an ipa, it fails.
This is my command line:
xcrun -sdk iphoneos PackageApplication -v ./build/page.app -o ~/Documents
/ipas/page.ipa -sign "iPhone Distribution: [XXXXXXX]" -embed "XXX.mobileprovision"
And this is the error I got after execute the command.
Output directory: '/Users/longfei/Documents/ipas/page.ipa'
Temporary Directory: '/var/folders/n9/1pqsg0kj667d741s43cfnlw80000gn/T/kLf7Emmi2L' (will NOT be deleted on exit when verbose set)
+ /bin/cp -Rp ./build/page.app /var/folders/n9/1pqsg0kj667d741s43cfnlw80000gn/T/kLf7Emmi2L/Payload
Program /bin/cp returned 0 : []
Checking original app
+ /usr/bin/codesign --verify -vvvv ./build/page.app
Program /usr/bin/codesign returned 1 : [./build/page.app: code object is not signed at all
In architecture: i386
]
Codesign check fails : ./build/page.app: code object is not signed at all
In architecture: i386
Done checking the original app
Embedding '~/Dropbox/Works/xcode/zs/yunsite1/yunsite1.mobileprovision'
+ /bin/rm -rf /var/folders/n9/1pqsg0kj667d741s43cfnlw80000gn/T/kLf7Emmi2L/Payload/page.app/embedded.mobileprovision
Program /bin/rm returned 0 : []
+ /bin/cp -rp ~/Dropbox/Works/xcode/zs/yunsite1/yunsite1.mobileprovision /var/folders/n9/1pqsg0kj667d741s43cfnlw80000gn/T/kLf7Emmi2L/Payload/page.app/embedded.mobileprovision
Program /bin/cp returned 1 : [cp: ~/Dropbox/Works/xcode/zs/yunsite1/yunsite1.mobileprovision: No such file or directory
]
error: Unable to copy '~/Dropbox/Works/xcode/zs/yunsite1/yunsite1.mobileprovision' to '/var/folders/n9/1pqsg0kj667d741s43cfnlw80000gn/T/kLf7Emmi2L/Payload/page.app/embedded.mobileprovision'
I'm a newbie for ios and phonegap. I have searched for a long time to get a solution, but failed. Hope you can help me. Thanks a lot.
Your command line looks OK (similar to mine). Your problem is that you are signing a debug version of your phonegap build. The error is there:
Codesign check fails : ./build/page.app: code object is not signed at all
In architecture: i386
The debug builds are i386 binaries so they run on the Mac, but the release builds are ARM binaries. I don't use phonegap to do the build, but you need to build the Release version in order to sign. I do builds like so in my makefile:
ios-app:
echo 'MAKE SURE YOU HAVE DONE security unlock-keychain login.keychain'
cd $(ios_dir);xcodebuild -target $(app_name) -project $(app_name).xcodeproj -target $(app_name) -configuration Release CODE_SIGN_IDENTITY=$(sign_identity) CONFIGURATION_BUILD_DIR=`pwd`/build
cd $(ios_dir);xcrun -sdk iphoneos PackageApplication $(ios_dir)/build/$(app_name).app -o $(ios_dir)/build/$(app_name).ipa -sign $(sign_identity) --embed $(cert_name) -verbose
Bottom line is you need to sign the correct build of the package.

Code sign validation failing during xcodebuild and Failed to read entitlements for xcrun

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.

Resources