Cordova 构建 iOS 错误:在路径“path/to/myApp.xcarchive”中找不到存档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52281848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:47:18  来源:igfitidea点击:

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

ioscordovaphonegapcordova-3

提问by TheeBen

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 在我的 iPhone 上工作和运行。我遵循以下命令,但在构建时看到以下错误:

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.

我使用的是 macOS High Sierra 和 Xcode 10。

回答by Samuel Hsieh

There is a work around here.

有一个变通这里

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

如果您在命令行上构建,则可以指定 --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:

如果您使用 build.json 配置文件进行构建,则可以在 iOS 版本或调试配置下添加以下内容:

"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"

如果您在 Xcode IDE 中打开项目,则需要将 Workspace Settings 中的构建系统更改为“Legacy Build System”

回答by jessica

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

解决方案 ---buildFlag="-UseModernBuildSystem=0"或设置 Legacy Build System都不适合我。

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.

出于某种原因,只有在运行cordova build命令之前我确定从我的计算机上的USB上拔下我的iPad或iPhone时,错误才会消失。

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

也许我的配置有些古怪,但我想我会分享,以防它对其他人有帮助。

回答by nharrer

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

Cordova iOS 支持自 5.0.0 以来的新构建系统(请参阅发行说明)。

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

因此,将您的 package.json 更新为"cordova-ios": "5.0.0"(或更高版本)并调用npm install.

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

请注意,之后我必须清除所有内容(删除目录平台、插件、www)才能使其正常工作。

回答by Stefan Rein

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

如果您不想一直在构建标志中设置它,请打开您的MyApp.xcworkspace并转到:

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)

旁注:是的,您需要始终通过在cordova 中添加ios 平台来执行此操作。(例如,您删除并再次添加了 ios 平台)

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

文件 > 工作区设置 > 选择构建系统:传统构建系统

enter image description here

在此处输入图片说明

回答by Jelmer Jellema

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

当您cordova ios build --prod使用连接到 Mac 的设备运行时,也会发生这种情况。拔掉插头再试一次。