Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding an SPM Dependency from a build by reading a flag #6271

Closed
malcommac opened this issue May 10, 2024 · 5 comments
Closed

Excluding an SPM Dependency from a build by reading a flag #6271

malcommac opened this issue May 10, 2024 · 5 comments
Labels
type:need/problem Report needs or problems you came across that are not bugs

Comments

@malcommac
Copy link

malcommac commented May 10, 2024

What problem or need do you have?

Hello, I wanted to know if there is a way to exclude a specific dependency (specifically a locally imported framework via SPM) from the builds by reading the presence of a defined flag (e.g., RELEASE/DEBUG/TESTING) within the project settings. The framework should not be compiled or included in the final IPA

I think I could use the condition in TargetDependency but I'm not sure how I could read a settings flag, I can see only the PlatformFilter as possible argument: while I would to use the configuration (in pure SPM something like .target(name: "XXXX", condition: .when(configuration: .debug))):

.external(name: $0, condition: .when(...))

Potential solution

No response

macOS version

14.4.1

Tuist version

4.x

Xcode version

15.x

@malcommac malcommac added the type:need/problem Report needs or problems you came across that are not bugs label May 10, 2024
@malcommac malcommac changed the title Excluding an SPM Dependency from RELEASE builds Excluding an SPM Dependency from a build by reading a flag May 10, 2024
@pepicrft
Copy link
Contributor

Xcode only supports selecting dependencies based on the configuration being built, not on a certain value of a project build setting. You might be able to achieve that with imports implicitly resolved, but I advise not to, because many Xcode features, such as Swift Previews, rely on explicitness to work reliably. Does it answer your question?

@malcommac
Copy link
Author

Hi @pepicrft thank you for your quick reply. Per configuration import would be okay; what's the best way to achieve it via Tuist?

@pepicrft
Copy link
Contributor

Sorry, my bad; I meant destination and not configuration. I think you'll have to resort to build settings magic to conditionally do that, like CocoaPods does, but as I mentioned, this is generally not a good idea.

@malcommac
Copy link
Author

malcommac commented May 16, 2024

Upon further thought, I have come to the conclusion that it would be much easier and faster to send to the Tuist generate (or read via environment variable) a setting that tells me whether to create a project/target that includes that framework or not. This way, I can easily handle this scenario by choosing the best configuration depending on whether it's a development, testing, or production build.

@fortmarek
Copy link
Member

That sounds like a good way forward! We're closing the issue as there's no action item for us here 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:need/problem Report needs or problems you came across that are not bugs
Projects
None yet
Development

No branches or pull requests

3 participants