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:
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.
A symbol remains undefined when a symbol reference in a relocatable object is never matched to a symbol definition. Similarly, if a shared object is used to create a dynamic executable and leaves an unresolved symbol definition, an undefined symbol error results.
Why Is the Undefined Symbols for Architecture x86_64: Error Happening? This error is happening due to the lack of included values inside the declared statements in your code. The browser is going to render the information incorrectly and show this error, especially if you are working with Main and Similarity tools.
Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_xxx", referenced from: objc-class-ref in yyy.o. This generally means, you are calling "xxx" (it may be a framework or class) from the class "yyy". The compiler can not locate the "xxx" so this error occurs.
I was also troubled by the problem. To solve this problem, you may want to add -fprofile-instr-generate
to Build Settings > Linking > Other Linker Flags
.
This flag is an option used for coverage output. With this setting in my environment, I succeeded in enabling the preview while enabling the coverage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With