【发布时间】:2017-04-30 18:21:23
【问题描述】:
我在使用 Cordova/Ionic CLI 的 App Extensions 运行和构建 iOS 应用程序时遇到问题。为了使我的应用程序正常工作,我必须添加一些应用程序扩展(CallKit 目录和意图),并且我使用 XCode 完成了它 - 添加了一个新目标并用 Swift 编写了一些东西。当我从 Xcode 进行构建时,一切似乎都在工作,但是 Cordova CLI 似乎无法区分主应用程序和应用程序扩展。
/<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”来解决这些问题,但黑客攻击从来都不是一个好的解决方案。谷歌搜索该主题一无所获,好像没有人尝试将应用扩展添加到 Cordova 应用。
现在可以分两步进行构建: 1) 将文件从 /www 移动到 /platforms/ios/www 2)从Xcode手动运行。 这很烦人。
有谁知道避免这种情况的好方法,而不必破解 Cordova 脚本?
谢谢。
【问题讨论】: