tuist / tuist

Tuist's CLI
https://tuist.io
MIT License
4.48k stars 535 forks source link

Plugin symbols are not available in the `Package.swift` when it is being resolved #5873

Closed ak-bs closed 6 months ago

ak-bs commented 6 months ago

What happened?

In the past we used to define Package dependency helpers in our Tuist plugin like so:

extension ProjectDescription.Package {
  public static let alamofire = .package(...)
  public static let internal = .local(...)
}

then in the Dependencies.swift our engineers would use the helpers like:

let dependencies = Dependencies(
  swiftPackageManager: .init(
    [
        .alamofire,
        .internal,
        ...
    ]
  )

However, in Tuist 4.0 beta 1 it looks like the the only way to use Plugin symbols in the Package.swift is to wrap the relevant code into #if TUIST, which is reasonably not available when SPM resolves the dependency graph. This means the Plugin can't be used to provide dependency helpers anymore.

How do we reproduce it?

Just try importing a plugin in the Package.swift outside of the #if TUIST statement and run tuist fetch.

Error log

error: 'tuist': Invalid manifest ...

macOS version

14.2.1

Tuist version

4.0.0 Beta 1

Xcode version

15.2

danieleformichelli commented 6 months ago

Ciao Alex 👋 Unfortunately with the new solution you can only use PackageDescriptionHelpers for the part that describes the Tuist part of the manifest, but not for the Package part, so it is currently not supported to define helpers like that anymore 😓