Why won't app groups work inside my WatchKit extension?

只愿长相守 提交于 2019-11-29 01:23:05

I had the similar problem. What I noticed, that my WatchKit Extension and WatchKit App had equal bundle identifiers. I changed bundle id of my WatchKit App. Also I didn't forgot to change NSExtensionAttributes/WKAppBundleIdentifier in the info.plist of Extension to match that id. Now everything works. I hope this will help you!

Shortly: Bundle identifiers of WatchKit App and Extension should be different!

BalestraPatrick

Did you try to read the same key from the iPhone app?

I believe the problem is that you didn't activate the App Group entitlement in your WatchKit extension.

  1. Select your WatchKit Extension under your project settings.

  2. Select Capabilities tab under WatchKit Extension and look for App Groups and turn it on.

  3. Select the same App Group identifier your created before (it should appear automatically and just check it).

Here is what did the trick for me. Apparently Xcode automatically created a new Entitlements file for the new Extension (probably after I set it up from "Capabilities" but unfortunately the value of the array was missing...

In the app Entitlements:

In the Extension Entitlements the value was missing from the array:

Also it's important to make sure that the group appears in the "Capability" tab for both targets (app and Extension) and that all 3 checkmarks are green, see example:

App Target

Extension Target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!