AliSoftware / OHHTTPStubs

Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
MIT License
5.03k stars 602 forks source link

Mocktail, HTTPMessage Support for SPM #340

Open fabrizioCorut opened 3 years ago

fabrizioCorut commented 3 years ago

Description

Mocktail and HTTPMessage features were not visible for users that drag OHTTPStubs as a dependency using Swift Package Manager because the default behaviour of Swift Package Manager is to compile all the sources that are found under: Sources/$(PACKAGE_NAME), hence, the only compiled sources were Sources/OHHTTPStubs. Sources/Mocktail and Sources/HTTPMessage were ignored.

Tests

While this is not that critical, the same principle applies for the Tests as well but I could not get it to work. Currently the Mocktail tests are not ran. Whatever I do, the Mocktail tests are not seeing the resources, even though I'm declaring them in the Package.swift file. Some help with this regard would be nice. It seems that the files are not found in the bundle.

I tried to keep the changeset to a minimum, sadly, with a custom path for the target we would have had to modify all the #include directives which are currently solved for free if you include all your headers in the include folder. Hence, the small change that I did include: • moving the Mocktail and HTTPMessage folders in the Sources/OHHTTPStubs folder; • moving the .h files in their include folders to Sources/OHHTTPStubs/include; • moving the core functionality (old OHHTTPStubs/*.m files) in a new folder: Sources/OHHTTPStubs/OHHTTPStubs so we keep the old structure; • updating the Xcode project to reflect the new hierarchy so it compiles;

Motivation and Context

The problem is descried in #331 ~ SPM users were not able to see the Mocktail and HTTPMessage functionalities because they were not included in the framework build process.

Final remarks

There is nothing to add to the README file since this was supposed to work out of the box. No credits needed, just moved some folders around.