Understanding builds for Watch-iPhone app in XCode - ios

I have an iPhone app with an Apple extension and when I build the app in XCode only the Watch app starts building, I see both simulators but the iPhone app doesn't launch, is this a normal behavior when testing iPhone+Watch app?
I would like to have more control as far as builds since at times I just want to test the iPhone app and the Watch app doesn't need to be involved and vice versa.
Can I have both apps launch when building in Xcode so I can debug both?
Can I stop testing the watch app and only test the iPhone app if I wanted to?
Is there a way to speedup the build time?
Thanks

If the Watch App's or Watch Extension's scheme is selected, when you press Build, only your Watch app will launch.
You can launch both separately and debug both. If you only want to test the iPhone app, you can do it exactly as usual by selecting the iPhone app and running it from Xcode.
Regarding the build time, I think it's as fast as possible. Just make sure you don't have something that causes a full rebuild each time you are debugging, as build usually takes less than 2 seconds when working on a project if the project is not building from ground up (which usually takes over a minute in a normal-sized project).

Related

Release Apple Watch app only without iPhone app

Situation:
I have a Xcode project that included an iPhone app and a Watch App.
Goal:
Only release the Watch App
Issue at I Tunes Connect:
I get the message that I should upload product images for iPhone.
But I don't want to launch the IPHone app in it.
The Watch app works without iPhone fine.
Question:
Do I have the wrong project chosen in I Tunes Connect or must I delete targets in Xcode?
Snippet From Xcode
The iOS bundles had been inside the watch bundles.
We needed to separate them and it worked.

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.

iOS App testing - Low Budget Solution

So I am currently building my first iOS iPhone App which I plan to launch in the coming months. I have now finished my app but I don't have a big budget so testing on multiple devices is difficult. I already have an iPad so I assume that could run an iPhone version just to check that all the code is working. If I know that the code can run on an actual iOS device (the iPad) will the simulator suffice for the rest of testing would you think? I do plan to use test flight later on in the project too.
you could launch your app on your iPad with iphone mode. Just select option 'iPohne' as on screenshot below
Using simulator gives you some restrictions. For examle, you can not test full process of in-app purchase, location, ads, etc. So, if you are using some of this features for your specific platoform, it's better to test it on the actual device

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.

Simulator and device give different results

Have any of you ever ran into issues where the changes you've made are only being reflected on the simulator and not on the device?
Example, if i want to set the selected background image view for a table cell, the selection state in the simulator will show the changes but not on the device during testing.
This inconsistency is starting to worry me because when it's time to deploy to production, how do i know that the apps in the app store will work correctly?
Thanks
Have any of you ever ran into issues where the changes you've made are only being reflected on the simulator and not on the device?
Yes, this has happened to me many times.
This inconsistency is starting to worry me because when it's time to deploy to production, how do i know that the apps in the app store will work correctly?
When I first started developing for iPhone, I once had to rewrite a significant portion of code because while it worked perfectly in the Simulator, it did not work properly on the iPhone. I realized then that the Simulator is not an Emulator, that is, it does not replicate an iPhone exactly.
You need to test on an iOS device frequently to ensure that your code is working properly. That is what the App Store reviewers will be using and what your users will be using, not the Simulator.
During your daily development, you can use the Simulator and also your fastest device, like the 5th gen iPod Touch and iPhone 5. Periodically and towards the end of your development, it is good to test on older, slower, more memory limited devices, especially the oldest available that will run the iOS version that you are targeting.
The best thing you can do when this happens is to uninstall the app your're developing, (extra measure) restart the device to clean any app caches, and finally do a clean build from XCode. Things like this tend to happen to me frequently and uninstalling my app followed by a clean build seems to do the trick all the time.
Inconsistencies happen, that's why you need to test on actual devices (and why it's a simulator, not an emulator). In this case, it's most likely being caused by XCode failing to properly update the program, in particular the nibs. Delete your app from the phone and reinstall it fresh. The app store and iTunes use a different method of installation, so you shouldn't have to worry about it in the store.

Resources