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