Brightify / Cuckoo

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

[Suggestion] Improved SPM Installation Process #370

Closed jchitel closed 6 months ago

jchitel commented 4 years ago

Today, my project's build failed in CI because of a problem downloading the cuckoo_generator executable in the run script. I'm not sure what the actual issue was (there was an issue extracting the URL from the GH API response), but it started working again by itself sometime later, so I'm assuming that it was a GH blip.

I find it a little strange that the SPM installation for Cuckoo depends on an ad hoc process to download the generator executable. Obviously I could improve this for my project by removing the --download flag from the run command and depend on the cuckoo_generator executable always being there, but it seems like there should be a better process here.

Ideally, in the perfect world scenario, we should be able to add the dependency and all of the necessary files would be accessible locally. As far as I'm aware, this is exactly how it works for CocoaPods and Carthage, and it's only SPM that requires the extra download step. Correct me if I'm wrong, but the problem seems to lie in the fact that CocoaPods and Carthage put the installed packages in a directory relative to the project, while SPM puts them in DerivedData, which makes it difficult to resolve the installation path.

I went through the thread in #173 (specifically this comment) and it seems like it should be possible to just run the generator directly from source, or at least to include the executable in the package. Surely Xcode provides a way to resolve the SPM installation path?

I'm not going to pretend to be an expert on SPM, but I just wanted to start the conversation to try to improve the developer experience here.

nicofrancken commented 1 year ago

It would be nice if the cuckoo_generator would be supplied as a swift package manager build plugin. Maybe that also solves the current issues with the run script. SPM plugin docs: https://github.com/apple/swift-package-manager/blob/main/Documentation/Plugins.md

MatyasKriz commented 1 year ago

Hey, @nicofrancken. Yes, there's an abandnoned PR that set out to do just that. It's also something I'd like to include, but I'm not done with the rewrite to SwiftSyntax yet.

MatyasKriz commented 6 months ago

Cuckoo 2.0 supports running the generator as a SPM plugin now. 🙂

nalounguyen commented 2 months ago

Cuckoo 2.0 supports running the generator as a SPM plugin now. 🙂

how can I use it ?

MatyasKriz commented 2 months ago

Cuckoo 2.0 supports running the generator as a SPM plugin now. 🙂

how can I use it ?

Take a look at the readme: https://github.com/Brightify/Cuckoo?tab=readme-ov-file#swift-package-manager