SwiftUI for non-Apple platforms (like Android, Web, Windows)

Swift was announced with the explicit goal of "World Domination".

It makes sense that SwiftUI needs to be open-sourced, even to some degree, for that goal to be realized.

21 Likes

I'm a lowly UI dev on the Windows team at Microsoft and am only speaking for myself, not the company, but I would love to be able to target web and Windows with SwiftUI. I've been doing UI development for a long time and SwiftUI looks like the best take on it yet.

21 Likes

In my opinion SwiftUI should be open sourced just so the community can help push it forwards and fix issues. As demonstrated by the Swift community already, there are a lot of people willing to contribute their energy and knowledge to a project like this and I think Apple would be missing an opportunity if they didn't try to utilise that.

I think my biggest concern is that after using UIKit for the past 9 years (oh god, has it been that long :dizzy_face:) is that when bugs have been found you need to hack your way around them either by doing something inventive within the constraints of the framework or by swizzling into the framework and fixing it yourself. Then, if you're lucky, years down the line the issue gets fixed and you can eventually remove your hack. I really don't want to have to go through that again with SwiftUI.

Another advantage of SwiftUI being open sourced is that we could (within reason) support some backwards compatibility. This would help faster adoption or new features and allow back porting of bug fixes instead of waiting for a new OS release to fix a bug.

Personally I'm not that interested in bringing it to other platforms as I'm sure it relies heavily on CoreGraphics/Animation and that would be a big job to port to other platforms and that isn't getting open sourced, ever. But I do want to make making UI's on Apple's platforms better, and open sourcing is a fantastic opportunity to do that.

How about it @tkremenek, how do we convince you, Craig or whoever makes the open source decision of SwiftUI to make our dreams come true? :star_struck:

7 Likes

I am afraid this decision is not up to @tkremenek.

Yeah, I thought that might be the case, but I didn't know who else to @ on these forums.

At least he may be able to speak to his supervisor and forward the signal from the Swift community.

1 Like

I don't see it happening. At least not any time soon.

Apple's traditional approach to developer tools and frameworks is that they are features of the platform. Basically, if it is easier to create great Apps for Apple platforms, then Apple platforms will have the best Apps, which translates to a direct competitive advantage over platforms where easy-to-write Apps are not so great, or great Apps are much more difficult to create.

It's not just theory, either - for a long time, it was a broadly-recognised fact that iPhone Apps were of higher quality than their Android counterparts. That gap still exists, but it has been narrowed because smartphones are so ubiquitous that companies saw the value in making significant investments to create decent Android software for smartphones. It wasn't just among developers, either - consumers recognised the difference.

On the other hand, Android tablets never really took off (partly because they had such crappy software), so it wasn't worth making another huge investment for them. The difference between iPad and Android tablet software is often still like night and day, because it's just so much easier to create great iPad Apps.

These days Apple is doing more in services, but even then, they are still tied as closely as possible to Apple's platforms. That's why services like iMessage still require an Apple device: "oh, you want the features, privacy and ease-of-use of iMessage? Buy an Apple device." Similarly, the story which makes most sense from Apple's perspective is to say: "oh, you want this super-simple UI framework to help you write great Apps in much less time? Build your App for Apple devices."

So I don't expect this to go open-source. It could happen, but I think it would be out of character for Apple.


Now, there have been 3rd-party implementations of UIKit in the past (most notably from Microsoft as part of their WinObjC bridge), but one very important thing has changed in that time: Oracle sued Google and won (EDIT: Appeals not yet exhausted, see below). That case established that APIs (not the implementation, but the "structure, sequence, and organisation" of available functionality) are creative works similar to writing a song. Thus, they are protected by copyright. You don't even need to file anything to have copyright protection; it's automatic.

This led the court to conclude "that the overall structure of Oracle's API packages is creative, original, and resembles a taxonomy" (p. 14). It therefore reversed the district court on the central issue, holding that the "structure, sequence and organization" of an API is copyrightable.

There are some exceptions to copyright protection ("fair use"), and Google tried to argue that "interoperability" should be one. I don't believe there was a conclusive ruling on that argument, because (A) It was hypocritical; once they had enough market power, Google diverged from the Java APIs to make them less interoperable with regular Java, and (B) Android's use of Java failed a lot of other "fair use" factors (e.g. commercial, not minimal, not transformative, and diluted the value of Oracle's IP).

Now, IANAL, but my understanding of the Oracle vs. Google case is that a 3rd-party implementation of the SwiftUI API could easily be an infringement of Apple's copyright, just like Google's own implementation of Java's SDK infringed on Oracle's copyright. Depending on how you use/distribute it, some of the facts may be different, but Apple could still argue that a non-commercial implementation dilutes the value of their IP (see above: good APIs are a competitive advantage). In any case, my point is: even if Apple does not open-source the framework, I'm not sure it is safe to assume that you may create your own implementation. Wait to see if SCOTUS hears the case, and maybe get some actual legal advice depending on what they say.

EDIT: Meant to quote @pvieito 's post.

EDIT2: Apparently, Google is still trying to appeal the ruling to the Supreme Court. This is the 2nd time they've tried; the court declined to hear it on the first attempt. We'll see what comes of it, but it's at least far from certain that copying an API is legal, even if it's backed by your own clean-room implementation.

6 Likes

Keep in mind that Android and Windows have different UI/UX then iOS or macOS. So, I don't believe that SwiftUI will be available for Android or Windows.

1 Like

That really doesn't have anything to do with it, given that macOS, iOS, tvOS, and watchOS all have different UI/UX and SwiftUI is designed for them all. Apple even did a session at WWDC about supporting all platforms from the same codebase. So it seems entirely likely that SwiftUI could be made to work on Windows and the Linux UI frameworks, Apple just chooses not to do so. Personally, I recognize that abstracting the SwiftUI runtime away from the underlying platforms enough to make it available to other platforms would be more work than they'd otherwise need to do, but I think the benefits would outweigh the costs, as Swift and SwiftUI would suddenly become a viable cross platform app framework.

7 Likes

What Apple doesn't get is that they are losing the battle for developers. A lot of education institutions simply won't teach software development for Apple platforms because:

(1) students would have to purchase an expensive computer (my 15" MBP costs more than the tuition for three years at our university, even if you don't have a scholarship).
(2) it uses programming languages and frameworks that are specific to the platform and aren't used in other courses.

If students have to choose between developing for Android using a language/platform they already know (Java), or spending $$$ to develop using a language/platform they know nothing about (and may not even like), what do you think they'll do?

Investing more in Swift on other platforms, and open sourcing more frameworks so they'll work on those platforms will mean Swift can be adopted for general programming courses, and the barrier of entry into Apple platforms will be much lower. This is definitely in Apple's best interest as it will increase hardware sales.

10 Likes

Wouldn‘t Swift remain closed sourced by that logic. You could argue „oh you want to develop with a cool modern type safe language, build for apple platforms in Swift“. Yet it‘s here, and it‘s availability grows with the recent support for Windows. :slight_smile:

If people start building apps for Android in Swift(if that was possible), they may just port their code to Apple platforms and everyone benefits.

So my fingers are crossed for the good outcome of the initiated signal from this discussion.

4 Likes

Ideally I'd love to see low-level UI implementations on other platforms with SwiftUI as a front-end, a la Flutter.

However, I don't see it being open sourced anytime soon. Its currently being positioned as a meaningful competitive advantage for Apple, so it would be a pretty big departure from the status quo.

There could also be some significant technical hurdles. The amount of integration SwiftUI has with Apple's localization and accessibility features, as well as possible future directions like AR (which will definitely remain proprietary), may make it difficult to fully abstract it in an accessible way for OSS development.

Although I can't see a future where Apple provides an Android implementation, I can definitely see them making a Web version at some point, (though maybe just internally...also possibly via WASM?), and maybe a linux version (although, who uses linux for it's GUI? :wink:). As for Windows...I doubt it, but with the way Microsoft has been changing it's not nearly as clear cut as it used to be.

Regardless, as most/all the required language features should be in Swift, there's nothing stopping someone from building their own version for other platforms. Even if there are potential copyright issues, I'm sure there are ways around that via code conversion or something similar.

2 Likes

What about a $330 iPad with Xcode for iPad in iOS 14/15? :wink:

What are you basing this on? It seems to be continually gaining popularity, And even if that's mainly cannibalizing Objective-C, that's still a win. Swift is still VERY new. 5 years since it's announcement is meaningfully more recent than any popular competitor I'm aware of.

As far as academia, my perception of most (U.S.) universities is their Computer Science programs aren't really interested in following trends. I think this has changed somewhat, but for a long time many programs used Academic languages for much of the intro/theoretical classes.

IMO the more compelling story for Swift+Education is at the primary/secondary level with something like Playgrounds on an iPad. I can't see a University using Swift as it's primary teaching language for another decade or so when the language features have stabilized, full Memory Management has been added, and it has meaningful usage among professors.

1 Like

Well, firstly, Apple didn't have anything to do with Windows support (neither did Microsoft AFAIK).

Secondly, I don't think Apple considers the language itself to be a part of their "special sauce". There are lots of reasons why it makes sense to open the language itself up, so that it can be more widely supported on server platforms, for example. I doubt even Apple uses macOS as a server.

Of course, it may still happen. Anything might happen. I'm just saying that this is pretty wishful thinking. Not only is there no evidence to support it, but there is arguably evidence against it. Lots of people have been wishing for years that they'd open-source UIKit. And did they?

I don't think Apple just forgot to mention they'd be open-sourcing SwiftUI. If there were any such plans, they would have said that.

"everyone benefits" except Apple and their customers. Suddenly they're just getting ports of Android Apps instead of the bespoke experiences they've been used to.

At the same time, "bespoke experiences" shouldn't mean "difficult to create" or "requires expert knowledge". The goal has always been to make it as easy as possible to create great Apps which behave in a way that is natural to the platform.

3 Likes

Let me clarify: That's mean that SwiftUI should understand that app is running on Android and it needs to use Material Design instead of Cupertino. Therefore as I understand SwiftUI should implement all these Material Design components at the core. Flutter works in that way.

if winning the battle for developers won the war, linux would rule the world. winning users is what matters, and the developers will follow the market. as long as you need an iphone to send a blue text, i don't see Apple's market dominance going away anytime soon.

4 Likes

Yes, developers will develop for iOS because they have the users, but that doesn't mean they'll use native Apple technologies. Where I live, cross-platform tools such as React Native, Flutter and the sorts are way more popular with students, and this year's students are next year's developers ...

If Apple wants developers to build native apps, so their users have a better experience, and a reason to buy an iPhone over an Android device, they need to open up their development platform so more students can be exposed to it.

4 Likes

Personally, I don’t care that much whether the SwiftUI will be open source or not. It would be useful for me when trying to understand or optimize an app. However imo, SwiftUI won’t be SwiftUI without all the Core libraries supporting it. I am far more interested in having all the tools needed to create SwiftUI-like wrappers around other (C) libraries like GTK+. Then people would be able to write some small wrappers that would just pick correct method for a platform.

I hope property wrappers and dsl would be sufficient, however, having Combine open source would be great. (I hope it would since it is listed under the Foundation framework in the documentation.)

3 Likes

I definitely want students to adopt Swift and there's no doubt Apple could do more in that realm. I also think the comparison should be with Objective-C, and not things like React. I'm unsure where I would find a statistic, but I think It's fair to assume there are more students (at all levels) using Swift now than there were using Objective-C prior to Swift's launch.

My question though is why they're popular. Three reasons I see are ease-of-use, compatibility, and relation to existing platforms. The only platforms Apple cares to integrate with is their own which Swift does quite well, and SwiftUI massively improves ease-of-use to be on par with (or better than) Flutter, and compatibility went from 1 or 2 platforms to 5.

Flutter is becoming trendy now just like ReactNative has been (and is now starting to fall off), just like Xamarin was for a while and Cordova before that. These platforms tend to spike in popularity and then settle into a particular niche. They're still great for plenty of use cases, but there are always drawback. E.g. they're usually developed by a single company with no real guarantee it will still be supported in 5 years time if/when their business model changes. Whereas I doubt Apple will sunset SwiftUI in the next decade.

1 Like

I think that sums it up well. These tools are available everywhere and you don't need to buy a new computer to use them.

1 Like