Not able to create IPA using xcodebuild command through jenkins shell script - ios

I am trying to create an IPA file using below command on Jenkin
xcodebuild -exportArchive -archivePath export/MySampleApp.xcarchive -exportPath export/ -exportOptionsPlist export/export_options.plist
But it gives me error
+ xcodebuild -exportArchive -archivePath export/MySampleApp.xcarchive -exportPath export/ -exportOptionsPlist export/export_options.plist
2018-06-19 19:16:07.324 xcodebuild[81214:2060182] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/y5/1qdx7j6j2tdb1j6g3vvg_xww0000gn/T/MySampleApp_2018-06-19_19-16-07.323.xcdistributionlogs'.
2018-06-19 19:17:20.872 xcodebuild[81214:2060182] [MT] IDEDistribution: Step failed: <IDEDistributionPackagingStep: 0x7ff2b080be50>: Error Domain=IDEDistributionPipelineErrorDomain Code=0 "Code signing "libswiftCore.dylib" failed." UserInfo={NSLocalizedDescription=Code signing "libswiftCore.dylib" failed., NSLocalizedRecoverySuggestion=View distribution logs for more information.}
error: exportArchive: Code signing "libswiftCore.dylib" failed.
Error Domain=IDEDistributionPipelineErrorDomain Code=0 "Code signing "libswiftCore.dylib" failed." UserInfo={NSLocalizedDescription=Code signing "libswiftCore.dylib" failed., NSLocalizedRecoverySuggestion=View distribution logs for more information.}
** EXPORT FAILED **
I was able to create an archive file using below command
xcodebuild -scheme "MySampleApp" -sdk iphoneos -target MySampleApp -destination "generic/platform=iOS" -archivePath export/MySampleApp.xcarchive archive DEVELOPMENT_TEAM="QPG8EMUULT" PROVISIONING_PROFILE="efb8da47-3b87-4880-82e8-4967167bb2d3" CODE_SIGNING_REQUIRED=NO
Can anyone please let me know what could be the issue ?

Keychain was locked on Jenkin server thats why it was not able to code sign.
Unlocked it with below command before xcodebuild command
security unlock-keychain -p yourPassword
Now its working good.

I met the problem when :
xcodebuild archive using Xcode 10
xcode-select to Xcode 9
try to run xcodebuild -exportArchive
so I xcode-select to Xcode 10 and problem solved

Related

io.jenkins.plugins.appcenter.AppCenterException: No file found matching pattern

I am trying to upload .ipa file to AppCenter using Jeinkins, but getting the following exception:
+ pwd
/Users/maniprasannakumar/.jenkins/workspace/IOS_Test
+ xcodebuild -exportArchive -archivePath /Users/maniprasannakumar/.jenkins/workspace/IOS_Test/builds/RemoteLync.xcarchive -exportOptionsPlist /Users/maniprasannakumar/Desktop/jenkinsarchinve/kiddeExportOptions.plist -exportPath /Users/maniprasannakumar/Desktop/jenkinsarchinve/
2022-01-03 12:09:16.138 xcodebuild[35412:1166670] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/hy/f06dhv196hx6bywh9lhm2ptr0000gn/T/RemoteLync_2022-01-03_12-09-16.136.xcdistributionlogs'.
Exported RemoteLync to: /Users/maniprasannakumar/Desktop/jenkinsarchinve
** EXPORT SUCCEEDED **
ERROR: Build step failed with exception
io.jenkins.plugins.appcenter.AppCenterException: No file found matching pattern: '/Users/maniprasannakumar/Desktop/jenkinsarchinve/RemoteLync.ipa'

Getting IOS development build error

Development build get the following error during export, it shows that archive succeeded. Also the app store distribution build passes. I used the cert tool to generate all certs for this.
The full build log is here:
Build log
Here is the messages that look like the cause of the failure:
** ARCHIVE SUCCEEDED **
Executing: echo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist
Executing: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist 2017-12-14 08:05:38.785 xcodebuild[42364:31715511] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/rvgame_2017-12-14_08-05-38.784.xcdistributionlogs'.
2017-12-14 08:05:38.825 xcodebuild[42364:31715511] [MT] DeveloperPortal: Using pre-existing current store at URL (file:///Users/administrator/Library/Developer/Xcode/DeveloperPortal%207.3.1.db).
2017-12-14 08:05:59.053 xcodebuild[42364:31715511] [MT] 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 **
Not sure how to fix this.
This was a problem with new Xcode requirements on static libraries. The Admob and Flurry static libs were compiled with an older version of Xcode which didn't include LC_VERSION_MIN_IPHONEOS run commands, and ipatool now crashes if it encounters a library that doesn't include this.
I have updated both the Admob and the Flurry cn1libs to use Cocoapods instead of the static library directly, and this will fix the issue. These will be available in Codename One Settings after the next server update (this week). If you need them before then, you can download and install the cn1libs directly:
https://github.com/codenameone/CodenameOneLibs/raw/master/cn1libs/CN1Flurry.cn1lib
https://github.com/codenameone/CodenameOneLibs/raw/master/cn1libs/AdmobFullScreen.cn1lib
I have also made some changes on the build server to add a more descriptive error message when it detects this scenario. That will also be updated in the next build server update.

EXPORT FAILED error using xcodebuild command line tool

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.

Exporting xcarchive and IPA in xcode 6.4

I want to make build scripts for my app to export xcarchive and ipa files.
I used following command to export xcarchive:
xcodebuild -scheme myscheme archive -archivePath path/appname.xcarchive
Which gave me an xcarchive file and I used following to export IPA file:
xcodebuild -exportArchive -exportFormat IPA -exportProvisioningProfile *** -archivePath path/appname.xcarchive -exportPath path/appname.ipa
And I got following error regardless of what I typed in front of exportProvisioningProfile.
no provisioning profile matches ***
** EXPORT FAILED **
What should I write insted of *** in front of exportProvisioningProfile?
The name of the provisioning profile. This is the same name as seen on the page (https://developer.apple.com/account/ios/profile/profileList.action). If you have spaces in that name you need to write the name with quotes. E.g.
xcodebuild -exportArchive -exportFormat IPA -archivePath
MyMobileApp.xcarchive -exportPath MyMobileApp.ipa
-exportProvisioningProfile 'MyMobileApp Distribution Profile'
It may also be that you have not downloaded the provisioning profile, try re-downloading it and opening it with Xcode to install it in the correct location.

Build Project From Terminal throws Provisioning Profile error

I am trying to create ipa of my application using terminal.
I am able to successfully build my application, but when converting into an ipa, it throws the following error:
Check dependencies
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “/Users/xxxx/Downloads/Certificate/xxxx.mobileprovision”, however, no such provisioning profile was found.
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'
** ARCHIVE FAILED **
When I try to build the same application using X-Code, it works fine with the same provisioning profile.
The script I am running to build the ipa is
xcodebuild -verbose -project Build_Project_From_Terminal.xcodeproj -scheme nameOfProject -configuration Release -sdk iphoneos clean archive CONFIGURATION_BUILD_DIR="/Users/xxxx/Desktop/xxxx/Project Name/build" PROVISIONING_PROFILE="/Users/xxxxx/Downloads/Certificate/xxxxx.mobileprovision"
EDIT 1:
I have changed my script to
DEVELOPER_NAME="xxxxxxxxx" APP_NAME="xxxxxx"
xcodebuild archive -project $APP_NAME.xcodeproj -scheme $APP_NAME -archivePath ./$APP_NAME.xcarchive
xcodebuild -exportArchive -exportFormat APP -archivePath ./$APP_NAME.xcarchive -exportPath ./$APP_NAME.ipa
iphoneos PackageApplication -v ./$APP_NAME.app -o ./$APP_NAME.ipa --sign $DEVELOPER_NAME --embed ./*.mobileprovision
With this I am getting $APP_NAME.ipa.app as output. When I try to install this, it does not install at all.
Any help will be appreciated.
Please use an alternate method. This is a working example
DEVELOPER_NAME="Your apple developer name"
APP_NAME="application name"
xcodebuild archive -workspace $APP_NAME.xcworkspace -scheme $APP_NAME -archivePath ./$APP_NAME.xcarchive
xcodebuild -exportArchive -exportFormat APP -archivePath ./$APP_NAME.xcarchive -exportPath ./$APP_NAME.ipa
iphoneos PackageApplication -v ./$APP_NAME.app -o ./$APP_NAME.ipa --sign $DEVELOPER_NAME --embed ./*.mobileprovision
Save above shell script in a file (abc.sh) and save that file in your project folder along with your provision profile. Run this script using terminal will save ipa in the project directory.

Resources