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

Unit test case crashing on accessing generated code #19

Open
parvez-keeptruckin opened this issue Nov 22, 2023 · 2 comments
Open

Unit test case crashing on accessing generated code #19

parvez-keeptruckin opened this issue Nov 22, 2023 · 2 comments

Comments

@parvez-keeptruckin
Copy link

parvez-keeptruckin commented Nov 22, 2023

The testTarget is accessing Colour from generated code and thus crashing. The below code results in fatalError

@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *)
  public private(set) lazy var color: Color = {
    guard let color = Color(asset: self) else {
      fatalError("Unable to load color asset named \(name).")
    }
    return color
  }()

The swiftgen.yml file has bundle as Bundle.module. How to fix this issue ? Below is the Package.swift content:

let package = Package(
    name: "MyLibrary",
    defaultLocalization: "en",
    platforms: [
        .iOS(.v14)
    ],
    products: [
        .library(
            name: "MyLibrary",
            targets: ["MyLibrary"]),
    ],
    dependencies: [
        .package(url: "https://github.com/ReactiveX/RxSwift.git", from: ("6.5.0")),
        .package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.0"),
        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.52.4"),
        .package(url: "https://github.com/DaveWoodCom/XCGLogger.git", from: "7.0.1"),
        .package(url: "https://github.com/Quick/Nimble.git", from: "9.2.1")
    ],
    targets: [
        .target(
            name: "MyLibrary",
            dependencies: [
                "RxSwift",
                "XCGLogger",
                .product(name: "RxCocoa", package: "RxSwift")],
            resources: [
                .copy("Fonts"),
                .copy("GoogleMapTheme"),
                .copy("Assets")
            ],
            plugins: [.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin")]),
        .testTarget(
            name: "MyLibraryTests",
            dependencies: [
                "MyLibrary",
                "RxSwift",
                .product(name: "RxCocoa", package: "RxSwift"),
                "Nimble"],
            resources: [
                .embedInCode("CoreAssetsCatalog.swift") // <- accessing content of this file in unit test results in fatalError
            ]
        )
    ]
)
@aregler
Copy link

aregler commented Mar 16, 2024

Hey. Did you solve this issue?

@fruitcoder
Copy link

I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants