I've been trying to figure this out, but there doesn't seem to be any light at the end of the tunnel, thus trying it here...hope you can help.
I have an Ionic project. Running via ionic serve gives me the result I expect, no problem there.
However, when running a command like ionic cordova run ios -lc, I receive an error breaking the build process. The error I receive is the following:
[cordova] error: archive not found at path '/Users/path-to-app/platforms/ios/demoapp.xcarchive'
[cordova] ** EXPORT FAILED **
[cordova]
[cordova] (node:5866) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error code 65 for command: xcodebuild with args: -exportArchive,-archivePath,demoapp.xcarchive,-exportOptionsPlist,/Users/path-to-app/platforms/ios/exportOptions.plist,-exportPath,/Users/path-to-app/platforms/ios/build/device
[cordova] (node:5866) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I see 2 different errors here: archive not found and a deprecation problem. Don't know which one is breaking the build but can't seem to find a solution for either one of them.
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.1.2
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0, browser 5.0.4, ios 4.5.5
Cordova Plugins : no whitelisted plugins (0 plugins total)
System:
Android SDK Tools : 25.1.7 (/Users/Vincent/Library/Android/sdk)
ios-deploy : 1.9.2
NodeJS : v9.1.0 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Any help would be appreciated!
Currently cordova-ios is not compatible with Xcode 10
You can try to disable the new build system that Xcode 10 uses and use the old one by adding this to your build.json file
"buildFlag": [
"-UseModernBuildSystem=0"
]
or adding --buildFlag="-UseModernBuildSystem=0" to the build command
The full command should be cordova build ios --buildFlag="-UseModernBuildSystem=0".
Or for Ionic ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"
In addition to the above answer given by @jcesarmobile, another solution is to build the app with the Ionic CLI by executing the following command:
ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"
According to the documentation of the ionic build command, to pass additional options to the Cordova CLI you should use the -- separator after the Ionic CLI arguments. The execution of the build command through Ionic CLI instead of Cordova CLI will also build web assets and provide friendly checks before cordova merely builds the app.
An Example for a working build.json (to place into your cordova / ionic project root directory) is the following content:
{
"ios": {
"debug": {
"buildFlag": [
"-UseModernBuildSystem=0"
]
},
"release": {
"buildFlag": [
"-UseModernBuildSystem=0"
]
}
}
}
For more parameters about build.json see also cordova doc: https://cordova.apache.org/docs/en/latest/guide/platforms/ios/
The command suggested by jcesarmobile didn't work for me, but doing
cordova build ios --buildFlag="-UseModernBuildSystem=0"
(without ionic) succesfully completed the build.
After that I've been able to do ionic cordova build ios without any problems. (even without the buildFlag). I'm not an expert in this, in fact it was a mistake not to include ionic lol. So, although everything seems to work ok i'm not sure if there are any drawbacks in building with only cordova for the first time. Maybe someone can throw some light in the comments
In My case I have to specify the swift compiler version and workspace settings in XCODE 10.2.1
NOTE : In my project I have installed Onesignal plugin
First I specified the swift compiler version.
- Open the myproject-name.workspace file because cocoapods installed.
- Go to Build Settings Tab in xcode.
- Scroll very bottom of the build settings tab find Swift Compiler - Language.
- Select the Swift version from the Swift Language Version drop down (Ex : Swift 4).
Then Change the workspace setting
- Go to Xcode File Menu
- Select Workspace Settings
- Select Legacy Build System from the Build System drop down
- Click Done
And after all try to rebuild with following command in terminal
ionic cordova build ios
来源:https://stackoverflow.com/questions/52385600/ionic-ios-build-fails-error-archive-not-found