typealiased / mockingbird

A Swifty mocking framework for Swift and Objective-C.
https://mockingbirdswift.com
MIT License
657 stars 82 forks source link

Mocking a protocol I another project #223

Closed Allje closed 2 years ago

Allje commented 3 years ago

I have a Xcode workspace that includes two Xcode projects. The structure following

Mockingbird

I can install mockingbird for DeviceA with following command: iOSApplication/DeviceA$ mockingbird install -- target DeviceATests --source DeviceA

The problem is that DeviceA uses a protocol (ProtocolA) defined in the common folder and I can't install mockingbird for that interface. I have tried with following command iOSApplication/DeviceA$ mockingbird install -- target DeviceATests --source ../Common/Common but I get this error: malformedConfiguration(description: "Unable to find source target named \'../Common/Common\'")

I have also tried to use a absolute path to Common, but that also doesn't work. Is it not possible to mock a file from another project?

Environment

andrewchang-bird commented 3 years ago

You can modify the configured build phase (or manually add another one) to invoke the generator with the --project option.

Allje commented 3 years ago

I have looked at the links you specified, but I can't get it working.

Can you pls. provide an example of how to configure it with --project based on the example I provided?

andrewchang-bird commented 3 years ago

You would modify the run script build phase installed on DeviceATests to include a call to the generator similar to:

"${SRCROOT}/Pods/MockingbirdFramework/mockingbird" generate \
  --project "${SRCROOT}/Common/Common.xcodeproj" \
  --srcroot "${SRCROOT}/Common" \
  --targets Common \
  --output "${SRCROOT}/MockingbirdMocks/DeviceATests-CommonMocks.generated.swift"

And then update the Mockingbird build phase to include DeviceATests-CommonMocks.generated.swift as an output file + add it to the compile sources build phase.