Closed roksollc closed 3 years ago
I believe the problem is that XCTest
is imported in XCTest+Mocker.swift
, which is part of the Sources
folder.
@roksollc you've probably added Mocker
to your main target. XCTest
is only available from test targets and Mocker
is designed to be used within tests only.
The easiest fix would be to reintegrate Mocker
using SPM and making sure the selected target in the final step is set to your test target:
That's a shame you're pigeon-holing the product, as we were using it as a means to run/test our app for new features w/o using bandwidth. I never encountered anything that suggested the product was meant solely for XCTest usage...and it wasn't forced that way until the recent changes.
@roksollc I would be open to support that scenario, I was assuming nobody would use it that way.
If we can find a way to support both I would be happy to approve any PR for that! Main issue would be to only include XCTest for test targets.
#if canImport(XCText)
could do the trick 👌 we will make a PR for that since we are also using this really nice library for our UITests.
@iGranDav in that case I'm reopening this issue so that it can be closed with your PR!
May also be resolved by changing build options ENABLE_TESTING_SEARCH_PATHS to YES
This issue is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.
This never made it into the lib did it? Would be great to use mocker for an app that needs a "demo" mode to work without a backend.
if canImport(XCText) could do the trick 👌 we will make a PR for that since we are also using this really nice library for our UITests.
Nope..#if canImport(XCText)
will always be true, even if ENABLE_TESTING_SEARCH_PATHS
is not set.
Adding ENABLE_TESTING_SEARCH_PATHS
to the build options indeed seems to work... but, it will stop all your SwiftUI previews from compiling 😞
I've forked the project for now, removing XCTest https://github.com/WeTransfer/Mocker/compare/master...teameh:Mocker:without-xctest for a version that can be used in main targets to mock the network for using in demo modes.
could you PR this? i'm only using Mocker for SwiftUI previews, so my main targets depend on it. i can't set ENABLE_TESTING_SEARCH_PATHS
to false, since it would break those previews
Undefined symbol: __swift_FORCE_LOAD_$_XCTestSwiftSupport
Using version 2.2.0, no error results.