Osegi
Software·2 min read

Build iOS and macOS apps on Windows without a Mac, using WSL2

A developer got native SwiftUI apps compiling into an iOS .ipa and a macOS .app on Windows 11 in about 28 seconds, with no Mac and no Xcode window.

A Windows 11 laptop showing a terminal compiling a Swift app into an iOS .ipa file, with no Mac in sight.
Image: Хабр

You can build a native iPhone app on a Windows PC without owning a Mac. One developer did it on Windows 11 using WSL2, Swift 6.4.1 and a tool called xtool, and a small SwiftUI test app compiled and packed into an .ipa in 28.3 seconds.

The limits come first. This covers cross-compiling, linking Mach-O binaries (Apple's executable format) and packaging .ipa and .app bundles. It does not run the iOS Simulator, test the interface on a real macOS, pass Gatekeeper or sign a release with a Developer ID certificate.

How to build an iOS .ipa on Windows

The setup is an isolated WSL2 Ubuntu 22.04 environment in /opt/macless-build, with Swift 6.4.1, xtool 1.24.0 and the official Xcode_27.1.xip, which you download yourself from your Apple Developer account. A thin Python wrapper called macless-build ties it together. No Apple binaries sit in the public repository.

One trap: running xtool new inside a script makes it open an Apple Account login wizard and hang on a closed stdin. A documented flag switches that off.

The first real build of a SwiftUI screen with a title and a counter button took 24.80 seconds to compile, 28.3 in total. The HelloWindows.ipa weighs 125,215 bytes and holds an arm64 executable targeting iOS 17.0. It is unsigned, on purpose, so the build never touches an Apple account unasked.

Can you build a macOS .app on Windows too?

Yes. While reading xtool's source, the author found that unpacking Xcode.xip also installs a macOS SDK, MacOSX27.0.sdk, with arm64 and x86_64 targets. So Swift on Linux can build macOS SwiftUI projects through SwiftPM directly.

Five snags followed. The target triple must be exactly arm64-apple-macosx or x86_64-apple-macosx, with the minimum OS set in Package.swift. The new swiftbuild engine crashed, so the build needs --build-system native, which SwiftPM already flags as deprecated. The LLD linker prints a warning, which the author left visible. Zipping a .app on Windows strips the executable permission, so the packager writes explicit Unix attributes into the ZIP.

Two details are easy to misread. The binary records SDK 14.0 even though it compiled against the 27.0 SDK. And the code signature on the ARM64 build is only an ad-hoc one added by the linker, not a Developer ID certificate.

Apps worth a look

SUMO: the number puzzle

Tap the right tiles, add them up, hit the target. Easy to learn, hard to master. Free, for all ages.

Tags:swiftxtoolwsl2iosmacosswiftui

More from this day

See all →

More in: Software

See all →