-
Re: Save data from Watch to Phone?
eskimo Nov 25, 2016 2:00 PM (in response to WatchDev2015)In watchOS 2 and later your iPhone app and WatchKit extension are running on different bits of hardware (the iPhone app runs on the phone, the WatchKit extension runs on the watch). There’s no longer any possibility of shared file system access between the two. If you want to put data from the watch to the phone, you’ll need to use a networking API. Most folk do this sort of thing using the Watch Connectivity framework but there are other options (for example, you could store the data in CloudKit and have both the watch and the phone access it from there).
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Save data from Watch to Phone?
WatchDev2015 Nov 27, 2016 5:42 AM (in response to eskimo)Thank you for your answer! I understand what you are syaing, however the code I developed runs on the iPhone, and is only called from the Watchkit Extension. So I have a file in the iPhone app called WriteData that performs the write to the database, and i set it up as a Shared Instance:
static let sharedInstance = WriteData()
and then in the Watchkit Extension, there is a file that tracks the data on the Watch, and then to write the data I call
WriteData.sharedInstance.updateDatabase()
but for some reason when the updateDatabase() is called directly from the iPhone, it creates a different path than if it is called from the WatchKit extension, despite the code running on the iPhone in both cases...Strange.
-
Re: Save data from Watch to Phone?
eskimo Nov 28, 2016 1:58 AM (in response to WatchDev2015)for some reason when the updateDatabase() is called directly from the iPhone, it creates a different path than if it is called from the WatchKit extension, despite the code running on the iPhone in both cases
We’re talking watchOS 2 or later, right? If so, the WatchKit extension is not running on the phone, it’s running on the watch.
To summarise:
Code watchOS 1 watchOS 2… iOS app phone phone WatchKit extension phone watch WatchKit app watch watch Notice the change in the second row; the WatchKit extension has moved from the phone to the watch and thus no longer has the ability to share data directly with your iOS app.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Save data from Watch to Phone?
WatchDev2015 Nov 29, 2016 7:07 AM (in response to eskimo)Yes Watch Os2.The confusion is because the database code is running ONLY on the iPhone, not the Watch Extension App. So from the extension app I simply call the code on the Phone:
I have a file in the iPhone app called WriteData that performs the write to the database, and i set it up as a Shared Instance:
static let sharedInstance = WriteData()
and then in the extension app i use the following line tp update data:
WriteData.sharedInstance.updateDatabase()
-
Re: Save data from Watch to Phone?
eskimo Nov 29, 2016 3:45 PM (in response to WatchDev2015)So from the extension app I simply call the code on the Phone …
How do you do that? What API do you use to do the networking between the watch and the phone? Watch Connectivity? Or something else?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Save data from Watch to Phone?
WatchDev2015 Dec 8, 2016 10:47 AM (in response to eskimo)Hi:
In the iPhone app, I have a file called "WriteData.swift", with Target Membership for both the iPhone App and watch Extension, and in that file I declare it as a static shared instance:
static let sharedInstance = WriteData()
then in the Watchkit Extension App, there is a file called "ScoreInterfaceController.swift", and from there I call:
WriteData.sharedInstance.updateDatabase()
so when the updateDatabase() code is called from teh iPhone, it builds a path to teh DB file, but when it is called from teh file in the Extension app (but AFAIK the code itself still runs on teh iPhone), it builds a different path.
I hope this is making sense.
Thanks!
John.
-
Re: Save data from Watch to Phone?
eskimo Dec 11, 2016 3:31 PM (in response to WatchDev2015)… when it is called from teh file in the Extension app (but AFAIK the code itself still runs on teh iPhone) …
This last bit is where you’re confused. In watchOS 2 and later the WatchKit extension runs on the watch.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
-
-
-
-
-