tuist: Generated assets @available markers break compilation on Xcode 14

What happened?

We introduced a .colorset into our xcassets. When generating the project using Tuist, the generated assets swift file contains code that doesn’t compile under Xcode 14.

How do we reproduce it?

  1. Use this project
  2. Run tuist generate -n
  3. The TuistAssets+DemoApp.swift file will contain the following sections of code which will produce Xcode errors:
  #if canImport(SwiftUI)
  @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
  public private(set) lazy var swiftUIColor: SwiftUI.Color = {
    SwiftUI.Color(asset: self)
  }()
  #endif

Error: Stored properties cannot be marked potentially unavailable with ‘@available

#if canImport(SwiftUI)
public extension SwiftUI.Color {
  @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
  init(asset: DemoAppColors) {
    let bundle = DemoAppResources.bundle
    self.init(asset.name, bundle: bundle)
  }
}
#endif

Error: ‘Color’ is only available in iOS 13.0 or newer

Error log

Written above.

macOS version

13.0.1

Tuist version

3.15.0

Xcode version

14.2.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 20

Most upvoted comments

How about using my demo project? When using tuist 3.12.1, it compiles successfully, and fails to compile on 3.15.0.

I realize now that in the initial description I haven’t mentioned that the deployment target needs to be lower than 13 for this to reproduce. So @danyf90 I apologize for the bad collaboration on the issue

Thanks! That’s why it’s better to use a sample project 😜