Hi folks! A few months ago I shared my Swift SDK for Darwin, which allows you to build iOS Swift Packages on Linux, amongst other things. I mentioned that a lot of work still needed to be done, such as handling codesigning, packaging, and bundling.
I'm super excited to share that we've finally reached the point where all of these things are now possible with cross-platform, open source software. Enter, xtool!
About
xtool does a lot of things (because Xcode does a lot of things ) but the headline features are
Build a SwiftPM package into an iOS app
Sign and install iOS apps
Interact with Apple Developer Services programmatically
This means it's finally possible to build and deploy iOS apps from Linux and Windows (WSL). At the same time, xtool is SwiftPM-based and fully declarative, which means you can also use it to replace Xcode on macOS for building iOS software!
Using xtool
I put together some DocC Articles + a DocC Tutorial on how to get started with xtool. You can find these at xtool.sh.
Gotchas
The aim so far has been to flesh out the core functionality in a typical build-run-edit loop for an iOS application. There's some things that are infeasible outside macOS, and others that are possible but still need to be implemented:
- Interface builder: would require a lot of effort to replicate, probably not worth it since SwiftUI mostly supersedes it at this point
- Asset catalogs: require reverse engineering to implement, might be worth it. You can still add images as raw files in the absence of asset catalogs, it's just less efficient.
- Proprietary macros: The ones that are also in the Linux toolchain (e.g.
@Observable
) work just fine, but Apple-proprietary macros (such as the SwiftData ones) will need to be reverse-engineered and rebuilt from source if we want them to work. Or Apple could ship these as WebAssembly Macros which would make them host-independent - App Extensions: Right now you can only build "Application"-type targets. I think App Extensions should be easy to implement as an addition to the
xtool.yml
spec, but just require engineering effort. - LLDB debugging: this used to be pretty easy before iOS 17, and xtool has all of the pieces in place to support lldb with those old versions, but Apple has recently made a number of changes to the way you invoke LLDB's
debugserver
on iOS. There are a few modern tools that support the new approach (notably pymobiledevice3), and it's already possible to use these tools to connect to lldb, but I definitely want to integrate this into xtool down the road. This will require a good amount of work since the new RemoteXPC protocol is entirely different from the legacy mechanism, but it'll probably be necessary in the future for other functionality as well. - App Store deployment: You can build and run on your own device with xtool, but it doesn't let you deploy builds to App Store Connect yet. Luckily 1) iTMSTransporter is cross-platform and 2) we have all the other infra in place to interact with the ASC API, so this should be achievable too, but remains to be done.
xtool is a culmination of 8 years of work around iOS app deployment (the commit history has some nuggets!) but I'm the sole developer on this project and replicating Xcode is a massive undertaking. Now that I'm ready to share the project more widely, I'd be very happy to accept external contributions to flesh out the feature set. And if you end up using xtool, please let me know!