How to migrate the existing project from WatchOS 2 into WatchOS 3 - watchos-2

I have an existing WatchOS 2 app. I want to upgrade it and add some WatchOS 3 features, so I have installed Xcode 8 beta 3. My question is do I need to create another target for WatchOS 3 project or I can still keep working on the same WatchOS 2 target and add new WatchOS 3 features there with Xcode 8.

Use same target but functions/code would need to be conditional:
#available(watchOS 3, *)
{
// do some watchOS 3 stuff
}
#else
{
// do some watchOS 2 stuff
}
#endif

Related

Can I develop in Xcode beta, then submit from the most recent Xcode GM?

I have found a lot of questions similar to the one I am asking only ask if you can develop and submit through the beta. This is not what I am looking for an answer to.
I am curious to know if I can develop my application using the Xcode 9 beta, but submit it through Xcode 8?
All programming would be done in the Xcode 9 beta, but when it is time to release the app, I would open the project in Xcode 8 to archive and submit it.
Is this something that would work? If not, why wouldn't it?
Note: I would be using Swift 3.2, not 4.
Submitting with Xcode 8 would be submitting using Swift 3.1 instead of Swift 3.2.
So you can write conditional code like that:
#if swift(>=3.2)
// code builds for Xcode 9 beta
#else
// code builds for Xcode 8
#endif
So in practice it gives compatibility to two versions of Xcode, but it's not the same code that compiles.
That's useful for pods and frameworks.
An example where code is required to be different between swift 3.1 and swift 3.2 is when using function swap(); example of use case:
extension Array {
mutating func unstableShuffle() {
for i in stride(from: count - 1, to: 0, by: -1) {
#if swift(>=3.2)
swapAt(i, Int(arc4random_uniform(UInt32(i))))
#else
swap(&self[i], &self[Int(arc4random_uniform(UInt32(i)))])
#endif
}
}
}
Xcode 9 GM Seed is available now. You can download Xcode 9 without Paid (Premium) Apple Developer Account from below links.
Now you can submit your project developed using Xcode 9 beta to app store using Xcode 9 GM Seed.
Xcode 9 - GM Seed
- (Command Line Tool - Xcode 9 - GM Seed for macOS 10.12)
- (Command Line Tool - Xcode 9 - GM Seed for macOS 10.13)

Building frameworks for iOS 8 and above in XCode 8

I have recently updated to Xcode 8. Previously I was using Xcode 7 with Swift 2.2.
I have a framework that I built in with deployment target iOS 9.3. Now that I have moved to Xcode 8 I cannot use this framework.
Is there a way I can build a framework that will work for iOS sdks 8 and above?
I want to set the minimum deployment target of my app to iOS 8+.
Also
Alamofire for Swift 3 has been updated and I have updated my pod file.
Will I be able to run the app in iOS versions above 8?
Any help will be appreciated.
Yes it is possible to build frameworks for iOS 8 with Xcode 8. But if you try to support iOS 8 you could also use Swift 3, put If you use other frameworks like Alamofire, you have to be careful, because the latest version of Alamofire (4.x) requires a minimum iOS target version of iOS 9. So you have to use Alamofire (3.x). With Alamofire 3.5 you have to use Swift 2.3
So first you have to decide what's more important for you:
iOS 8 support: So you have to switch to Swift 2.3 and Alamofire 3.x
Swift 3 support: So you have to drop iOS 8 support, because Alamofire 4.x requires iOS 9
As you know that Xcode 8 supports only Swift 2.2 and Swift 3. Your framework is built on top of Swift 2.2. So there is no way that you can run or build the project in Xcode 8, you will get an error like "The project has an older version of Swift, Please build it with newer version of Xcode".
You can use Xcode 8 and you can set minimum deployment target to iOS 8. But you can't use any of the new Swift 3 features in there, I mean you can use it but it will not execute in iOS 8. For that you have to write code with class or API availability checking for each snippet you write.
If you use new version of Alamofire there is no chance that you can use it in iOS 8.0. You need an older version of it. Because Alamofire new version is Swift 3 and have minimum deployment target of iOS 10 I think.
So it is better to convert your project into Swift 3 or to Swift 2.3. That is the best way to solve this situation. Otherwise you will see more lot of problems eventually.

Does Swift 2 work on iOS 8?

When building with Xcode 7 beta using Swift 2, can iOS 8 devices be used as deployment targets?
I remember that swift runtime gets embedded as dynamic framework so each app uses its own version of swift instead of iOS's version of swift, but I can't be sure.
On a related note, as of July 12, can you submit app to app store containing Swift 2?

Xcode 7 supporting watch OS1 and OS2

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
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?.
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.
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.
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.
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.
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.
Hope that helps
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!

Can't Run xCode 6 Beta 5 Swift App on iPhone 5?

I'm trying to test my swift app on my iPhone 5 device. But I'm getting the following message:
I just updated my iPhone 5 and xCode 6 to the latest versions. Any ideas?
Found out the issue was my deployment target in build settings is 8.0, it should be 7.0 if I want my swift app to run in iOS 7.
You cannot run the app when it is made with swift because that comes with iOS 8. you need the beta on your iPhone
And you cannot use swift for iOS 7 programming

Resources