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
Allow specifying explicit product destinations in PackageSettings #6073
Conversation
Aren't target platform determined depending on which targets depend on the product? |
This is where you have a Tuist project depending on Swift targets. I believe the scenario @fortmarek addresses here is where you run Tuist against a Swift Package. In that scenario, we have no information that allows us to narrow-down the list of platforms. |
@@ -29,6 +29,12 @@ public struct PackageSettings: Codable, Equatable { | |||
/// The custom `Product` type to be used for SPM targets. | |||
public var productTypes: [String: Product] | |||
|
|||
/// Custom product destinations. This setting should only be used when using Tuist for SPM packages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd mention first that the key in the dictionary represents the name of the product for which the destinations are defined.
@@ -175,7 +175,7 @@ final class ProjectEditor: ProjectEditing { | |||
|
|||
/// We error if the user tries to edit a project in a directory where there are no editable files. | |||
if projectManifests.isEmpty, editablePluginManifests.isEmpty, helpers.isEmpty, templateSources.isEmpty, | |||
resourceSynthesizers.isEmpty, stencils.isEmpty | |||
resourceSynthesizers.isEmpty, stencils.isEmpty, packageManifestPath == nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So users can run tuist edit
on a project that has the Package.swift
manifest only
@@ -40,6 +40,14 @@ final class EditAcceptanceTestAppWithSPMDependencies: TuistAcceptanceTestCase { | |||
} | |||
} | |||
|
|||
final class EditAcceptanceTestSPMPackage: TuistAcceptanceTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one!
@@ -53,6 +53,8 @@ final class InstallServiceTests: TuistUnitTestCase { | |||
// Given | |||
let stubbedPath = try temporaryPath() | |||
|
|||
manifestFilesLocator.locatePackageManifestStub = stubbedPath.appending(components: "Tuist", "Package.swift") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered taking the opportunity to use @Mockable
with ManifestsFileLocating
?
Yup, that's exactly the scenario this PR aims to fix 🙏 |
I see, are we ignoring the setting in case we are running against a tuist project instead? |
Also, I need we need to support |
No, we're not. I feel it would be weird if that setting didn't do anything depending on if the
Yes, the PR already adds support for that. |
I think we should. |
Sure, done! |
Resolves https://github.com/tuist/tuist-cloud/issues/153
Short description 📝
Let's take the following
Package.swift
:In this example, we have two products –
MyPackage
andMyUIKitPackage
.MyPackage
supports all destinations, whereasMyUIKitPackage
only support iOS-based platforms since it depends onUIKit
(which is not available on platforms like macOS).If you try to use e.g.
tuist cache
when developing a package, we will try to cache all platforms since packages implicitly support all platforms. To explicitly encode inPackage.swift
if some of your products support only some destinations, we're adding a new property ofPackageSettings
calledproductDestinations
. For the above example, you could encode thatMyUIKitPackage
supports only iOS-based platforms by:How to test the changes locally 🧐
Run
tuist generate
in thespm_package
fixture.MyPackage
target should have all destinations whereasMyUIKitPackage
onlyiPhone
andiPad
.Contributor checklist ✅
mise run lint:fix
Reviewer checklist ✅
changelog:added
,changelog:fixed
, orchangelog:changed
, and the title is usable as a changelog entry