TheBen
TheBen

Reputation: 3522

Cordova build iOS error: archive not found at path 'path/to/myApp.xcarchive"

I have been struggling to get Cordova to work and run on my iPhone. I follow the commands below but see error below at build:

cordova create myApp org.apache.cordova.myApp myApp
cd myApp
cordova platform add ios 
cordova build ios

I get the error below:

Building project: /Users/ben/Desktop/myTest/platforms/ios/myTest.xcworkspace
    Configuration: Debug
    Platform: device
User defaults from command line:
    IDEArchivePathOverride = /Users/ben/Desktop/myTest/platforms/ios/myTest.xcarchive

Build settings from command line:
    CONFIGURATION_BUILD_DIR = /Users/ben/Desktop/myTest/platforms/ios/build/device
    SHARED_PRECOMPS_DIR = /Users/ben/Desktop/myTest/platforms/ios/build/sharedpch

Build settings from configuration file '/Users/ben/Desktop/myTest/platforms/ios/cordova/build-debug.xcconfig':
    CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
    CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
    CODE_SIGN_IDENTITY = iPhone Developer
    ENABLE_BITCODE = NO
    GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
    HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
    OTHER_LDFLAGS = -ObjC
    SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h

error: archive not found at path '/Users/ben/Desktop/myTest/platforms/ios/myTest.xcarchive'
** EXPORT FAILED **

(node:4984) UnhandledPromiseRejectionWarning: Error code 65 for command: xcodebuild with args: -exportArchive,-archivePath,myTest.xcarchive,-exportOptionsPlist,/Users/ben/Desktop/myTest/platforms/ios/exportOptions.plist,-exportPath,/Users/ben/Desktop/myTest/platforms/ios/build/device
(node:4984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4984) [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 have tried removing and adding platforms. Also, uninstalling stuff as well.

I'm on macOS High Sierra and Xcode 10.

Upvotes: 56

Views: 31911

Answers (5)

Jelmer Jellema
Jelmer Jellema

Reputation: 1126

This also happens when you run cordova ios build --prod with a device connected to your mac. Unplug and try again.

Upvotes: 0

nharrer
nharrer

Reputation: 636

Cordova iOS supports the new build system since 5.0.0 (see release notes).

So update your package.json to "cordova-ios": "5.0.0" (or later) and call npm install.

Note, that I had to clean out everything (delete the directories platforms, plugins, www) afterwards in order for it to work.

Upvotes: 4

Stefan Rein
Stefan Rein

Reputation: 9062

If you don't want to set it in the build flag all the time, open your MyApp.xcworkspace and go to:

Sidenote: Yes you need to do this all the time by adding the ios platform in cordova. (e.g. you removed and added again the ios platform)

File > Workspace settings > Choose for Build System: Legacy Build System

enter image description here

Upvotes: 3

jessica
jessica

Reputation: 3141

Neither solution - --buildFlag="-UseModernBuildSystem=0" or setting the Legacy Build System worked for me.

For some reason, the error only goes away if I am sure to unplug my iPad or iPhone from usb on my computer before running the cordova build command.

Maybe something quirky about my configuration, but I thought I'd share in case it helps anyone else.

Upvotes: 47

Samuel Hsieh
Samuel Hsieh

Reputation: 1546

There is a work around here.

If you're building on the command-line, you can specify --buildFlag="-UseModernBuildSystem=0":

# Cordova CLI
cordova run ios --buildFlag='-UseModernBuildSystem=0'
cordova build ios --buildFlag='-UseModernBuildSystem=0'

# Ionic CLI
ionic cordova run ios -- --buildFlag="-UseModernBuildSystem=0"
ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"

If you're building with a build.json config file, you can add the following under the iOS release or debug config:

"buildFlag": [
  "-UseModernBuildSystem=0"
]

If you are opening the project in the Xcode IDE, you need to change the build system in Workspace Settings to "Legacy Build System"

Upvotes: 143

Related Questions