我在使用Cordova/Ionic CLI运行和构建iOS应用程序时遇到了问题,这些问题与App扩展有关。为了使我的应用程序正常工作,我不得不添加一些App扩展(CallKit Directory和Intents),我使用XCode添加了一个新目标并编写了一些Swift代码。当我从Xcode进行构建时,似乎一切都正常,但是Cordova CLI似乎无法区分主应用程序和App扩展。
/<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)
看起来脚本在构建扩展时试图使用主应用程序的桥接头文件,而显然是用Swift编写的。在Xcode中,我为这两个目标设置了“不安装Objective-C兼容头文件”,但Cordova CLI并不关心。可能,使用Objective-C重新编写扩展可以解决问题,但是我没有更多时间尝试我不擅长的语言。
以前我遇到了与扩展相关的其他构建问题,通过向Cordova lib文件添加一些“ifs”进行了修复,但是黑客永远不是一个好的解决方案。谷歌这个话题没有结果,似乎没有人尝试将App Extension添加到Cordova应用程序中。
现在可以通过以下两个步骤进行构建: 1)将文件从/ www移动到/平台/ ios / www 2)手动运行Xcode。 那很烦人。
有人知道一种不必黑客Cordova脚本就能避免这种情况的好方法吗?
谢谢。