ios - WatchKit:捆绑标识符和 WKAppBundleIdentifer 之间有什么区别?为什么它会导致应用程序组无法工作?

标签 ios objective-c swift watchkit xcode-6.2

我不知道WKAppBundleIdentifier的用途是什么。 WatchKit 扩展的包标识符和 WKAppBundleIdentifer 是否具有相同的 id?当我为它们分配相同的 id com.myProbjectName.watchkitextension 时,iOS 模拟器和 iWatch 模拟器之间共享数据(应用程序组)根本不起作用。但是,如果我将 WKAppBundleIdentifer 更改为 com.myProbjectName.watchkitapp 并保留 WatchKit 的包标识符不变 (com.myProbjectName.watchkitextension)在 iOS 模拟器和 Apple Watch 模拟器之间共享数据是可行的。为什么要这样做?WKAppBundleIdentifier 和包标识符 (CFBundleIdentifier) 之间有什么区别?

最佳答案

CFBundleIdentifier 是 WatchKit 扩展的捆绑标识符,其中包含 WatchKit 应用程序。因此, bundle 标识符对于扩展来说是唯一的,例如 com.some.app.watchkitextension 。

WKAppBundleIdentifier 是捆绑在扩展中的 WatchKit 应用程序的标识符。这就是为什么这些值必须不同的原因,因为 WatchKit 应用程序有自己的捆绑标识符(例如 com.some.app.watchkitapp)。该值应该是WatchKit App的CFBundleIdentifier的值。

这也与配置有关。所有三个部分(iOS 应用程序、WatchKit 扩展和 WatchKit 应用程序)都必须有自己的 bundle 标识符,因此也必须有自己的配置文件。


WKAppBundleIdentifier 实际上是 NSExtension 下 WatchKit App 的 WatchKit 扩展规范的一部分。

<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>WKAppBundleIdentifier</key>
        <string>com.some.app.watchkitapp</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.watchkit</string>
</dict>

关于ios - WatchKit:捆绑标识符和 WKAppBundleIdentifer 之间有什么区别?为什么它会导致应用程序组无法工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29688365/

相关文章:

ios - Swift 属性只有在存在 didSet 时才能正确设置(可以为空)

ios - 根据特定实体获取数据

ios - 如何将多个对象传递给延迟方法?

iOS swift : Custom interactive transition

ios - 在加载 WKWebView 之前尝试获取 CLLocation 坐标

ios - GMSGeocoder iOS SDK - 没有收到反向地理编码的回调

ios - 在 iOS 中画线时命中检测

android - Twilio IP 消息通知 - channel 设置

objective-c - 包标识符应该是小写字母还是驼峰字母?

ios - UIImages 或 UIViews 在 iOS Swift 中不会相互碰撞?