Xcode 7 supporting watch OS1 and OS2
Asked Answered
A

2

20

I have been fiddling with Xcode 7 for sometime now, I get to know that it supports only Swift 2 and there is no way to support Swift 1.0 or 1.2 in Xcode 7. This is fine.

Now coming to WatchOS, can I have two targets one for WatchOS1 and one for WatchOS2 separately in Xcode 7 so that I can support for both??

I was looking into the deployment target setting in the build settings of both the watch target and the iOS app target but I could see only WatchOS2 in the list so

  1. Can I support two targets one for WatchOS1 & WatchOS2 respectively in Xcode 7? If so should I install WatchOS1 SDK at some place?? or this it totally not possible, if not why?.

  2. If both targets can be supported how can I prevent source duplicates for both targets since both OS have significant differences in terms of architecture.

  3. Also since the introduction of WatchConnectivity framework the iOS counterpart app will also have some changes, how to maintain that for the two targets?

I am confused and I need to take a decision quickly, any help is appreciated.

Austria answered 22/6, 2015 at 7:55 Comment(2)
@Droppy But in iOS targets I am able to see lower version of iOS in the list. Why so?Austria
@Droppy Yes I too think the same but what if I need to support both, fingers crossed!Austria
D
26

You can support watchOS 1 apps in Xcode 7. You can also support watchOS 2 apps in Xcode 7.

If you want to support both watchOS 1 and watchOS 2 then you will need to have separate targets for each OS (due to the differences in architecture)

For a watchOS 1 app, add a new target and select the Apple Watch section from the left and then click on the WatchKit App for watchOS 1 from the list.

watchOS 1 App

For a watchOS 2 app, add a new target and select the watchOS > Application section and then click on the WatchKit App option in the list.

watchOS 2 App

Couple of things to note about making a watchOS 1 app in Xcode 7 (beta 1)...

Because I did my testing on an iPhone 6 running iOS 8.3 and my watch running watchOS 1.0.1, I needed to change my deployment target to iOS 8.3 but note that you want to do this at a project level rather than just target level (so that the extension also gets set to 8.3 and not just the main app) otherwise it won't let you deploy onto a real device.

Due to a known issue in Xcode 7 beta 1, a watchOS 1 app will fail to install on a real watch with the following error if your paired phone is 64 bit:

Jun 20 17:25:08 Liams-iPhone companionappd[271] <Notice>: (Error) WatchKit: validateWatchKitApplicationInfoDictionary, invalid Info.plist key 'UIRequiredDeviceCapabilities'

This is because Xcode 7 is adding arm64 to the UIRequiredDeviceCapabilities info.plist key at build time even to your watchOS 1 extension when it shouldn't be.

You can temporarily get around this by setting Build Active Architecture Only to NO for DEBUG mode.

Xcode 7 Known Issue

Hope that helps

Denims answered 22/6, 2015 at 10:35 Comment(3)
Thanks liam for the detailed answer but I have few questions please se my updated question.Austria
How exactly do you test the watchos1 app? As I don't see an option to download watchos1 simulatorWeathered
I'm not sure about simulators but I know that you are able to run it on a physical device running watchOS 2.xDenims
E
4

You can have both a watchOS 2 app for an iOS 9 iPhone and a watchKit Extension for an iOS 8 device.

I would though say that if you haven't already made a WatchKit app (as in watchOS 1), then it's highly unproductive to make a watchOS 2 app and try to create and maintain a watchOS 1 app... just jump on board to watchOS 2 for sanity purposes!

Excretion answered 22/6, 2015 at 10:45 Comment(6)
No @Excretion I already have a WatchKit 1 app and I want to take a stand due to release dates.Austria
So the watch engineers encouraged me at WWDC to not "migrate" my watchOS 1 app to 2, instead just create a new target for the watchOS 2 app and have them coexist.Excretion
Ok makes sense but any idea on how to juggle code for the two targets?Austria
You could remove os1 specific API usage in your interface controllers to a category or separate class and then use that slimmed down interface controller class in both targets. My app will probably be completely rewritten so I don't have this concern but that's probably how I would do it.Excretion
Xcode 7: Has anyone seen where the dropdown for the deployment target for the watch kit 1.0 app and extension ONLY has watch kit 2.0 available? Tried an existing and a new project and same result for the WK1.0 targets. I did set the associated iOS app to 8.3 target, still no luck. Must I extract the 1.0 WK SDK from an earlier version of Xcode? Wondering if anyone's done it.Hoarding
@Hoarding did you finally manage to build your watchos1 app under Xcode7 . I have a problem similar.Commencement

© 2022 - 2024 — McMap. All rights reserved.