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

tuist cache fails #6030

Closed
kapitoshka438 opened this issue Mar 5, 2024 · 9 comments · Fixed by #6047
Closed

tuist cache fails #6030

kapitoshka438 opened this issue Mar 5, 2024 · 9 comments · Fixed by #6047
Labels
type:bug Something isn't working

Comments

@kapitoshka438
Copy link
Contributor

What happened?

My app project with SPM dependencies fails on tuist cache with the latest Tuist 4.5.0.
Tuist 4.4.0 works fine.

How do we reproduce it?

tuist install
tuist cache

Error log

We received an error that we couldn't handle:
    - Localized description: The operation couldn’t be completed. ((extension in TuistLoader):ProjectDescription.PlatformCondition.OnlyConditionsWithUnsupportedPlatforms error 1.)
    - Error: OnlyConditionsWithUnsupportedPlatforms()

If you think it's a legit issue, please file an issue including the reproducible steps: https://github.com/tuist/tuist/issues/new/choose
Consider creating an issue using the following link: https://github.com/tuist/tuist/issues/new/choose

macOS version

14.2.1

Tuist version

4.5.0

Xcode version

15.2

@kapitoshka438 kapitoshka438 added the type:bug Something isn't working label Mar 5, 2024
@kapitoshka438 kapitoshka438 changed the title 'tuist cache' fails tuist cache fails Mar 5, 2024
@pepicrft
Copy link
Contributor

pepicrft commented Mar 5, 2024

Thanks for reporting this @kapitoshka438. We'll look into it.

@fortmarek
Copy link
Member

Can you try running tuist clean? If that doesn't help, a repro project would be really helpful!

@kapitoshka438
Copy link
Contributor Author

@fortmarek here is what I found. You can reproduce the error by adding SwiftLint SPM dependency to the app_with_spm_dependencies fixture.

.package(url: "https://github.com/realm/SwiftLint", exact: "0.54.0")

@fortmarek
Copy link
Member

Thanks, that's really useful. We'll look into it!

@kapitoshka438
Copy link
Contributor Author

I forgot to mention that SwiftLint is included as a target dependency this way:
.package(product: "SwiftLintPlugin", type: .plugin)

@fortmarek
Copy link
Member

I see – tuist generate still should not fail in this instance but you're not supposed to put plugins into the Tuist/Package.swift, instead add them as packages in your Project.swift. This is because we currently don't support build plugins with the native Tuist integration, so we need to fallback on SPM integration.

We plan to fix that soon, but for the time being, you'll need to follow the steps that I mentioned.

@kapitoshka438
Copy link
Contributor Author

The reason why I put SwiftLint into Tuist/Package.swift is that I need to run linting both on build phase and on CI pipelines before building the app using Fastlane. So, with Tuist 4.4.0 this way works for me very well:
Tuist/Package.swift:

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "PackageName",
    dependencies: [
        ...
        .package(url: "https://github.com/realm/SwiftLint", exact: "0.54.0")
    ]
)

Tuist project's target dependencies:

.package(product: "SwiftLintPlugin", type: .plugin)

Tuist project's target scripts:

scripts: [
    .pre(script: "Tuist/.build/artifacts/swiftlint/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.54.0-macos/bin/swiftlint",
    name: "SwiftLint",
    basedOnDependencyAnalysis: false)
],

Fastfile:

lane :swiftlint_local do
    swiftlint(
      executable: 'Tuist/.build/artifacts/swiftlint/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.54.0-macos/bin/swiftlint',
      mode: :lint,
      strict: true,
      quiet: true
    )
  end

Moving the SwiftLint dependency to Project.swift won't allow to build the swiftlint binary. I know I can install SwiftLint using mise by adding it to .mise.toml but there will be another issue of figuring out how to mise activate in Xcode build phase script to get access to the binary.

@fortmarek
Copy link
Member

Moving the SwiftLint dependency to Project.swift won't allow to build the swiftlint binary. I know I can install SwiftLint using mise by adding it to .mise.toml but there will be another issue of figuring out how to mise activate in Xcode build phase script to get access to the binary.

There's dedicated documentation how to use mise inside Xcode which I'd recommend instead: https://mise.jdx.dev/ide-integration.html#xcode

We will still look into the error, however.

@kapitoshka438
Copy link
Contributor Author

kapitoshka438 commented Mar 7, 2024

Thank you for the info. I was able to move SwiftLint to mise and make it work in Xcode build phase. Taking into account that we install mise via Homebrew and have both Intel and M1 CI runners, mise location may differ. This is our solution:

if test -d "/opt/homebrew/bin/"; then
  PATH="/opt/homebrew/bin/:${PATH}"
fi
# no need to add PATH for mise installed in /usr/local/bin 
mise exec swiftlint -- swiftlint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants