As of Xcode 11 using SwiftUI, it looks very difficult/no way to enable code coverage in unit tests and have preview working.
This is what I did:
- Select target -> Edit scheme in Xcode
- Select Test tab and under Options tab, select Gather coverage for some targets (only select the main target)
- Go to a SwiftUI file and preview stops working with following error. Please note you can still use the build option just fine.
And this is the error:
linker command failed with exit code 1 (use -v to see invocation)
failedToBuildDylib: ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator'
Undefined symbols for architecture x86_64:
"___llvm_profile_runtime", referenced from:
___llvm_profile_runtime_user in Pods_RadioDemo(Pods-RadioDemo-dummy.o)
(maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To get away from this issue, I can just turn off code coverage. Obviously that's not what I'm looking for. Please just show me how to get to the perfect world with both preview and code coverage working.
Just a bit of reference is here. Timmmm the good man had some insights on a very similar issue.