ios WatchKit 扩展包标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30203079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WatchKit Extension bundle identifiers
提问by Tom Coomer
I am trying to build my app but it failed. I am shown the message below.
我正在尝试构建我的应用程序,但失败了。我看到下面的消息。
error: WatchKit Extension doesn't contain any WatchKit apps whose bundle identifiers match "com.domain.appname.watchkitapp". Verify that the value of WKAppBundleIdentifier in your WatchKit Extension's Info.plist matches the value of CFBundleIdentifier in your WatchKit App's Info.plist.
错误:WatchKit 扩展不包含任何捆绑标识符匹配“com.domain.appname.watchkitapp”的 WatchKit 应用。验证 WatchKit 扩展的 Info.plist 中 WKAppBundleIdentifier 的值是否与 WatchKit App 的 Info.plist 中的 CFBundleIdentifier 值匹配。
I have recently changed "com.domain.appname.watchkitapp"
to "com.domain.differentappname.watchkitapp"
.
我最近更改"com.domain.appname.watchkitapp"
为"com.domain.differentappname.watchkitapp"
.
I cannot find where to change this.
我找不到在哪里改变这个。
回答by Dejan Skledar
You have to be careful when changing the bundle identifiers, and here's how they should be set (you need to change each identifier in the Info.plist for the iPhone app, for the Watchkit Extensionand for the Watchkit App):
更改包标识符时必须小心,以下是它们的设置方式(您需要更改 Info.plist 中iPhone 应用程序、Watchkit 扩展程序和Watchkit 应用程序的每个标识符):
iPhone Application Info.plist:
iPhone应用信息.plist:
Set any bundle identifier as you like (the "Bundle identifier" property).
根据需要设置任何捆绑标识符(“捆绑标识符”属性)。
Example:
例子:
Bundle identifier: com.fruitcompany.orange
WatchKit App Info.plist
WatchKit 应用信息.plist
The bundle identifier here mustbe prefixed with the identifier of the iPhone application, like this(example):
这里的 bundle identifier必须以 iPhone 应用程序的标识符为前缀,像这样(示例):
Bundle identifier: com.fruitcompany.orange.watchkit
You also need to change the WKCompanionAppBundleIdentifier
which mustmatch with the iPhone application bundle identifier, like this:
您还需要更改WKCompanionAppBundleIdentifier
which必须与 iPhone 应用程序包标识符匹配,如下所示:
WKCompanionAppBundleIdentifier: com.fruitcompany.orange
Watchkit Extension Info.plist:
Watchkit 扩展信息.plist:
The bundle identifier here mustbe prefixed with the identifier of the iPhone application, like this(example):
这里的 bundle identifier必须以 iPhone 应用程序的标识符为前缀,像这样(示例):
Bundle identifier: com.fruitcompany.orange.watchkit.extension
You also need to set the WKAppBundleIdentifier
under the NSExtension
attribute.
您还需要WKAppBundleIdentifier
在NSExtension
属性下设置。
The WKAppBundleIdentifier
identifier mustmatch with the WatchKit app bundle identifier like this:
该WKAppBundleIdentifier
标识符必须与 WatchKit 应用程序包标识符匹配,如下所示:
WKAppBundleIdentifier: com.fruitcompany.orange.watchkit
回答by AdamJonR
First, let me highlight the excellent answer on this page by @DejanSkledar, as all of the locations noted in the answer are important.
首先,让我强调@DejanSkledar 在此页面上的出色答案,因为答案中指出的所有位置都很重要。
That said, the precise setup in that answer was not sufficient for me. I'd like to supplement this answer and point out that since watchkit 2, there appears to be a hierarchy required as you work from the app, to the watch app, and then finally to the app extension in terms of the bundle id's.
也就是说,该答案中的精确设置对我来说还不够。我想补充这个答案并指出,从 watchkit 2 开始,当您从应用程序工作到手表应用程序,最后到应用程序扩展程序时,就捆绑 ID 而言似乎需要一个层次结构。
Here are the settings in each of their corresponding info.plist files that worked for me after I found edwardmp's answer on a related issue.
以下是在我找到edwardmp 对相关问题的回答后对我有用的每个相应 info.plist 文件中的设置。
iPhone App's Bundle Id: com.domain.yourapp
iPhone 应用程序的捆绑 ID:com.domain.yourapp
Watch App's Bundle Id: com.domain.yourapp.watchkit
Watch App 的 Bundle Id:com.domain.yourapp.watchkit
Watchkit's Extension Bundle Id: com.domain.yourapp.watchkit.extension
Watchkit 的扩展包 ID:com.domain.yourapp.watchkit.extension
As you can see, an iPhone app has a watchkit app, which itself happens to have a watchkit extension, and each of these levels must be reflected in each of their respective bundle id's.
正如你所看到的,一个 iPhone 应用程序有一个 watchkit 应用程序,它本身恰好有一个 watchkit 扩展,并且这些级别中的每一个都必须反映在它们各自的包 ID 中。
Completing the relationships, the watch app must point to the iPhone app to which it belongs using it's (WKCompanionAppBundleIdentifier), and the watch extension must point to the watch app to which it belongs (WKAppBundleIdentifier.)
完成关系后,手表应用程序必须使用它的 (WKCompanionAppBundleIdentifier) 指向它所属的 iPhone 应用程序,并且手表扩展程序必须指向它所属的手表应用程序 (WKAppBundleIdentifier)。
Watch App's WKCompanionAppBundleIdentifier: com.domain.yourapp
Watch App 的 WKCompanionAppBundleIdentifier: com.domain.yourapp
Watch App's Extension WKAppBundleIdentifier: com.domain.yourapp.watchkit
Watch App 的扩展 WKAppBundleIdentifier:com.domain.yourapp.watchkit
Hopefully this saves someone some time, as I had to struggle on this for a few hours :(
希望这可以为某人节省一些时间,因为我不得不为此挣扎了几个小时:(
回答by Nelson Capes
You also may have to change the WKCompanionAppBundleidentifier key in the projects iOS companion app's info p.list to match the WKAppBundleIdentifer key in the watch kit extension info.plist. I found this out when I copied an earlier watch kit project and changed the WKAppBundleIdentifier in the watch kit extension info.plist to match the bundle identifier in the watch kit info.plist and the project still got the same error. You need to go to Finder, locate the iOS companion project info.plist, and double-click on it, then change the WKCompanionAppBundleIdentifer key if necessary. I wasn't able to see this key by looking ant the info.plist in Xcode.
您可能还需要更改项目 iOS 配套应用程序信息 p.list 中的 WKCompanionAppBundleidentifier 键,以匹配手表套件扩展 info.plist 中的 WKAppBundleIdentifier 键。当我复制早期的手表套件项目并更改手表套件扩展 info.plist 中的 WKAppBundleIdentifier 以匹配手表套件 info.plist 中的包标识符时,我发现了这一点,但该项目仍然出现相同的错误。你需要去 Finder,找到 iOS 配套项目 info.plist,双击它,然后根据需要更改 WKCompanionAppBundleIdentifer 键。我无法通过查看 Xcode 中的 info.plist 来看到此键。
回答by Lucas Huang
So, you don't necessarily change something when you just want to run on test devices. But you do need to request two more provisioning profile in order to test the watch app. Those two additional identifiers can be acquired from extension target and watch app target. That's also the same things you need to do when you want to upload the watch app to App Store
因此,当您只想在测试设备上运行时,您不一定要更改某些内容。但是您确实需要请求另外两个配置文件才能测试手表应用程序。这两个额外的标识符可以从扩展目标和手表应用目标中获取。当您想将手表应用程序上传到App Store时,这也是您需要做的事情