nalexn / ViewInspector

Runtime introspection and unit testing of SwiftUI views
MIT License
2.16k stars 148 forks source link

Unable to use with Xcode 15 #246

Closed ztolley closed 1 year ago

ztolley commented 1 year ago

If I try to create a new project and add viewInspector then the build fails.

Steps to reproduce:

The build fails with a message like the attached

ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes'
ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture arm64:
  "_$s6XCTest7XCTFail_4file4lineySS_s12StaticStringVSutF", referenced from:
      _$s7SwiftUI4ViewP0C9InspectorE7inspect8function4file4line10inspectionySS_s12StaticStringVSuyAD011InspectableC0VyAD0C4TypeVABVy_xGGKXEtF in ViewInspector.o
      _$s7SwiftUI12ViewModifierP0C9InspectorE7inspect8function4file4line10inspectionySS_s12StaticStringVSuyAD011InspectableC0VyAD0C4TypeVABVy_xGGKXEtF in ViewInspector.o
      _$s13ViewInspector18InspectionEmissaryPAAE5setup33_7842524499E11E7966421A3557BF3F7DLL10inspection11expectation8function4file4lineyy1VQzKc_So17XCTestExpectationCSSs12StaticStringVSutFyALcfU_ in ViewInspector.o
  "_OBJC_CLASS_$_XCTestExpectation", referenced from:
      objc-class-ref in ViewInspector.o
  "__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
      __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_ViewInspector in ViewInspector.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Screenshot 2023-06-10 at 19 19 57
Tyler-Keith-Thompson commented 1 year ago

Linker issues with XCTest are often caused by folks accidentally linking ViewInspector to their production code rather than their test target. Can you just double check whether that happened here?

nalexn commented 1 year ago

There were indeed issues with Xcode 15 and iOS 17 (resolved now with v0.9.7), but they were unrelated to the linker. I suspect Tyler is right, you should try re-integrating the library with the test target of your project.