Brightify / Cuckoo

Boilerplate-free mocking framework for Swift!
MIT License
1.67k stars 172 forks source link

Use Cuckoo in product target? #455

Closed Velin92 closed 5 months ago

Velin92 commented 1 year ago

Is it possible to use Cuckoo in a product target using SPM?

In our project we usually use Mocks not only in UnitTests but also to render swift ui views previews, and for UI testing. Would it be possible for the generated mocks to be used in the main target of the application?

I tried something similiar by adding the SPM to the product target and generating the mocks without using the --testable option, and importing them in the product target but I get the No such module 'Cuckoo' error.

MatyasKriz commented 1 year ago

Hey, Cuckoo depends on XCTest, so I don't believe this is possible. Not sure though, as I've never tried it.

amgdev9 commented 1 year ago

It does not work, it fails at linking because of undefined references to XCTest stuff. Would it be possible to have two separate packages, one for the mock customization stuff and other one with parts dependant on XCTest? That way we could use this library on SwiftUI previews without a problem, for example to mock an ObservableObject