Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

xcodebuild fails to build target that links AppIntents.framework once SWIFT_EXEC is specified

Reasoning

I am working on a tool that does swift code preprocessing, which is done by a custom script that gets passed as SWIFT_EXEC. This script does some magic and then calls the original swift compiler from /usr/bin/swiftc.

I am facing a rather non-common issue.

Problem

With the release of Xcode 16, for some reason xcodebuild now forcibly does not supply --compile-time-extraction flag to the appintentsmetadataprocessor, if xcodebuild also has a SWIFT_EXEC= argument.

(appintentsmetadataprocessor is a tool that is executed automatically by the xcode build system if the app is using App Intents feature).

Xcode 15 behaves fine in this regard and always passes --compile-time-extraction flag to appintentsmetadataprocessor (both with or without SWIFT_EXEC).

But when the --compile-time-extraction flag is not passed, the appintentsmetadataprocessor fails with an error, making xcodebuild fail as well, essentially making AppIntents unavailable if SWIFT_EXEC build setting is used.

Here's how to reproduce the issue:

Create a new iOS Xcode project, add AppIntents.framework to the list of linked frameworks, and run

xcodebuild SWIFT_EXEC=/usr/bin/swiftc

from the project directory.

If you're using Xcode 16 you will get a build error:

starting appintentsmetadataprocessor export
error: At least one halting error produced during export. No AppIntents metadata have been exported and this target is not usable with AppIntents until errors are resolved.
error: The operation couldn't be completed. (GeneratorBuildProductExtractor.BinaryScanningError 6.)

Alternatively, instead of running xcodebuild, one can add user-defined build setting SWIFT_EXEC=/usr/bin/swiftc to the xcode project target's build settings and build it from xcode, getting the same build failure error.

Question

The question I am hoping to get an answer or a hint to, is is there any kind of a workaround that would force appintentsmetadataprocessor to still get the --compile-time-extraction argument, when it is launched by the xcodebuild, so the build process completes sucessfully?

I also tried passing LM_COMPILE_TIME_EXTRACTION=YES to the xcodebuild, which, according to /Applications/Xcode.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/PlugIns/XCBBuildService.bundle/Contents/PlugIns/XCBSpecifications.ideplugin/Contents/Resources/AppIntentsMetadata.xcspec, should enable --compile-time-extraction, however this setting seems to be either ignored or overridden once the SWIFT_EXEC is passed, making it useless. Can this option be injected/enforced?

The corresponding issue tracking number is FB15274300

Thank you

xcodebuild fails to build target that links AppIntents.framework once SWIFT_EXEC is specified
 
 
Q