-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
Multiplatform Phase 3 - Expose support in ProjectDescription
#5381
Conversation
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.
Thanks @waltflanagan
@@ -0,0 +1,112 @@ | |||
import Foundation | |||
|
|||
extension Multiplatform { |
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.
The approach you've taken here is much cleaner though so I see the value in that, main concern is maintaining two duplicate Target
s
Would it be possible to make this the main Target
structure but map the the legacy properties to the appropriate underlying new properties?
e.g.
init(
// ...
platform: Platform,
deploymentTarget: DeploymentTarget,
// ...
) {
self.init(
// ...
destinations: [Destination.from(platform)],
deploymentTargets: DeploymentTargets.from(deploymentTarget)
// ...
)
}
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.
yes we can and should. this approach was taken to continue to support source compatibility for current Tuist users. given that platform
is a public property of Target
, I didn't feel safe changing how things like that are exposed at this point in time.
If we're open to breaking changes, we can very much adjust the main Target
type for our new needs as well as provide a convenience initializer that makes migration simpler for folks that dont need multiplatform support.
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.
Makes sense to maintain source compatibility.
My thinking is we may be able to map / derive the old properties to prevent breaking changes, however if that proves to be too much hassle the approach you have taken is much cleaner.
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'm on the fence here. While supporting source compatibility is important, the cost of maintaining two similar structures in the codebase creates room for inconsistencies. I'm not a big fan of breaking changes, but multi-platform support is an important change for Tuist and might warrant going with a major release, in which we can batch other deprecated APIs. If I'm not wrong here, the changes developers would have to make are not that significant, so even if it's a breaking change, which is always undesirable, the process "should" be straightforward.
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.
My main thought for this was that it would be "short" lived. We could publish the source compatible version for a while, allow users to migrate at their own pace and incrementally if they have many targets to migrate. After enough time we can make the source breaking change to remove the old deprecated target implementation and promote the multiplatform one to the only one.
|
||
extension Target { | ||
/// Platform for use with services when a platform is not specified | ||
var servicePlatform: Platform { |
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.
What about naming this one platformIfOneOrThrow
? It reads more verbose, but someone reading the code will immediately get the logic by reading the getter name.
e24a1d0
to
5e31c9b
Compare
β¦ations - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support #5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
β¦ations - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support #5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
β¦ations - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support #5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
β¦ations - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support #5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
- Updated the `GraphLinter` to account for multi-destination (multi-platform) targets - Lint issues are now flagged only if there are no valid source and destination platform combination based on the existing rules rather than only using the `legacyPlatform` (single platform) to base the rules on Test Plan: - Existing unit tests should continue to pass - New cases for valid and invalid combinations were addeed Notes: - This is a pre-requiste for #5381 which adds the public API for multi-desintations
β¦ations - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support tuist#5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
β¦ations (#5438) - When specifying multiple destination, the `SUPPORTED_PLATFORMS` build setting needs to be set to include the various sdks for both simulator and device Notes: - This was cherry-picked from a draft PR for multi-platform support #5381 Test Plan: - Multiple destinations is not yet exposed via public as such can only be validated with unit tests at this time
- Updated the `GraphLinter` to account for multi-destination (multi-platform) targets - Lint issues are now flagged only if there are no valid source and destination platform combination based on the existing rules rather than only using the `legacyPlatform` (single platform) to base the rules on Test Plan: - Existing unit tests should continue to pass - New cases for valid and invalid combinations were addeed Notes: - This is a pre-requiste for #5381 which adds the public API for multi-desintations
- Updated the `GraphLinter` to account for multi-destination (multi-platform) targets - Lint issues are now flagged only if there are no valid source and destination platform combination based on the existing rules rather than only using the `legacyPlatform` (single platform) to base the rules on Test Plan: - Existing unit tests should continue to pass - New cases for valid and invalid combinations were addeed Notes: - This is a pre-requiste for #5381 which adds the public API for multi-desintations
98cc77c
to
a9621b5
Compare
e697373
to
3b47e00
Compare
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.
Thanks @waltflanagan π
I'll experiment locally to see how much of a lift would the refactor of the graph types to account for platforms
be if we think that is a valid path.
I think we can split this (I appreciate it further delays getting a working version π)
Option A - Exposing API first to allow limited usage + further testing
- (1) Expose
destinations
inProjectDescription
and map using existing logic - (2) Add
platformFilters
support to dependencies etc...
Option B - Internally refactor to support platformFilters
on dependencies ahead of exposing API
- (1) Propagating
platformFilters
internally withinGraph
/Models
- (2) Exposing API in
ProjectDescription
projects/tuist/fixtures/multiplatform_app_with_sdk/Project.swift
Outdated
Show resolved
Hide resolved
) | ||
case let .target(name, path): | ||
guard let target = target(path: path, name: name) else { return nil } | ||
return .product( | ||
target: target.target.name, | ||
productName: target.target.productNameWithExtension, | ||
platformFilters: target.target.dependencyPlatformFilters | ||
platformFilters: target.target.dependencyPlatformFilters // What to do here now that we have smart things? |
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.
we have a few options:
- We can either omit
platformFilters
fromproduct
dependencies (i.e..target
/.project
) dependencies and automatically derive this as we do today onmain
- if we expose
platformFilters
we'd have to do some form of intersection between the user specified filters (which may contain errors - possibly lint warn / error ahead of time) + valid filters we determine
8288fe1
to
44b9a81
Compare
b5980f7
to
2282fa8
Compare
β¦m:)` to resolve filters
This will filter out windows, linux, and other platforms when a dependency is exclusively conditional on them.
59dc6a4
to
0c16654
Compare
@@ -15,3 +15,19 @@ public enum Platform: String, Codable, Equatable, CaseIterable { | |||
/// The visionOS platform | |||
case visionOS = "visionos" | |||
} | |||
|
|||
/// A supported platform representation. | |||
public enum PackagePlatform: String, Codable, Equatable, CaseIterable { |
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.
This was introduced because SPM includes catalyst as a platform while many other parts of our system map catalyst to iOS. This was a necessary distinction when inferring destinations from a SPM package.
15c5268
to
842c4a6
Compare
Very first exposure of multiplatform work in ProjectDescription. All feedback on API design welcome.
Short description π
tbd
How to test the changes locally π§
tbd
Contributor checklist β
./fourier lint tuist --fix
Reviewer checklist β
changelog:added
,changelog:fixed
, orchangelog:changed
, and the title is usable as a changelog entry