watchkit

Implementing Core Data to watchOS 2.0

拜拜、爱过 提交于 2019-12-12 10:23:25
问题 I am pretty new to WatchKit, and I am trying to add Core Data to my WatchKit extension. So far I have created a Data Model in my WatchKit extension, but I am stuck on implementing the rest of the Core Data stack. Is the process of creating Core Data models and initializing the Core Data stack identical to iOS or are there any differences I should be aware of? Also, do I initialize the Core Data stack in the ExtensionDelgate.swift or should I initialize it somewhere else? 回答1: The process of

Watchkit - shared code - framework, app extension, app groups, add target or just copy files?

荒凉一梦 提交于 2019-12-12 06:16:35
问题 I have an existing app and I'm adding a Watch app to it. I have several .swift files with code from my main app that I'll need to use for the watchkit app (functions and some constants, etc). I'm confused by the options for sharing this code - how do I know which one to try and use? Create an app group, my own framework, app extension? I actually started to just copy the .swift files into my watchkit app folder and noticed when you add a file to Xcode on the dialog that comes up you get the

Using same iCloud enabled CoreData store across Watch Extension and iPhone

不问归期 提交于 2019-12-12 06:14:12
问题 I'm witnessing some strange behaviour when opening iCloud Enabled CoreData store from Apple Watch Extension. I'm using the same iCloud Container across all targets. Here is a picture that shows what folder (ubiquity container) structure looks like inside the ubiquity container : It looks like it creates different stores for iPhone & Watch I'm sharing the same CoreData Stack between iPhone app & Watch Extension. Any ideas why this is happening ? If I understand this correctly it treats iPhone

Sending array of dictionary from iPhone to watchkit app

大兔子大兔子 提交于 2019-12-12 06:12:03
问题 Code: AppDelegate.swift func application(application:UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) -> Void)!) { let entityDescription = NSEntityDescription.entityForName("Quote", inManagedObjectContext: managedObjectContext!) let request = NSFetchRequest() request.entity = entityDescription let pred = NSPredicate(format: "(quoteDate = %@)", "2015-03-08") request.predicate = pred var error: NSError? var objects =

Reading Apple Watch syslog (NSLog()) in real-time

我怕爱的太早我们不能终老 提交于 2019-12-12 06:05:36
问题 I'm looking for a way to read the watch's syslog in real-time, similar to the way Device Console or this do it for the iPhone. It's ok if the phone will be plugged by usb to the computer at the time I'm reading. At this point I'll even settle for a solution that somehow reads the texts at real-time from Xcode debug console, really (though I will prefer a way to hook in to the watch's syslog in a standard fashion :).. Thanks! 回答1: While I couldn't find any official way to get logs from the

Watchkit Complication and location updates?

徘徊边缘 提交于 2019-12-12 06:02:18
问题 I'm trying to write a complication that uses location data. I can get the location data in the complication controller but it never seems to work properly due to the results coming back asynchronously. What is the best way to update a complication with location specific data? I'm thinking that it's not a good idea to get the location in the complication (even though you can). 回答1: You should retrieve and cache the location data before the complication data source needs it. The job of your

Use of unresolved identifier 'WKExtension'

天大地大妈咪最大 提交于 2019-12-12 05:36:33
问题 i want to make a phone call from Apple Watch too. I imported WatchKit. Then i put this code in my method: if let telURL=NSURL(string:"tel:5553478") { let wkExtension=WKExtension.sharedExtension() wkExtension.openSystemURL(telURL) } It shows me an error: Use of unresolved identifier 'WKExtension' in line 2. I don't know what I am doing wrong :/ 回答1: WKExtension is only available on WatchOS 2.0, as you can see from Apple's prerelease reference. So I'm guessing you're either not using Xcode 7 or

How to show notification in iWatch?

99封情书 提交于 2019-12-12 05:30:05
问题 In my app, I want to implement functionality like when iPhone away with some distance from iWatch than watch app show local notification with a text message 回答1: If it is enough for you to get notified when the Watch gets disconnected from the Phone, you could use the WatchConnectivity framework to achieve this. The optional func sessionReachabilityDidChange(_:) gets called on the Watch when it disconnects from the Phone. However, your WatchExtension needs to be running in the foreground or

Notification syncing issue between iPhone and Apple watch

倖福魔咒の 提交于 2019-12-12 04:05:41
问题 I am working on iOS app in which push notifications comes from web server. I do Apple watch configuration in Xcode by adding new target and make new Provisioning Profiles and use them in Xcode for Apple watch. When i test it some times notification appear on Apple watch some times on iPhone not on both. Any one help 回答1: The OS determines which device to send the notification to based on a few different factors. Primarily, the Watch will only receive the notification if it is being worn –

WatchKit - iOS App Bundle Contains 2 WatchKit App Binaries

不问归期 提交于 2019-12-12 03:36:50
问题 When I build my iOS app for the app store and run the validation, I see that the embedded binaries and entitlements section contains two instances of my watchkit app. How is this happening? Has anyone else faced this problem? The entitlements I use are for keychain sharing and app group sharing. If any more information is needed, I'll be glad to provide it. When I build an enterprise version of this app and distribute it to my team, only one WatchKit app is installed. Should this be OK to