简体   繁体   English

Ionic / Cordova iOS应用程序构建错误的应用程序扩展名 - ** ARCHIVE FAILED **

[英]Ionic/Cordova iOS app build error for app with extension - ** ARCHIVE FAILED **

I am experiencing an issue with running and building an iOS application with App Extensions with Cordova/Ionic CLI. 我遇到了使用Cordova / Ionic CLI的App Extensions运行和构建iOS应用程序的问题。 In order to make my application work properly, I had to add a couple of App Extensions (CallKit Directory and Intents), and I did it using XCode - added a new Target and wrote some stuff in Swift. 为了使我的应用程序正常工作,我不得不添加几个App Extensions(CallKit Directory和Intents),我使用XCode做了 - 添加了一个新的Target并在Swift中写了一些东西。 Everything seems to be working when I make a build from Xcode, however Cordova CLI does not seem to be able to differentiate the main app form App Extension. 当我从Xcode进行构建时,一切似乎都在工作,但Cordova CLI似乎无法区分主应用程序表单App Extension。

/<Path_To_The_App>/Bridging-Header.h:28:9: note: in file included from /<Path_To_The_App>/Bridging-Header.h:28:
#import "CallKit-Bridging-Header.h"
        ^
/<Path_To_The_App>/Plugins/my.custom.callkit_plugin_written_in_swift/CallKit-Bridging-Header.h:1:9: error: 'Cordova/CDV.h' file not found
#import <Cordova/CDV.h>
        ^
<unknown>:0: error: failed to import bridging header '/<Path_To_The_App>/Bridging-Header.h'


** ARCHIVE FAILED **

The following build commands failed:
        CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
        CompileSwift normal arm64 /My Call Directory Extension/CallDirectoryHandler.swift
        CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
        CompileSwift normal arm64 /My Intent Extension/IntentHandler.swift
(4 failures)

It seems like the script is attempting to use bridging header files from the main app while building an Extension, which is obviously written in Swift. 似乎脚本试图在构建扩展时使用来自主应用程序的桥接头文件,这显然是用Swift编写的。 In Xcode I set "Install Objective-C compatibility Header" to "No" for these two targets, but Cordova CLI does not care. 在Xcode中,我为这两个目标设置了“安装Objective-C兼容性标题”为“否”,但Cordova CLI并不关心。 Probably, re-writing the Extensions in Objective-C would solve the issue, but I don't have more time to experiment with a language I'm not good with. 也许,在Objective-C中重写Extensions可以解决这个问题,但我没有更多的时间来尝试一种我不擅长的语言。

I used to have another build issues related to the extension, which were fixed by adding some "ifs" to Cordova lib files, but hacking is never a good solution. 我曾经有过与扩展相关的另一个构建问题,这些问题是通过向Cordova lib文件中添加一些“ifs”来修复的,但是黑客攻击从来都不是一个好的解决方案。 Googling the topic results in nothing as though nobody has ever tried to add an App Extension to a Cordova app. 谷歌搜索主题没有任何结果,好像没有人试图将应用程序扩展添加到Cordova应用程序。

Now build can be made in two steps: 1) moving files from /www to /platforms/ios/www 2) manually running the from Xcode. 现在可以分两步构建:1)将文件从/ www移动到/ platforms / ios / www 2)手动运行Xcode。 That's annoying. 那很烦人。

Does anybody know a good way to avoid this without having to hack Cordova scripts? 有没有人知道避免这种情况的好方法而不必破解Cordova脚本?

Thanks. 谢谢。

I spent some time learning run-command output and saw that the build process is initiated with Xcode command line tools: 我花了一些时间学习运行命令输出,并看到构建过程是使用Xcode命令行工具启动的:

xcodebuild -xcconfig <Path To My app>/platforms/ios/cordova/build-debug.xcconfig -workspace "<My App Name>.xcworkspace" -scheme "<My App Name>" -configuration "Debug" -destination generic/platform=iOS -archivePath "<My App Name>.xcarchive" archive CONFIGURATION_BUILD_DIR=<Path To My app>/platforms/ios/build/device SHARED_PRECOMPS_DIR=<Path To My app>/platforms/ios/build/sharedpch

Documentation to this command says: 该命令的文档说:

-xcconfig filename -xcconfig文件名

Load the build settings defined in filename when building all targets. 在构建所有目标时加载在filename中定义的构建设置。 These settings will override all other settings, including settings passed individually on the command line. 这些设置将覆盖所有其他设置,包括在命令行上单独传递的设置。

build-debug.xcconfig imports build.xcconfig which for some reason had "SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h". build-debug.xcconfig导入build.xcconfig,由于某种原因,它有“SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/ $(PROJECT_NAME)/Bridging-Header.h”。 So apparently, it overrode bridging header for all Targets despite for .xcodeproj settings. 显然,尽管有.xcodeproj设置,但它覆盖了所有目标的桥接标题。

After commenting out this line in platforms/ios/cordova/build.xcconfig the build process runs as expected. 在platforms / ios / cordova / build.xcconfig中注释掉这一行后,构建过程按预期运行。

It turned out to be that Cordova build command was using a wrong Xcode version in my case. 事实证明,在我的案例中,Cordova构建命令使用了错误的Xcode版本。

I'm using Swift 3 and have two Xcode installed in my computer: Xcode 7.3.1 and Xcode 8.3.3. 我正在使用Swift 3并在我的计算机上安装了两个Xcode:Xcode 7.3.1和Xcode 8.3.3。 I could build my cordova app using Xcode 8.3.3 App with no problem, but when executing command cordova build ios I got the same errors as you. 我可以使用Xcode 8.3.3应用程序构建我的cordova应用程序没有问题,但是当执行命令cordova build ios我得到了与你相同的错误。 Here are the steps I did: 以下是我做的步骤:

  1. $ xcodebuild -version . $ xcodebuild -version This step gives you the version of Xcode cordova is using when building. 此步骤为您提供构建时使用的Xcode cordova版本。 In my case it returned Xcode 7.3.1 . 就我而言,它返回了Xcode 7.3.1

  2. $ sudo xcode-select -switch [PathToYourXcodeFolder] . $ sudo xcode-select -switch [PathToYourXcodeFolder] Switch to the Xcode version you would like to use. 切换到您要使用的Xcode版本。

You may want to check the current Xcode path: $ xcode-select -print-path . 您可能想要检查当前的Xcode路径: $ xcode-select -print-path

After I switched to Xcode 8.3.3 I could run cordova build ios with no errors. 在我切换到Xcode 8.3.3后,我可以运行cordova build ios而没有错误。 Hope this helps those who have the same problem as me. 希望这能帮助那些和我有同样问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM