r/iOSProgramming • • 3d ago

3rd Party Service Build Xcode projects on Linux with SweetPad

https://sweetpad.hyzyla.dev/blog/2026/11/21/build-xcode-projects-on-linux/

Hello! I would like to share my CLI that allow to build native iOS applications on Linux. It works with Xcode projects with zero changes and make possible to build native ios applications without macOS at all

16 Upvotes

15 comments sorted by

2

u/pandaro 2d ago

sweet serendipity! i started working on same yesterday.

tried on a real app: ~215k lines of swift in about 630 files, plus at least one vendored c library (libopus). it's 7 xcode targets: a swiftui ios app, share and notification extensions, an embedded watchos app, and test targets. it also uses local swiftpm packages and has git swiftpm dependencies. fresh deb 13 vm, 8 vcpu, sweetpad 0.1.28 from the apt repo, sdk imported from the xcode 27.2 .xip.

the device and simulator builds just worked (unsigned): 142 s cold for generic/platform=iOS, 18 s incremental, and the simulator build succeeded too. very impressive. three things i hit:

1. test build fails on watchos links: unknown argument: '-fuse-ld=lld'

the failing tasks are swiftc-driven Ld steps (swiftc -emit-library) for a swiftpm library product that swift build builds as a dynamic ..._PackageProduct.framework for watchsimulator. in the same build log, the swiftc links for the same kind of dynamic product on iphonesimulator get -use-ld=lld -ld-path=.../ld64.lld, while the watchsimulator ones get -fuse-ld=lld -ld-path=.... swiftc has no -fuse-ld. i re-ran the failing command by hand with -use-ld=lld swapped in, and it links fine and produces a mach-o. so it looks like the watchos path picks the clang spelling of the flag for a swiftc-driven link. the scheme has watch unit and ui test targets. i haven't built a minimal repro.

2. setup sample build rejects its own cache directory under umask 0002

error: Setup sample build failed: cannot prepare build utilities: build utility cache must be owned by the current user and writable only by that user: ~/.cache/sweetpad

~/.cache didn't exist before the first sweetpad run. afterwards ~/.cache/sweetpad and ~/.cache/sweetpad/swift were 0775, while ~/.cache/sweetpad/distribution was 0700. that's consistent with the mode only being applied to the leaf of a recursive mkdir. this was a regular (non-root) user on a stock debian 13 cloud image, where the login umask is 0002 (user private groups). root and most containers get 0022, so they won't see it. after chmod 700 ~/.cache/sweetpad, doctor is clean and builds work. i didn't re-run setup's sample build itself.

3. (minor, maybe intended) --json failure envelope goes to stderr

on success the envelope is on stdout. on a build failure, stdout is empty and the {"ok":false,...} envelope is on stderr, so > out.json only captures successes. if that's deliberate, a line in the docs would help.

1

u/hyzyla 2d ago

Thanks for feedback ! Looking into those πŸ‘€

2

u/pandaro 1d ago

no problem, happy to try again whenever - thanks for sharing this. it's definitely only half of the solution for ci, but if it's dependable it could free up the macos vms to focus on running tests.

2

u/ThalesMother9938 1d ago

Zero chagnes to the Xcode project is the part that got my attention, because that's usually where these setups fall apart. How do you handle code signing and provisioning profiles on Linux, or is that the one step that still needs a Mac?

1

u/hyzyla 21h ago edited 21h ago

singing works on linux too, i reimplmeneted apple's codesign in rust for that. You download singing profile from apple developer account and then everything else happens on Linux

2

u/mrdzyn 1d ago

This is a really interesting idea. Curious how you're handling the parts that usually depend on Apple's own tooling, like compiling asset catalogs and storyboards, and code signing? I could see this being super handy for CI runners where macOS minutes get expensive, even if the final signing and upload still happens on a Mac.

1

u/hyzyla 21h ago

Most of those tools I reimplmented them from scratch to make them work on linux. here is a list of those tools:

  • Storyboards and XIBs β€” ibtool

  • Asset catalogs β€” actool

  • Core Data models β€” momc

  • Core Data migration mappings β€” mapc

  • String Catalogs β€” xcstringstool

  • App Intents metadata β€” appintentsmetadataprocessor

  • Code signing β€” codesign

  • Entitlement encoding β€” derq

Some are hard to port, so they stay on mac. I'm thinking maybe to have remote server or something that will allow remotly call those

  • Metal shaders β€” metal, metal-ar, metallib

  • Core ML models β€” coremlc

  • SceneKit assets and shaders β€” scntool, copySceneKitAssets, compileSceneKitShaders

  • RealityKit assets β€” realitytool

  • AR reference objects β€” referenceobjectc

  • SpriteKit texture atlases β€” TextureAtlas

5

u/Zenmodo 2d ago

FYI linking against the SDKs in any way on a non-Apple platform is against their developer program terms and if caught doing this can result in your developer license being suspended.

> You agree not to install, use or run the Apple SDKs on any non-Apple-branded computer

Other versions of this idea have been done in the past but don’t gain much traction for this reason.

2

u/ct_the_man_doll 2d ago

I wonder if we might see someone work on a open source SDK for Apple devices.

-4

u/pandaro 2d ago

that's explained in op's doc; don't get sanctimonious without taking three seconds to look first.

2

u/Zenmodo 1d ago

It’s called out in a footnote but not explained in a way that actually resolves the issue or explains why you should do it anyway. Many may not even see that footnote.

1

u/hyzyla 21h ago

fair point, moving to the top of the article

1

u/zellJun1or Foundation 3d ago

Isn’t it using the open source foundation for Linux which is not complete?

2

u/hyzyla 3d ago

No, no. It links agains Apple SDKs (aka original Foundation). Unfortunately to run you need to have iOS or macOS. But at least building is now possible

2

u/Fair_Sir_7126 2d ago

SweetPad is the best