Jenkins automated iOS build has SwiftSupport folder missing - ios

Currently I'm having an issue that when jenkins executes a job to generate a .ipa to submit to testflight, Apple sends me the following email:
We have discovered one or more issues with your recent delivery for "XXXXX". To process your delivery, the following issues must be corrected:
Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.
Once these issues have been corrected, you can then redeliver the corrected binary.
I opened the .ipa that was uploaded and it's true this folder isn't there.
So I tried doing the build manually... I used the same workspace that jenkins uses to generate the builds, and I manually generated a build to upload to AppStore and everything went well...
What might be the problem with the automated build? Is there a step that jenkins might be missing?
Is anyone having the same issue??

Archive the application
xcodebuild \
-workspace "${WORKSPACE_FILE}" \ # only if you are using workspace
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-archivePath "${PROJDIR}/Build/${SCHEME_NAME}.xcarchive" \
-configuration Release \
archive
Export the archive to an ipa
xcodebuild \
-exportArchive \
-archivePath "${PROJDIR}/Build/${SCHEME_NAME}.xcarchive" \
-exportOptionsPlist "${PROJDIR}/exportOptions.plist" \
-exportPath "${PROJDIR}/Release"
exportOptions.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
</dict>
</plist>

Are you specifying the -exportOptionsPlist option on your xcodebuild command?
See xcodebuild -help for the available keys, but you probably want a plist with at least he method key set to "app-store", like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
</dict>
</plist>

Related

publish an xcodebuild iOS app with an healthkit based watchOS extension

I am using the xcodebuild for creating a package for publishing
The app bundle contains: the iOS app itself, the push notification extension, the watchos app with its extension.
The watchOS app is using the healthkit for retrieving heart rate data.
xcodebuild archive -configuration Release -workspace $(system.defaultworkingdirectory)/MyApp/MyApp.xcworkspace -scheme MyApp -archivePath $(system.defaultworkingdirectory)/MyAppArchive CODE_SIGNING_ALLOWED=NO
xcodebuild -exportArchive -archivePath $(system.defaultworkingdirectory)/MyAppArchive.xcarchive -exportPath $(system.defaultworkingdirectory)/Final -exportOptionsPlist $(system.defaultworkingdirectory)/MyApp/ExportOptions.plist
The ExportOptions.plist contains the info for signing the app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>provisioningProfiles</key>
<dict>
<key>fit.myapp.watchkitapp.watchkitextension</key>
<string>ProvisioningProfileGUID1</string>
<key>fit.myapp.watchkitapp</key>
<string>ProvisioningProfileGUID2</string>
<key>fit.myapp.notification</key>
<string>ProvisioningProfileGUID3</string>
<key>fit.myapp</key>
<string>ProvisioningProfileGUID4</string>
</dict>
<key>signingCertificate</key>
<string>Apple Distribution: MY COMPANY</string>
<key>signingStyle</key>
<string>manual</string>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>MYTEAMID</string>
<key>uploadBitcode</key>
<false/>
</dict>
</plist>
The ipa file is successfully created but when the ipa file is uploaded (by Transporter app) the package analysis fails with the following errors:
Asset validation failed (90701)
Missing entitlement. watchOS app bundle 'MyApp.app/Watch/MyAppWatch.app/PlugIns/MyAppWatch Extension.appex' uses 'UIBackgroundModes' value 'workout-processing' without the required entitlement 'com.apple.developer.healthkit' signed into the bundle. (ID: cc87a6cd-2084-4712-9f45-b22b35e9574a)
Asset validation failed (90334) Invalid Code Signature Identifier. The
identifier "com.apple.WK" in your code signature for "MyAppWatch"
must match its Bundle Identifier "fit.myapp.watchkitapp" (ID:
bb9a56d3-949c-4b49-ad86-3cf7a26a91a2)
Extra note: If the build has performed directly in Xcode/Organizer then the issue is not present.
What am I missing?
How can I debug this kind of issues?

Reach User Defined Build Settings inside exportOptionsPlist

I have a project which consists of different targets for different build environments. I'm getting IPA file on Jenkins with xcodebuild. I want to define one exportOptionsPlist file and assign a different variable for different targets. For example, for method, Dev target should have development and Prod target should have app-store. For achieving this I'm defining User-Defined settings in Build Settings.
P.S: Every target has only Debug and Release options and every target has IPA_EXPORT_METHOD.
My problem is that I'm getting below error when trying to get the IPA (Reading IPA_EXPORT_METHOD from the ExportOptionsPlist file):
Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {app-store, ad-hoc, enterprise, development, validation}, but found ${IPA_EXPORT_METHOD}" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {app-store, ad-hoc, enterprise, development, validation}, but found ${IPA_EXPORT_METHOD}}
How can I get the archive:
$ xcodebuild -workspace CLI.xcworkspace -scheme CLI -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/CLI.xcarchive
How can I get the IPA:
$ xcodebuild -exportArchive -archivePath $PWD/build/CLI.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build
Export Options Plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>destination</key>
<string>export</string>
<key>method</key>
<string>${IPA_EXPORT_METHOD}</string>
<key>provisioningProfiles</key>
<dict>
<key>com.iamdeveloper.myproject.dev</key>
<string>My Provision File</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Developer</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>XXXXXXXXX</string>
<key>thinning</key>
<string><thin-for-all-variants></string>
</dict>
</plist>
EDIT: I can define different exportOptionsPlists for different targets. This solves my problem but I want to achieve it with one plist file.

How to get a distribution app when using xcodebuild -exportArchive (Xcode8.3, Auto Signing)?

After update Xcode8.3, the options '-exportSigningIdentity', '-exportProvisioningProfile' and '-exportFormat' are removed from 'xcodebuild -exportArchive'.
When i try to get a distribution app, i get the error below: xcodebuild: error: invalid option '-exportProvisioningProfile'.
So how can i get distribution MyApp.ipa from MyApp.xcarchive, when the project has set Automatic Signing Enabled?
Automatic Signing
Sounds like you want to create an IPA on the command line from an existing xcarchive. Since Xcode 7, the preferred way to do this is (from man xcodebuild):
xcodebuild -exportArchive -archivePath xcarchivepath -exportPath destinationpath -exportOptionsPlist path
So in your case:
xcodebuild -exportArchive -archivePath MyApp.xcarchive -exportPath MyApp.ipa -exportOptionsPlist exportOptions.plist
exportOptions.plist is a PLIST file that contains various parameters configuring the IPA export. See xcodebuild -help for all available options. You'll have to at least specifiy an entry for method (app-store, ad-hoc, enterprise etc. - defaults to development). If you just want to export for App-Store distribution, the file should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
</dict>
</plist>
Just replace this parameter :
-exportProvisioningProfile "MyProvisioningProfile"
with:
PROVISIONING_PROFILE_SPECIFIER="MyProvisioningProfile"
Hope it helps.
When you set Automatic Signing Enabled Xcode will automatically generate according provisioning profile.
But in order to make your command working you need to manually export the archive the first time.
Once it is done, Xcode will generate the provisioning profile (it starts by "XC" in the Apple Developer website).
Then your xcodebuild command will work.
Product -> Archive
Once it's done
Windows -> Organizer -> Select the last version -> Export (right pannel under Upload to App Store)
Keep me inform if you need additional informations.

error: exportArchive: The operation couldn’t be completed. (IDEDistributionErrorDomain error 3.)

I am building iOS project on command line using xcodebuild. Building with Release configuration is ok which created and App.xcarchive. Then I am trying to export archive for App Store IPA using,
xcodebuild -exportArchive -archivePath App.xcarchive -exportPath ~/output/ -exportOptionsPlist appstore.plist
My appstore.plist,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>teamID</key>
<string>T3AM1D</string>
<key>method</key>
<string>app-store</string>
</dict>
</plist
This gives me error,
error: exportArchive: The operation couldn’t be completed.(IDEDistributionErrorDomain error 3.)
Any help will be appreciated.
Finally I was able to solve this issue.
Solution Steps
Make sure all profiles and certificates are setup successfully in Mac
Make sure no red mark is shown from Xcode, For example Xcode->targets->Build settings ->Profiles and signing identity + team
Make sure that all targets including MainApp, Widgets, Extensions are also configures without issue
Make sure that all capabilities, appgroup and keychains are OK
Important: Make sure that from Xcode -> Product -> Archive -> export to App Store IPA ran at least one time
When running xcodebuild from command line, make sure that Xcode is closed
Hope this helps

Xcode export Step failed: IDEDistributionThinningStep

I'm using Xcode version 8.2.1 and Mac OS Sierra 10.12.2
Having issues exporting archive using Xcode build command:
xcodebuild -exportArchive -archivePath {archivePath} -exportPath {exportPath} -exportOptionsPlist {exportOptionsPlistPath}
While running this command i'm getting this issue:
[MT] IDEDistribution: Step failed: <IDEDistributionThinningStep: 0x7fa4d888ee20>: Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo={NSLocalizedDescription=No applicable devices found.}
error: exportArchive: No applicable devices found.
Also when trying to export manually, and choosing export for specific device i'm getting this error :
The exportOptionsPlist file looks as follow:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
</dict>
</plist>
I tried to play with the thinning param but nothing helped.
Thanks in advance
Are you still having this problem?
I recently run into this issue ... and I am still working on it. So far, I see a problem in your exportOptionsPlist file, it should also include a teamID, I mean:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
<key>teamID</key>
<string>XX..XX</string>
</dict>
</plist>
Also, the error No applicable devices found might appear if one of the framework/library you app depends on, does not support bitcode but your app requires it.
I recommend you to follow this issue in fastline where it is described how to fully debug this error: https://github.com/fastlane/fastlane/issues/8737.
Regards.

Resources