How to set new build system in Xcode 13.3?

Hi everyone,

To enable new build mode in Xcode 13.3, it needs to run following command in terminal:

defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

If new team member installs Xcode 13.3 and forgets to execute above command he gets build error locally.

Is there a way that above command can be set as a script or flag in Xcode so new engineer doesn't need to worry about executing it in a local terminal?

Note: I tried saving it as Run Script in App target and as a argument in Run scheme. It didn't work.

There should be no instance where not setting that value causes a build error, otherwise Xcode would be broken by default. Your issue likely lies somewhere else.

If you post the actual error you're seeing we may be able to help.

Hi @Jon_Shier Thanks for replying. There are few frameworks as as dependency in my project. On all prior versions it works well except Xcode 13.3 without setting above EnableSwiftBuildSystemIntegration 1 command. On Xcode 13.3 it shows errors like cycle in dependencies between targets.

I am not the only one who's facing this issue. Please see the this question here Xcode 13.3 cycle in dependencies b… | Apple Developer Forums.

I am only looking for answer is how to set up following command as script in Xcode configuration so other engineers won't need to execute on terminal.

defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

Xcode 13.3's stricter cycle detection is usually due to the header phases in framework targets. Reordering the headers to build before the source or just deleting the header phase, if it's a Swift target, should resolve the issue.

Your fundamental issue here is that the defaults value requires a restart of Xcode to take effect. So there's no way to do this automatically inside Xcode. There are various way to automate launching Xcode, but it really depends on the infrastructure you have in place.

Speculatively I'd say the build system integration only has an effect because it breaks the otherwise more strict build rules. You can see the same thing happen with other compiler features, like notes, which don't appear when the integration is active.

Hi @Jon_Shier, Xcode13.3 shows me following error. When I clean build initially it works successfully but fails immediately if I change the source code.

Could you please help to resolve this error as its only comes with latest Xcode13.3 and goes away with above EnableSwiftBuildSystemIntegration 1 command which I need to execute only once?

Cycle in dependencies between targets 'Intents Extension' and 'UtilityiOS'; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.

Looks like the headers issue others mentioned. You either need to reorder the headers build phase above the sources build phase or delete it, depending on whether you have any actual headers.

2 Likes

I tried moving all run scripts above compile sources under build phases section. However, it didn't solve my problem of cyclic dependencies but running defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1 as build script solved. Only thing is this command needs Xcode restart after first build to enable the latest build system.