Swift-X tool to cross compile Swift and Objective-C(++) code to Android
1–10 of 27 posts
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#2Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#3swift-x is a python script that simplifies the compiling of Swift and Objective-C(++) code into object files.
... [It] is a two stage wrapper for clang and the swift compiler that uses the Android NDK tools to produce android compatible .o files.
The first stage uses clang or swift to compile source code and emit LLVM-IR code which is passed to the Android second stage tools which compile the IR into .o files.
So you get working object code, but you still need to figure out how to get Android versions of the Cocoa Touch libraries if you use any of those APIs.
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#4From the project's GitHub page, some more details on what it actually does: swift-x is a python script that simplifies the compiling of Swift and Objective-C(++) code into object files. ... [It] is a two stage wrapper for clang and the swift compiler that uses the Android NDK tools to produce android compatible .o files. The first stage uses clang or swift to compile source code and emit LLVM-IR code which is passed…
But this could be useful for people who enjoy Swift, and want to reuse blocks of logic from their iOS app to an Android port.
I'm wondering though, I thought Swift compiled down to code that uses things like the Foundation framework (NSString etc), which would also be missing on Android. It would be hard to do anything without these classes, wouldn't it?
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#5From the project's GitHub page, some more details on what it actually does: swift-x is a python script that simplifies the compiling of Swift and Objective-C(++) code into object files. ... [It] is a two stage wrapper for clang and the swift compiler that uses the Android NDK tools to produce android compatible .o files. The first stage uses clang or swift to compile source code and emit LLVM-IR code which is passed…
You can't just take a Swift app for iOS and compile it for Android, sure. But this could be useful for people who enjoy Swift, and want to reuse blocks of logic from their iOS app to an Android port. I'm wondering though, I thought Swift compiled down to code that uses things like the Foundation framework (NSString etc), which would also be missing on Android. It would be hard to do anything without these classes, wo…
Once you have the Obj-C runtime and cross-compiler working, porting either of those to Android should be fairly simple... But I suspect that Swift may have dependencies on new or recent Foundation features which could be missing from the open-source versions (for understandable reasons, they lag behind Apple by several years).
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#6Earlier quoted context omitted.
You can't just take a Swift app for iOS and compile it for Android, sure. But this could be useful for people who enjoy Swift, and want to reuse blocks of logic from their iOS app to an Android port. I'm wondering though, I thought Swift compiled down to code that uses things like the Foundation framework (NSString etc), which would also be missing on Android. It would be hard to do anything without these classes, wo…
There are several independent open-source implementations of Foundation like GNUStep and Cocotron. Once you have the Obj-C runtime and cross-compiler working, porting either of those to Android should be fairly simple... But I suspect that Swift may have dependencies on new or recent Foundation features which could be missing from the open-source versions (for understandable reasons, they lag behind Apple by several…
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#7Also interesting http://kivy.org allows you to use Python for iOS, Android, OS X and Windows.
I would not bet on Swift and cross compiling it today... too bleeding edge. But interesting project... hope it matures. Good luck!
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#8When I wanted to code a foundation of reusable code for different devices I would either do it like Dropbox and use C++ as the most common layer http://oleb.net/blog/2014/05/how-dropbox-uses-cplusplus-cros... or use Javascript (which I can also use for web pages) for the program logic like described here http://www.skyscanner.net/blogs/developing-mobile-cross-plat... Also interesting http://kivy.org allows you to use…
Re: Swift-X tool to cross compile Swift and Objective-C(++) code to Android
#9When I wanted to code a foundation of reusable code for different devices I would either do it like Dropbox and use C++ as the most common layer http://oleb.net/blog/2014/05/how-dropbox-uses-cplusplus-cros... or use Javascript (which I can also use for web pages) for the program logic like described here http://www.skyscanner.net/blogs/developing-mobile-cross-plat... Also interesting http://kivy.org allows you to use…
Another viable — and possibly more enjoyable — approach would be to use C# for the full stack, irrespective of platform. See http://xamarin.com