-
-
Notifications
You must be signed in to change notification settings - Fork 197
Description
From Xcode 8.3+ the way IPA is built changed.
The generation of the IPA is a two step process now:
xcodebuild archivexcodebuild export
Archive
This makes an archive folder that has app, debug symbols, etc. It has all the artefacts necessary to export for Development, Ad-Hoc or App Store distribution. The app is signed with the certificate and provisioning profiles set in the .xcconfig or in the xcodeproj (using the --provision option).
Export
This takes the archive and exports IPA for Development, Ad-Hoc or AppStore. During the export, the app is often resigned with a distribution certificate and an ad-hoc or AppStore distribution provisioning profile.
Problems
Currently the CLI does archive then export for development when tns build|run is issued. This leads to underwhelming results when developers try to publish at the store or export for ad-hoc using tns build. Why? During the export session the xcodebuild command accepts an -exportOptionsPlist that can contain keys listed in xcodebuild --help. Most importantly the: method : String:
Describes how Xcode should export the archive. Available options: app-store, package, ad-hoc, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to development.
The default is "development", for exportOptionsPlist currently the app/App_Resources/Info.plist is currently provided (IMO incorrectly) and it has no method key, so development is used as fallback. When the developers configure the .xcconfig to use Ad-Hoc or AppStore provisioning profile, the export is still performed as development, the result IPA is then incorrectly set to still use development settings such as entitlements.
Here are the related issues to exactly this problem:
- Build in release mode for iOS doesn't seem to set the production mode for APN #2888
- iOS Archive does not respect release flag #2999
(perhaps incorrectly?) tries to provide distribution certificate for archive, while archive should be performed with development certificate and export should sign with distribution certificate - Unable to tns publish ios #2922
Signes multitarget app with the AppStore distribution, there is a bug in old Ruby and Cocoapods that leads to this - Build in release mode for iOS doesn't seem to set the production mode for APN #2888
Building with --release as mentioned still exports with method: development - Web pack issues when build in release mode #2716
- EXPORT FAILED xcode 8.3 #2702
Similar to 2922 - resolved by ruby and cocoapods update but also the missing exportOptionsPlist is noted in warnings
We have discussed internally that adding tns archive + tns export would diverge too much from the current and Android build commands, also people shouldn't care how the build is implemented internally.
Here are some clues how this can be addressed:
The export during tns build ios is done here:
nativescript-cli/lib/services/ios-project-service.ts
Lines 259 to 263 in 1955028
| let args = ["-exportArchive", | |
| "-archivePath", archivePath, | |
| "-exportPath", exportPath, | |
| "-exportOptionsPlist", platformData.configurationFilePath | |
| ]; |
It incorrectly gets the app/App_Resources/Info.plist as exportOptionsPlist. Instead such export.plist files should be generated somewhere in the platforms/ios/build similar to the exportArchive that is currently used only for distribution:
nativescript-cli/lib/services/ios-project-service.ts
Lines 212 to 229 in 1955028
| let plistTemplate = `<?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> | |
| `; | |
| if (options && options.teamID) { | |
| plistTemplate += ` <key>teamID</key> | |
| <string>${options.teamID}</string> | |
| `; | |
| } | |
| plistTemplate += ` <key>method</key> | |
| <string>app-store</string> | |
| <key>uploadBitcode</key> | |
| <false/> | |
| <key>uploadSymbols</key> | |
| <false/> | |
| </dict> | |
| </plist>`; |
The method - Ad-Hoc or AppStore distribution that should be used during
tns build ios should either be provided through an option, or inferred from the provisioning profile used during the build.