为什么应用程序组不会在我的WatchKit扩展程序中运行? [英] Why won't app groups work inside my WatchKit extension?

查看:91
本文介绍了为什么应用程序组不会在我的WatchKit扩展程序中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了关于在主机应用和应用扩展程序之间共享NSUserDefaults数据的所有其他帖子,但我仍然无法正常工作。以下是我所做的一切:

I've seen all the other posts of SO about sharing NSUserDefaults data between host apps and app extensions, but mine still doesn't work. Here's everything I've done:


  1. 在Xcode的功能标签上为扩展程序和主机应用启用应用程序组。

  2. 将组名设置为group.com.mycompany.foo,并确认扩展名和主机应用已添加到组中。

  3. 确认存在权利文件将com.apple.security.application-groups键设置为我的应用程序组名称。 (对于它的价值,我也使用扩展和主机应用程序之间的共享钥匙串功能,这是有效的 - 所以我不认为这是权利问题)

  4. 重新生成所有配置文件。事实上,我甚至撤销了我的所有证书,并在设置应用程序组后重新生成了所有配置文件。

  1. Enable App Groups on Xcode's "Capabilities" tab for the extension and host app.
  2. Set the group name to "group.com.mycompany.foo" and confirmed the extension and host app are added to the group.
  3. Confirmed an entitlements file exists for both with the "com.apple.security.application-groups" key set to my app group name. (For what it's worth, I'm also using the shared keychain capabilities between extension and host app and that is working -- so I don't believe this is an issue with entitlements)
  4. Regenerated all provisioning profiles. In fact, I even revoked all my certificates and regenerated all profiles fresh after setting up the app group.

在所有这些之后,此代码仍无效:

And after all of that, this code still doesn't work:

// in the host app
NSUserDefaults *testDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.mycompany.foo"];
[testDefaults setObject:@"TEST" forKey:@"foo"];
[testDefaults synchronize];

然后:

// in the extension
NSUserDefaults *testDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.mycompany.foo"];
NSLog(@"%@", [testDefaults objectForKey:@"foo"]);

导致:

(null)

当我查看Xcode首选项时,我注意到这些图标,其中没有一个具有应用程序组图标:

When I look in Xcode preferences, I notice these icons, none of which have the "App Group" icon:

但正如我之前所说,我在设置应用程序组后清除了我的钥匙串,证书和配置文件。因此,如果这实际上是问题,如何将权利添加到配置文件?

But as I stated before, I went as far as clearing out my keychain, certs, and provisioning profiles after setting up the app group. So if this is in fact the problem, how do I add the entitlement to the profiles?

我缺少什么?我是新鲜的想法。

What am I missing? I'm fresh out of ideas.

帮助?

编辑:访问权限小组正在我的今天和我的工作Safari扩展,不在WatchKit扩展中。我不明白为什么,并且所有构建设置似乎都以相同的方式配置。

EDIT: Access groups are working in my Today & Safari extension, just not in the WatchKit extension. I have no idea why, and all the build settings appear to be configured the same way.

编辑2 :对于那些坚持我的能力的人设置不正确,这是一个截图:

EDIT 2: For those insisting that my capabilities aren't setup properly, here's a screenshot:

推荐答案

我遇到了类似的问题。我注意到,我的WatchKit扩展和WatchKit应用程序具有相同的包标识符。我更改了WatchKit App的bundle id。此外,我没有忘记在Extension的info.plist中更改NSExtensionAttributes / WKAppBundleIdentifier以匹配该ID。现在一切正常。我希望这会对你有所帮助!

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!

很快: WatchKit App和Extension的捆绑标识符应该不同!

这篇关于为什么应用程序组不会在我的WatchKit扩展程序中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆