Mocking a protocol I another project
Allje opened this issue · comments
I have a Xcode workspace that includes two Xcode projects. The structure following
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
- Mockingbird CLI version (
mockingbird version
): 0.17.0 - Xcode and macOS version (are you running a beta?): Xcode: 12.5.1, macOS: 11.5.2
- Swift version (
swift --version
): Apple Swift version 5.4.2 - Installation method (CocoaPods, Carthage, from source, etc): CocoaPods
- Unit testing framework (XCTest, Quick + Nimble, etc): XCTest
- Does your project use
.mockingbird-ignore
? No - Are you using supporting source files? No
You can modify the configured build phase (or manually add another one) to invoke the generator with the --project
option.
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?
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.