51

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 two different errors here: archive not found and a deprecation problem.

I don't know which one is breaking the build, but I can't seem to find a solution for either one of them.

Ionic information:

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vincent
  • 595
  • 1
  • 5
  • 13

7 Answers7

102

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"

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • 3
    I don't have a build.json file, where is it ? – Lenny D Sep 18 '18 at 15:48
  • build.json is not required while in development, so you can use the --buildFlag param instead. build.json file is used to configure the build configuration of the app, specially for release mode. See the docs at https://cordova.apache.org/docs/en/8.x/guide/platforms/ios/index.html#using-buildjson. You just have to create it on the root of your project – jcesarmobile Sep 18 '18 at 15:53
  • 1
    Strange, it's not working for me I tried ionic cordova build ios --buildFlag="-UseModernBuildSystem=0" but getting same error. Will this work from the ionic command also ? – Lenny D Sep 18 '18 at 16:00
  • @jcesarmobile: My build keeps getting broken, as well as I am not able to run the app in device with free apple id and team setup. Does apple removed support from running the project in device via personal team also? – iPeter Oct 09 '18 at 13:16
  • FYI this is **File > Workspace Settings... >> Build System** if you'd rather take the GUI route – Jacksonkr Mar 18 '19 at 19:02
  • sir its not working for me got error :Error: Error code 65 for command: xcodebuild with args: -xcconfig,/ in CLI? – Kapil Soni Apr 03 '19 at 10:40
  • @jcesarmobile : ok sir but do you have any idea sir how to fix above error i stuck this issue last 2 days as well as I don't have a build.json file and another error is Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 12.1'? – Kapil Soni Apr 03 '19 at 11:30
31

In addition to the 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
AlexGpeppe
  • 429
  • 4
  • 10
20

An example for a working build.json file (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 file build.json, see also the Cordova documentation: iOS Platform Guide

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dgbt
  • 251
  • 1
  • 6
1

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

1

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.

  1. Open the myproject-name.workspace file because cocoapods installed.
  2. Go to Build Settings Tab in xcode.
  3. Scroll very bottom of the build settings tab find Swift Compiler - Language.
  4. Select the Swift version from the Swift Language Version drop down (Ex : Swift 4).

Then Change the workspace setting

  1. Go to Xcode File Menu
  2. Select Workspace Settings
  3. Select Legacy Build System from the Build System drop down
  4. Click Done

And after all try to rebuild with following command in terminal

ionic cordova build ios
KATJ Srinath
  • 950
  • 1
  • 11
  • 18
1

A couple of pitfalls: Preparing the Xcode file.

It’s time to prepare the project to be opened in Xcode. However, Ionic-Cordova doesn’t support the new build system of Xcode. So the project has to be prepared for the legacy build system. Pitfall #2.

Important! Disconnect your iPhone or iPad device connected to the Mac or the following command won’t work!!! Pitfall #3.

ionic cordova build ios --prod --buildFlag='-UseModernBuildSystem=0'

Congratulations! Your MyApp.xcodeproj (etc.) file is ready. You’re almost half way to have an IPA uploaded. Just double click on the Myapp.xcodeproj file or open it through Xcode.

Picture showing Xcode

There are several other pitfalls you will find:

  • It’s a common pitfall #4 to not have the proper privilege set. In particular the rol “Developer” (pitfall #4.1) doesn’t have privileges to push apps to the Store
  • Double check that the “Bundle Identifier” is exactly the one you set in the config.xml file!
  • Xcode exposes a signing bug, pitfall #5, so untick the “Automatically manage signing” and tick again. You will face this bug for sure.

Xcode bugs and Cordova not supporting properly the new building system leads to all these issues. I made a full guide showing how to fix them after lurking hours.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Victor Martinez Calvo
  • 1,717
  • 1
  • 12
  • 11
0

Just try the below command:

ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Manoj Alwis
  • 1,337
  • 11
  • 24