Issues running Apple Watch glance app in simulator - ios

I'm trying to test my apple watch glance for my iOS app using the simulator, however I'm getting some very strange behaviour. When I launch the iOS app in the simulator it works without problem and the app is fully functional. However , when I then try to launch the glance app for apple watch afterwards it shows up, but the iOS app no longer works (if I try to launch it from the simulator it immediately crashes) and the data that's in the app sharing group doesn't show up on the watch (but if I relaunch the iOS app simulator from Xcode it shows up there).
I've checked both apps and they are configured for the same sharing groups and that is definitely the case.
I just don't understand why running the iOS app and the apple watch app in the simulator won't work / behave correctly together?

Credit to #WhiteTiger for this answer:
if you're using watchos 2 appgroup the system does not work on the device, you should use wcsession as the documentation indicates.
Or look at updating to use the WatchConnectivity approach instead

Related

Issue with watchOS app when submit iOS app

I have an issue when uploading iOS app with watchOS, when I upload the iOS app it's showing that there is no WatchOS app attached to it. I tested the app in the simulator and it is working fine, here is the targets for my app it is showing there are watchOS targets attached to it
every time I upload the iOS build it is showing there is no Apple Watch app attached. can anyone help me out to figure out what is the problem for this one
I could think this is it. Watch app for iOS is installed with the iOS app, stand-alone watch app is installed standalone via the watch app store

Implications of converting dependent watchOS app to independent with watchOS 6

I am considering updating to an independent app for watchOS 6 (as Apple suggests) but it's not clear to me what will happen to users of older watchOS versions that have my app installed. More specifically:
What will happen if a user had the dependent app installed on their watchOS 5 watch but downloads an update of the iOS app (which now lists the watch app as independent) for their connected iOS 13 iPhone? Will the watch app be uninstalled or not function at all (since it will try watch connectivity with an iOS app that no longer supports it)?
This will definitely occur, since, according to official page:
watchOS 6 will be available for Apple Watch Series 1 and Apple Watch Series 2 later this fall.
I think this is not a hard question. An independent app means that the app can work alone. But it doesn't have to. An independent watchOS app should work with or without the iOS companion app. If you watchOS app can't work properly without iOS companion app, it is not an independent app. You should refactor your Apple Watch Extension or just leave it as not independent.
Here are what I believe should be true:
If you installed an Apple Watch app with its iOS companion app, both apps are removed if you remove the iOS app.
However, if the Apple Watch app is independent, you could installed it alone without install the iOS companion app.
For the second rule, there are some pitfalls as a developer. When you are debugging an independent watch app, it is listed in Watch app on iPhone. However, since there is no iOS companion app, you can't remove it entirely on iOS. Even if you have removed it on Apple Watch, it is still shown as not installed in Watch app.

Running Watch Simulator and iOS Simulator

When I'm running the Apple Watch simulator from Xcode, both the iOS simulator and the Watch Simulator launch but the iOS app doesn't start up. Is that by design or am I doing something wrong? I can launch either in the simulators and they communicate as expected but if both would launch at the same time that would be very useful.
Xcode doesn't have an option to automatically run both apps for you.
The existing approach is historically by design, but there are other reasons for it too. For example:
It's faster, and uses less resources to not unnecessarily (build, install and) launch the host app.
You may want to test that the watch app works as expected when it can't communicate with its paired device or app.
Within Xcode, you tell it to run a particular app, whether it be the iOS app or the watchOS app. That's the (only) app that launches.
The best you can do (within Xcode) is to first run the iOS app, then run the watchOS app. Both will be running, and you can then debug either one from within Xcode.
Of course, you could always submit a feature request to add an option to launch both apps.

Will iPhone app run on iPhone not paired to an Apple Watch

I'm new to iOS development and I'm playing with Swift in Xcode working on a number of experimental projects.
In one of these I've designed an app for the Apple Watch (using the InterfaceController.swift in Watch App Extension) and in the same Xcode project I've also deigned a corresponding app for the iPhone (in the usual Main.storyboard, ViewController.swift, etc). When I run these apps using the iPhone 6s + Apple Watch - 38mm simulator, both apps run on each device as they should.
Now, if I connect my iPhone 6s and try to run the app, I get a message stating: "Could not launch 'App Name' on iPhone 6s. No paired Apple Watch."
I don't actually own an Apple Watch, so the error is understandable. But this got me to thinking and I now have the following questions:
If I go through the process to submit this to Apple, will the iPhone app work for people as a standalone iPhone app if they have no Apple Watch? Or, are the apps in this project (both the iPhone and Apple Watch apps) only going to work for people who have an iPhone paired with an Apple Watch?
If I want this iPhone app to be available to people with only iPhones, do I need to do anything special? For example,do I need to create a new Xcode project and effectively copy across the iPhone app from this project, or is there another approach I should adopt?
What else do I need to be aware of? For example, do I need to rename the iPhone app to something different to make it available only to iPhone users? Is there anything else I should be aware of?
Regarding running the app on your iPhone, as Paulw mentioned in the comments, just change the execution target to the iPhone app. See screenshot:
Answering your other questions:
The watch extension is an extension inside your iPhone app. iOS Apps with a watch extension work on all iPhones, even if they are not paired with an Apple Watch.
Yes it will be available.
You don't need to worry about anything else. The iPhone app will work on all iPhones. The watch app will show up on only those iPhones that are paired with an Apple Watch.

WatchKit App only starts iPhone Simulator and WatchKit App, but not the IOS App

I have configured the WatchKit App to run on iPhone 6, the WatchKit App Scheme Executable points to WatchKit App.app, Watch interface points to Main, but the IOS App is not starting only the WatchKit App.
When I select the WatchKit App to run on iPhone 6, the iPhone 6 simulator is starting, I see a black screen for a second after that the simulator returns to IOS level but the main app is not starting, only the WatchKit App on the Apple Watch simulator. I can not figure out why the IOS App is not starting?
In order to debug the iOS app while running the Watch Extension, you should follow the steps explained here.
You also need to understand that the iOS App does not have to be running while the Watch app is running. You have several combinations of possible runtime scenarios...all of which your iOS app and Watch App must handle seamlessly.
iOS App is running but not the Watch App
Watch App is running but not the iOS App
Both apps are running in the foreground
Watch App is running in the foreground and iOS App is running in the background
I have also posted some additional information about launching the parent app from the Watch Extension as well as sharing data here.
Hopefully that helps.
If you want to see NSLogs from the container app, you can do this:
put a breakpoint as early in your watch app's processes as possible
run the container app
stop the container app
run the watch app and let it hit the breakpoint
with the watch app running and debugging connected, go to the simulator and open the container app by clicking on it
go back to XCode and go to Debug > Attach to process > Your container app
You should now be connected to both processes, and see breakpoints and logs from both. You can use the thread navigator in the left pane to switch between apps (which you'll need to do to get the watch app running again).
Note that an early breakpoint in the watch app is optional, I just find it useful to make sure any early breakpoints are caught.
There is a bug at the moment which hasn't been fixed yet. To get around and launch the iPhone app do the following:
1) Stop any process in Xcode.
2) Build and run the iPhone app.
3) Stop the iPhone app once launched.
4) Switch to the WatchKit scheme extension and build and run it.
5) Open your iOS app from the iPhone home screen by pressing its icon.

Resources