我不知道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/