Hive
Can not load external target settings via SPM
GitHub issue · Open
What happened?
Description
When using an external Swift Package (via SPM) that defines cxxSettings with conditional compilation flags, these settings are not being applied to the app target that depends on the package.
Expected Behavior
When a target depends on an external SPM package, the compilation settings defined in that package (particularly cxxSettings ) should be properly loaded and applied to the dependent target, so that the preprocessor macros and Swift compilation conditions are available during compilation.(see: https://github.com/tuist/tuist/pull/6170)
Actual Behavior
The settings defined in the SPM package’s cxxSettings are not being loaded or applied to the dependent app target. The preprocessor macros (e.g., SHOULD_COMPILE_LOOKIN_SERVER, SPM_LOOKIN_SERVER_ENABLED) defined in the external package are not available in the app target.
How do we reproduce it?
- Use the attached demo project
- Run
tuist installandtuist generate - Run App
- The console is supposed to output
LookinServer - Will launch. Framework version: 1.2.8, but it currently doesn’t, so the Demo App cannot be seen in Lookin. Using SPM works successfully.
Error log
no error message
macOS version
26.0.1 (25A362)
Tuist version
4.119.1
Xcode version
Version 26.1 (17B55)
Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.
Start a Flight and preserve its objective, outcome, and session here.
Hi @liaoyuanng! I’m Dosu and I’m helping the tuist team.
This is a known limitation in Tuist: cxxSettings (such as preprocessor macros and conditional compilation flags) defined in external Swift Packages are not automatically propagated to dependent app targets when generating Xcode projects with Tuist. This is by design—Tuist emphasizes explicit configuration and does not merge or forward these settings from SPM packages to your app target automatically. As a result, macros like SHOULD_COMPILE_LOOKIN_SERVER or SPM_LOOKIN_SERVER_ENABLED won’t be available unless you add them yourself docs.
Workaround:
You need to manually add the required compiler flags or macros to your Tuist manifest. You can do this in your Project.swift or Target.swift by specifying them in the settings for your app target. For example:
let project = Project(
// ...
targets: [
Target(
name: "App",
// ...
settings: .settings(
base: [
"OTHER_CPLUSPLUSFLAGS": "$(inherited) -DSHOULD_COMPILE_LOOKIN_SERVER -DSPM_LOOKIN_SERVER_ENABLED"
]
),
// ...
)
]
)
Alternatively, if you only need to set flags for specific source files, you can use the compilerFlags property in the SourceFileGlob struct docs:
sources: [
.glob("Sources/App/**", compilerFlags: "-DSHOULD_COMPILE_LOOKIN_SERVER -DSPM_LOOKIN_SERVER_ENABLED")
]
If your SPM dependency uses disableWarning flags, Tuist 4.96.0+ supports mapping those to the appropriate Xcode build settings, but this does not cover general cxxSettings propagation PR #8549.
After making these changes, regenerate your project with tuist generate and verify in Xcode that the flags appear in the build settings for your app target.
For now, manual configuration is required for any macros or flags you expect from SPM cxxSettings. There is ongoing discussion about improving this, so keep an eye on future Tuist releases if this is critical for your workflow discussion.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
To help troubleshoot, could you clarify what exactly isn’t working? For example, are the macros still missing in your app target, or is there a build error? Could you share the relevant part of your Tuist manifest (like your Project.swift/Target.swift) showing how you added the flags, and confirm if you ran tuist generate and did a clean build? If you have any build logs or screenshots of your Xcode build settings, that would help too.
Just to confirm, Tuist does not automatically propagate cxxSettings from SPM packages—you have to manually add the required flags to your app target’s settings for them to appear in the build. Sometimes, settings at the project level are overridden by target-level settings, so the flags need to be set directly on the target that needs them. If you can share your current setup, I can help spot what might be missing or misconfigured.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.