问题
What is the proper way to use Carthage for dependency management, but also be able to write tests with it for types it pulls in. For example, (this is hypothetical) if I pull in AlamoFire and let’s say it has a Response protocol and different concrete types conform to the Response protocol. In my own library, if I were to do
@testable import AlamoFire
it would complain that Module ‘AlamoFire’ was not compiled for testing. Doing some research, I believe it’s because enable testability should be set to NO on release builds, which Carthage uses by default. Is there a way to use third party types like this in your test target?
回答1:
Use import
instead of @testable import
to access a module's public types.
Also in your test target's Build Phases, add AlamoFire to "Link Binary With Libraries"
来源:https://stackoverflow.com/questions/48388957/unit-testing-with-third-party-libraries-and-carthage