在我的应用中,
我需要找到我的手机是否与苹果手表配对,并获得有关配对手表的一些信息,如名称.我试过阅读文档,但我似乎找不到任何特定于我的用例的东西.
任何帮助表示赞赏.
从昨天起,Xcode在尝试在我的iPhone上运行我的WatchKit应用程序时做了蠢事.它给了我错误:
嵌入式二进制验证实用程序错误
错误:警告:是目录
它不是很有用,似乎它抱怨为我的Watchkit扩展目标配置配置文件.我想我按照这个答案正确设置了它.
这就是我设置个人资料的方式.三个App ID和六个配置文件(三个用于开发,三个用于分发).
主要应用:

WatchKit扩展:

WatchKit Watch App:

每当我尝试在Xcode 7 beta 4中安装watchOS 2应用程序时,我在iOS上收到AlertView弹出错误:
无法安装Watch App
TestApp安装在您的iPhone上,但Apple Watch的TestApp应用程序目前无法使用.
我也试过通过Apple Watch iOS应用程序安装watchOS应用程序,但我得到了同样的错误.当我尝试运行watchOS目标时,我得到了这个:
启动'TestApp WatchKit App Extension'时出错
安装错误.查看iPhone控制台了解更多详情."
我重新安装了Xcode,删除并重新添加了所有模拟器,重置模拟器内容和设置......其中没有一个有效.我还创建了一个全新的项目.这发生在模拟器和运行iOS 9 beta 4和watchOS 2 beta 4的物理设备/手表上.
有没有人想出一个修复或解决方法?
谢谢!
我知道StackOverflow上有几个问题有类似的内容,但似乎我仍然无法得到这个问题的解决方案.
我有:
关键字"AppIcon"不会显示在我的.plist文件中的任何位置.我已经构建了清理应用程序并重新启动应用程序.我有点不确定是什么问题.当我在设备的Watch + IOS目标上构建它时,我收到此错误.
奇怪的是,如果我删除了xcassets中的所有图像文件,Xcode编译得很好,告诉我问题在于我的图像.
如果您有任何想法,请告诉我.
我正在为苹果手表构建一个小应用程序.我里面有一个Group和一个Label.我想要做的是:
我的代码看起来基本上像这样:
group.setBackgroundImageNamed("show_back-");
group.startAnimatingWithImagesInRange(NSMakeRange(0, 39), duration: 1.5, repeatCount: 1);
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1.5 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) { () -> Void in
self.animateWithDuration(1) { () -> Void in
self.label.setAlpha(1)
};
};
Run Code Online (Sandbox Code Playgroud)
问题是,第一次触发此序列时,图像动画的运行速度似乎慢于1.5秒,因为标签在图像停止变化之前开始淡入淡出.如果在应用程序运行时再次触发此操作,则一切都按预期工作.我想它与图像预加载或其他东西有关.
我怎样才能让它始终如一?我无法在图像序列动画上找到任何类型的回调来订阅.
编辑 我注意到的另一个问题:我有另一个案例,当bg从dispatch_after块动画时,当我通过点击表冠离开应用程序并通过双击它返回时,或者没有触发dispatch_after块,或者背景动画在第一次调用时没有正确呈现(我想第二次,因为我尝试在调度块中添加一个断点,并且每次测试时都会触发).我正在运行watchOS2,所以它可能与操作系统目前处于测试状态有关吗?
我目前有一个项目有3个不同版本的同一个应用程序(不同的品牌等),这工作得很好.从那时起我就添加了3个新Apple Watch目标(每个应用程序"版本"1个),其中2个引用"主"Apple Watch目标中的文件.
一切正常,只要我记得更改每个故事板视图的模块引用,以便它映射到相应的watchkit扩展目标中的正确接口控制器.
但是,记住每次我需要运行/构建应用程序版本/目标时切换它是一个痛苦,而不是一个真正的长期解决方案.
我创建了以下命令,我想在正确的时间运行它,以便在编译之前更改storyboard引用.
perl -pi.bak -e 's/customModule=\"(.*?)\">/customModule=\"watchMyTarget_Extension\">/g' ${SRCROOT}/watch/Base.lproj/Interface.storyboard
Run Code Online (Sandbox Code Playgroud)
我还得出结论,我可能希望在应用程序编译后重置更改,因为我不想让git抱怨文件更改.这就是上述脚本创建.bak文件的原因.所以在完成编译并在设备上打包/运行之后,我想运行
mv ${SRCROOT}/watch/Base.lproj/Interface.storyboard.bak ${SRCROOT}/watch/Base.lproj/Interface.storyboard
Run Code Online (Sandbox Code Playgroud)
我已经尝试将脚本放在目标(watchTarget,而不是appTarget)构建方案中,Build->Pre/Post Actions这似乎没有任何效果.我尝试将它放在Run->Pre/Post Actions一定程度上工作,但似乎在将应用程序推送到模拟器之前启动了帖子操作,从而导致应用程序崩溃("无法运行查看设备日志"或类似的东西).
那么我到底需要将这些脚本放在构建过程中的正确时间运行?
处理Apple Watch通知: -如果我在通知界面中添加按钮(来自对象Lib),那么错误是:
通知界面中不支持按钮
PushNotificationPayload.apns有WatchKit Simulator Actions这样的:
"WatchKit Simulator Actions":
[
{
"title": "View",
"identifier": "firstButtonAction"
}
],
Run Code Online (Sandbox Code Playgroud)
和模拟器向我显示这个

现在我的问题是,从服务器View发送时如何处理此按钮PushNotification,
如果aps文件包含操作按钮是Apple Watch的唯一选项,
如何使用指定的密钥从通知字典中的服务器发送它?
如何更改动作按钮BG颜色?
会不会有人请给我的样本aps文件,其中包括ActionButton对设备the Apple Watch不为Simulator
我只是通过将WatchKit Simulator ActionsKey 更改为Key来测试,WatchKit Actions但它没有显示Action Button.
正如答案中的@vivekDas所建议的,我通过替换aps为:
"alert" : {
"body" : "Acme message received from Johnny Appleseed",
"action-loc-key" : "VIEW",
"action" : [
{
"id" : "buttonTapped",
"title" : …Run Code Online (Sandbox Code Playgroud) 我们知道Apple Watch有两种屏幕尺寸:38mm和42mm.本WKInterfaceDevice类提供一个名为读取的特性screenBounds.我写了一个扩展名WKInterfaceDevice,尝试添加一种方法来检测当前的设备类型.
import WatchKit
enum WatchResolution {
case Watch38mm, Watch42mm
}
extension WKInterfaceDevice {
class func currentResolution() -> WatchResolution {
let watch38mmRect = CGRectMake(0.0, 0.0, 136.0, 170.0)
let watch42mmRect = CGRectMake(0.0, 0.0, 156.0, 195.0)
let currentBounds = WKInterfaceDevice.currentDevice().screenBounds
if CGRectEqualToRect(currentBounds, watch38mmRect) {
return WatchResolution.Watch38mm
} else {
return WatchResolution.Watch42mm
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是检测Apple Watch尺寸的正确方法吗?我在Apple文档中缺少另一种方法吗?
在我们的iOS应用程序中,我们使用共享容器在我们的主要iOS应用程序及其扩展(特别是WatchKit扩展)之间使用[NSFileManager containerURLForSecurityApplicationGroupIdentifier:]方法共享文件.出于调试目的,我们需要访问此共享容器的内容,因此我们尝试使用Xcode中的Devices窗口导出整个App容器:

但是,共享存储不包含在容器中,可能是因为它位于设备本身的不同路径中.
问题是如果可能的话,我们如何获得共享容器?
执行时
template.headerTextProvider = CLKSimpleTextProvider(text: header)
Run Code Online (Sandbox Code Playgroud)
在ComplicationController,我收到了大量类似的错误消息,到目前为止我还没有找到解决方法:
objc[4499]: Class SPProtoAudioFilePlayerStatus is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/Frameworks/WatchKit.framework/WatchKit and /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/PrivateFrameworks/SockPuppetGizmo.framework/SockPuppetGizmo. One of the two will be used. Which one is undefined.
objc[4499]: Class SPProtoSerializer is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/Frameworks/WatchKit.framework/WatchKit and /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/PrivateFrameworks/SockPuppetGizmo.framework/SockPuppetGizmo. One of the two will be used. Which one is undefined.
objc[4499]: Class SPProtoAudioFilePlayerMessage is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/Frameworks/WatchKit.framework/WatchKit and /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/PrivateFrameworks/SockPuppetGizmo.framework/SockPuppetGizmo. One of the two will be used. Which one is undefined.
objc[4499]: Class SPProtoCacheSyncData is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/Frameworks/WatchKit.framework/WatchKit and …Run Code Online (Sandbox Code Playgroud) apple-watch watchkit clockkit watchos-2 apple-watch-complication