Reproducing the toolchain used by Xcode

Hi, I'm trying to make tweaks to the toolchain for use in Xcode, but I'm having trouble because it seems that Xcode's toolchain may include changes that aren't published to the release branches of swift, llvm-project, etc. For example, this change to support MacCatalyst availability checks doesn't exist in the 5.5 release branch, but must exist in the clang that ships with Xcode.

Am I missing something, or is Apple keeping secrets that make it harder for external devs to work with Xcode + the open source toolchain?

1 Like

Apple starts with the open-source compiler code(clang, swift) and adds it's own modifications for whatever reasons it wants, many having to do with deeper integration with Xcode, and many are new features that are destined for open-source once they have been fleshed out in the proprietary environment.

These modifications are proprietary to Apple. It's one of the reasons that Apple ditched gcc and went to clang when gcc was re-licensed under GPL version 3. Modifications may transition to the open-source distribution later.

Right, that's the sense I've got. But withholding changes is actively making it harder for people interested in contributing to the project (e.g. me) to do so, because first I need to try to reproduce Apple's secret changes to get a toolchain on par with the one that ships with Xcode, and only then can I do meaningful work on it.

I can understand that Apple may have some things they'd like to keep secret, but to the maximum extent possible, I'd like to see the entire toolchain open-sourced alongside Xcode releases. Swift's README has instructions for installing the toolchain into Xcode. It'd be great if that actually worked for complex projects that rely on Apple's as-yet proprietary modifications.

As with the example mentioned above, some of the modifications seem to exist in open source already, just not in the release branch.

It sounds like you want to tinker with the integration of Xcode and the swift/clang infrastructures. You have now entered the proprietary Apple environment, for which Apple has long declared by actions and words that they are not interested in external developers directly interacting with the Xcode environment and application. They will take Feedback reports for suggestions that may or may not be realized, but, direct interaction is something that they have not allowed for decades. The only supported way to extend Xcode by external developers is via the Xcode extension process, which currently only provides for extensions to the Xcode editor.

1 Like

No, I am not interested in tinkering with the integration of Xcode. My interest is strictly contained to the Swift frontend at the moment, as used by any clients including Xcode, SwiftPM, or the driver. However, I want to test my changes against an extant codebase that uses Xcode to build. This is made extremely difficult by the fact that I can't land my changes atop a drop-in replacement for the toolchain that ships with Xcode.

I think it makes sense to allow developers to be able to test toolchain changes against existing code that happens to use Xcode to build.

If you’re only changing the frontend you can set a build variable in Xcode to override the frontend. SWIFT_DRIVER_SWIFT_FRONTEND_EXEC

Where this gets used:

Thanks, I'm aware of that variable but not sure where to set it in Xcode. Can you point that out to me please?

Getting the clang binary out of the equation would be helpful, though I think I've managed to find the necessary cherry-picks and fixes for that.

Even in the swift frontend, there are commits that should probably be in the release branch but aren't, like 04135a3.

It’s a user defined setting in the project build settings: objective c - How can I access a user-defined Xcode build setting? - Stack Overflow

Assertions will be disabled in releases, so that might be why that commit didn’t get cherry-picked.

Are you sure this actually works? I tried setting it like this, but Xcode still used its own swift-frontend.

Terms of Service

Privacy Policy

Cookie Policy