简体   繁体   English

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

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

There are several posts on this issue but none of the proposed solutions work in my case.有几个关于这个问题的帖子,但没有一个建议的解决方案适用于我的情况。 I am trying to integrate the WatchKit into a simple, sample app (I've tried a couple now) by following the instructions provided by Apple.我正在尝试按照 Apple 提供的说明将 WatchKit 集成到一个简单的示例应用程序中(我现在已经尝试了几个)。 When I compile I get the following error message:当我编译时,我收到以下错误消息:

"error: WatchKit Extension doesn't contain any WatchKit apps. Verify that the value of WKWatchKitApp in your WatchKit App's Info.plist is set to YES." “错误:WatchKit 扩展不包含任何 WatchKit 应用程序。验证 WatchKit 应用程序的 Info.plist 中 WKWatchKitApp 的值是否设置为 YES。”

I have successfully compiled and run the Apple Watch "Catalog" example so I know things are working from an iPhone to Watch perspective.我已经成功地编译并运行了 Apple Watch“目录”示例,所以我知道从 iPhone 到 Watch 的角度来看事情都在工作。 It seems like something is not right when I try to integrate with an existing app.当我尝试与现有应用程序集成时,似乎有些不对劲。 I have seen the posts here on this topic (eg WatchKit app wont run on simulator ) but none of the fixes work in my case;我已经看到了关于这个主题的帖子(例如WatchKit 应用程序不会在模拟器上运行),但在我的情况下没有任何修复工作; the bundle IDs all appear to be correct.捆绑 ID 似乎都是正确的。 Note I am trying to compile and run on an iPhone 6 not on the simulator.注意我正在尝试在 iPhone 6 上而不是在模拟器上编译和运行。 Any suggestions?有什么建议?

This error occurred for me when I changed the bundle id of my main iOS App.当我更改主 iOS 应用程序的包 ID 时,我发生了此错误。 This is what I did in the project explorer这是我在项目浏览器中所做的

  1. Under WatchApp --> plist在 WatchApp --> plist 下

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

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

this fixed the error for me.这为我修复了错误。

I ran into this problem on XCode Version 10.2 (10E125) , i realizes when i changed WatchkitApp Bundle identifier one key in watchkitapp extension did not changed and stayed as old bundle identifier.我在XCode Version 10.2 (10E125)上遇到了这个问题,我意识到当我更改 WatchkitApp 捆绑标识符时,watchkitapp 扩展中的一个键没有改变并保持为旧捆绑标识符。

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

the problem occurd here:问题发生在这里:

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

the key WKAppBundleIdentifier was made the problem, so i changed it by my self.关键的WKAppBundleIdentifier成为问题,所以我自己改变了它。

I noticed this on Xcode version 8.2.1.我在 Xcode 8.2.1 版上注意到了这一点。 Here is how I fixed it.这是我修复它的方法。

Go to "WatchKit App" -> Build Settings -> Packaging -> Product Name转到“WatchKit App”-> 构建设置-> 包装-> 产品名称

Change it so any string different from current string.将其更改为与当前字符串不同的任何字符串。 Agreed that it is a bizarre solution as called in the link below.同意这是一个奇怪的解决方案,如下面的链接所称。

Source: 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/来源: 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/

Main reasons to this error,此错误的主要原因,

1 Incorrect watch app bundle id in watchkit extension plist file. 1 watchkit 扩展 plist 文件中的手表应用程序包 ID 不正确。

  1. Missing dependancy of watchapp.app in watchkit extension target. watchkit 扩展目标中缺少 watchapp.app 的依赖。

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

Below settings worked for me以下设置对我有用

  • In Main App Info.plist在主应用程序 Info.plist 中

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

  • In Watchkit App Info.plist在 Watchkit App Info.plist 中

WKCompanionAppBundleIdentifier:com.domain.WatchKit-table WKCompanionAppBundleIdentifier:com.domain.WatchKit-table

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

  • WatchKit Extension Info.plist WatchKit 扩展信息.plist

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

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

Note: my bundle id has * as the third component.注意:我的 bundle id 有 * 作为第三个组件。 WatchKit-table is my project name WatchKit-table 是我的项目名称

I noticed this with xcode 10.0 after changing the build number.更改内部版本号后,我在 xcode 10.0 中注意到了这一点。

Cleaning the build folder, closing xcode, and re-opening worked for me.清理构建文件夹,关闭 xcode,然后重新打开对我有用。

In my case I had problem with building of the extension library.就我而言,我在构建扩展库时遇到了问题。 In fact it was not built and I had two errors: 1. From linker about absense of the extension library.事实上,它不是构建的,我有两个错误: 1. 来自链接器关于缺少扩展库。 2. From Xcode about "missing" NSExtensionPointIdentifier key. 2. 从 Xcode 关于“缺少” NSExtensionPointIdentifier 键。

Fix of linking error also fixed this message.修复链接错误也修复了此消息。

I'm using Xamarin and Visual Studio (on the PC).我正在使用 Xamarin 和 Visual Studio(在 PC 上)。 I had this issue, but none of the fixes above worked.我遇到了这个问题,但上述修复均无效。 Much like the XCode fix, however, restarting Visual Studio turned out to be the answer.然而,与 XCode 修复非常相似,结果证明重新启动 Visual Studio 就是答案。 /sigh /叹

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

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