Is SwiftUI backwards-compatible with iOS 12.x and

2020-01-29 05:49发布

If I have an app made with SwiftUI, will it work for iOS below iOS 13?

10条回答
The star\"
2楼-- · 2020-01-29 05:52

It is compatible with iOS 13+. Here is link to its documentation.

https://developer.apple.com/documentation/swiftui/


Even Xcode 10 does not support it. You need to use Xcode 11 which is in beta as of (Jun 3 2019). https://developer.apple.com/tutorials/swiftui/creating-and-combining-views

查看更多
萌系小妹纸
3楼-- · 2020-01-29 05:54

Based on Apple documentation it's available only starting with iOS 13, unfortunately.

https://developer.apple.com/documentation/swiftui/

查看更多
我想做一个坏孩纸
4楼-- · 2020-01-29 05:57

As all people before me mentioned, it's very clear that it will require iOS 13 or later. But as a new iOS developer, I was worried about to what extent I should adopt SwiftUI in comparison with UIKit. I already built some small projects with UIKit, and went somewhere advanced with it.

But as SwiftUI commenced, how to combine between them. The article in the following link puts all in context: https://www.hackingwithswift.com/quick-start/swiftui/answering-the-big-question-should-you-learn-swiftui-uikit-or-both

My only concern now is that I noticed with Xcode 11 that an Xcode project cannot combine both Storyboards and SwiftUI.

查看更多
趁早两清
5楼-- · 2020-01-29 05:58

If you are shooting to support iPhone and not iPad you could probably expect most users will upgrade to iOS 13 within 12-18 months(starting with the release date). Maybe 85-90%? (I think Apple said at this point theres still 15% of people not on iOS 12) That’s still quite a while though to where you aren’t going to be able to deploy SwiftUI apps right away or else risk alienating a lot of users.

Also depending on what the other 10-15% is, that could mean a lot of users (and $$) for you left on the table.

If you are supporting iPad as well then its more tricky because people don't upgrade their iPads as often. Theres a lot of iPad 2s along with 3rd and 4th generation iPads still out in the wild, that only have 10.3.3 and cannot upgrade anymore. People just aren't going to go get up and go pay between $400 - $1,000 for a new iPad when theirs works perfectly fine.

There’s always room and a need for updating the app, making it better, fixing bugs, that don’t necessarily have anything to do with iOS 13. i.e. finding a bug you didn’t know about before that making a lot of users unhappy.. not on the latest iOS version. and we haven't even talking about enterprise / corporate customers that a lot of dev shops support. theres a lot of more pushback on iOS updates for various reasons in that area.

So before you get all excited about iOS 13 and SwiftUI (which you absolutely should because its awesome), back in the real world, outside of Silicon Valley, that's not exactly going to align with what the average consumer expects and you will need to support older devices and need to because theres just too many people you would be alienating.

查看更多
兄弟一词,经得起流年.
6楼-- · 2020-01-29 06:00

only works for ios 13 or later

you can still attach your SwiftUI code by using

@available(iOS 13.0, *)
查看更多
我欲成王,谁敢阻挡
7楼-- · 2020-01-29 06:06

SwiftUI and Combine use Opaque-Return-Types in Swift 5.1 and since Opaque-Return-Types (alongside other features) are implemented in Swift 5.1 and due to the nature of their implementation, they can not be back deployed like DSL or Property-Wrappers to Swift 5.0, and because iOS 13 is the only iOS SDK that contains Swift 5.1 runtime in the OS, so the answer to the question is no and SwiftUI and Combine can not be used on earlier versions of iOS.

Unless, Apple provides a way to bundle Swift 5.1 runtime (or future releases) with the application like it used to do with earlier Swift versions, but since it will increase App-size and add overhead to the whole system again, I doubt this will ever happen.

It might be backward compatible

Swift 5.1 is not released yet and SwiftUI uses features such as opaque return types, DSL, propertyDelegate(introduced in WWDC as propertyWrapper) and etc, which will be available only in Swift 5.1. Since Swift 5 is binary stable, I guess it was not possible to use embedded swift-frameworks inside Xcode11, hence they’ve re-implemented these features in Cocoa’s core and marked them as iOS13+ available until Swift 5.1 gets released.

My assumptions are based on the fact that, Ordered Collection Diffing and DSL are going to be available in Swift 5.1 and have no correlations with Xcode or Apple’s eco-system, but they’re also marked as @available(iOS13,...). This means that they had to mark everything using Swift 5.1 features with the iOS availability attribute. Some of them will get removed once Swift 5.1 gets released, but we can’t be sure about SwiftUI and Combine unless Apple tells otherwise. This is also mentioned in DSL’s proposal:

Implementation: PR. Note that the implementation in the Xcode developer preview uses a somewhat simpler transformation than that described here. The linked PR reflects the implementation in the preview but is under active development to match this proposal.

So backward incompatibility limitation might be lifted when Swift 5.1 gets released, but it really needs to be clarified by Apple team.

查看更多
登录 后发表回答