繁体   English   中英

WatchKit 应用程序无法编译:“错误:WatchKit 扩展不包含任何 WatchKit 应用程序”

[英]WatchKit App won't compile: "error: WatchKit Extension doesn't contain any WatchKit apps"

有几个关于这个问题的帖子,但没有一个建议的解决方案适用于我的情况。 我正在尝试按照 Apple 提供的说明将 WatchKit 集成到一个简单的示例应用程序中(我现在已经尝试了几个)。 当我编译时,我收到以下错误消息:

“错误:WatchKit 扩展不包含任何 WatchKit 应用程序。验证 WatchKit 应用程序的 Info.plist 中 WKWatchKitApp 的值是否设置为 YES。”

我已经成功地编译并运行了 Apple Watch“目录”示例,所以我知道从 iPhone 到 Watch 的角度来看事情都在工作。 当我尝试与现有应用程序集成时,似乎有些不对劲。 我已经看到了关于这个主题的帖子(例如WatchKit 应用程序不会在模拟器上运行),但在我的情况下没有任何修复工作; 捆绑 ID 似乎都是正确的。 注意我正在尝试在 iPhone 6 上而不是在模拟器上编译和运行。 有什么建议?

当我更改主 iOS 应用程序的包 ID 时,我发生了此错误。 这是我在项目浏览器中所做的

  1. 在 WatchApp --> plist 下

    WKCompanionAppBundleIdentifier ==> Give the id of the iOS App (com.xxxx.appname)

  2. 在 WatchApp Extension --> plist NSExtension-->NSExtensionAttributes-->WKAppBundleIdentifier ==> Give the id of your watchkit app (eg: com.xxxx.appname.watchkitapp)

这为我修复了错误。

我在XCode Version 10.2 (10E125)上遇到了这个问题,我意识到当我更改 WatchkitApp 捆绑标识符时,watchkitapp 扩展中的一个键没有改变并保持为旧捆绑标识符。

plist 的路径:/Users/.../YourXcodeProjectFolder/Project/YourWatchkitExtensionFolder/info.plist

问题发生在这里:

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>WKAppBundleIdentifier</key>
        <string>com.applecode.water.watchkit</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.watchkit</string>
</dict>

关键的WKAppBundleIdentifier成为问题,所以我自己改变了它。

我在 Xcode 8.2.1 版上注意到了这一点。 这是我修复它的方法。

转到“WatchKit App”-> 构建设置-> 包装-> 产品名称

将其更改为与当前字符串不同的任何字符串。 同意这是一个奇怪的解决方案,如下面的链接所称。

来源: https : //blogofpuneet.wordpress.com/2015/05/02/xcode-build-error-watchkit-extension-doesnt-contain-any-watchkit-apps-verify-that-the-value-of-wkwatchkitapp- in-your-watchkit-apps-info-plist-is-set-to-yes/

此错误的主要原因,

1 watchkit 扩展 plist 文件中的手表应用程序包 ID 不正确。

  1. watchkit 扩展目标中缺少 watchapp.app 的依赖。

带有目录示例的 Apple 文档可能会有所帮助https://developer.apple.com/library/ios/technotes/tn2410/_index.html

以下设置对我有用

  • 在主应用程序 Info.plist 中

捆绑标识符:com.domain.WatchKit-table

  • 在 Watchkit App Info.plist 中

WKCompanionAppBundleIdentifier:com.domain.WatchKit-table

捆绑标识符:com.domain.WatchKit-table。 watchkitapp

  • WatchKit 扩展信息.plist

NSExtension>NSExtensionAttributes>WKAppBundleIdentifier: com.domain.WatchKit-table.watchkitapp

捆绑标识符:com.domain.WatchKit-table。 watchkitapp.watchkittextension

注意:我的 bundle id 有 * 作为第三个组件。 WatchKit-table 是我的项目名称

更改内部版本号后,我在 xcode 10.0 中注意到了这一点。

清理构建文件夹,关闭 xcode,然后重新打开对我有用。

就我而言,我在构建扩展库时遇到了问题。 事实上,它不是构建的,我有两个错误: 1. 来自链接器关于缺少扩展库。 2. 从 Xcode 关于“缺少” NSExtensionPointIdentifier 键。

修复链接错误也修复了此消息。

我正在使用 Xamarin 和 Visual Studio(在 PC 上)。 我遇到了这个问题,但上述修复均无效。 然而,与 XCode 修复非常相似,结果证明重新启动 Visual Studio 就是答案。 /叹

暂无
暂无

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

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