How to use XCode with Swift for Ubuntu

I am a working on a new iOS project and I want to use Swift to develop both the iOS app and the server to be run on Ubuntu. Ideally, I would like to use the current (and same) version of Swift for both projects. And I would prefer to use XCode for both projects.


I have set up a private GitHub repository for my server project and wanted to develop it in XCode on my desktop; push it to GitHub and then pull it to my Ubuntu instance for testing. However, I am running into a number of issues. But, mainly I'm grappling with just building my project on Ubuntu.


The current Swift Ubuntu release build is for 2.2.1, but does not include the Package Manager, so I'm a bit at loss on how to build the project without maintaining some sort of custom script file. The Package Manager is included in the current Development build, however the Development build is for Swift 3, which doesn't match the XCode Swift version (at the moment). There are previous development builds available, but they don't indicate which version of Swift they correspond to.


Beyond that, there are library incompatibilities that making it challenging to write the code on the Mac and then transfer it to Linux to be run.


What is the best way to do what I'm trying to do? Is there a better way to accomplish what I'm trying to do? What did Apple have in mind for this situation?

>What did Apple have in mind for this situation?


For you to use their IDE? On a Mac, of course.


Since you can't ad-hoc Swift and still release an iOS app, if that's your primary goal, you'll need to level versions from there and work out.


I think in the end you'll need to bifurcate your dev efforts, with the iOS app work done on a Mac and your server on Ubuntu. Because in the end, by the time you let that iOS app to talk to your server, it won't care which versions Swift were used to get there, as long as they were IDE compatible.

Xcode 7.3 and later let you select a custom toolchain, and there are toolchains available for Swift 3. To set this up, follow the instructions on the Swift download page.

I regularly use this feature to check whether problems I’m seeing in the release build of Swift (which is what I use day-to-day) still exist in the latest Swift 3 pre-release. I don’t have Linux set up, alas, so I don’t have direct experience on that front.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How to use XCode with Swift for Ubuntu
 
 
Q