ChimeHQ / UITestingPlus

Utilities for working with XCUI testing
BSD 3-Clause "New" or "Revised" License
38 stars 2 forks source link

ld: warning: Could not find or use auto-linked framework 'XCTest' #4

Closed chrisvasselli closed 1 year ago

chrisvasselli commented 1 year ago

When I added the package locally, I didn't have any trouble using it. But when I tried to add it as a dependency using SPM, I get linker errors (see below).

Per some googling, updating my own project to enable the build setting "Enable Testing Search Paths" did seem to fix the issue. But it feels like there should be a solution that doesn't require modifying a build setting on the target project.

I tried adding swiftSettings: [.define("ENABLE_TESTING_SEARCH_PATHS")] to Package.swift but it didn't seem to fix the issue. I also tried updating the Package.swift to add linkerSettings: [ .linkedFramework("XCTest")] to the UITestingPlus target, but that led to a ld: framework not found XCTest error instead.

I'm not an SPM expert, so I could use some help figuring out what the appropriate solution is.


Ld /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/Nihongo.app/Nihongo normal (in target 'StudyJapanese' from project 'StudyJapanese')
    cd /Users/chris/Code/SerpentiSei/StudyJapanese
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios15.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -L/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk/usr/lib/swift -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PackageFrameworks -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/AMPopTip -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/ARChromeActivity -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/CHCSVParser-iOS -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/CocoaLumberjack -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/DeviceKit-iOS14.0 -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/Down -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/Ensembles -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/FMDB-iOS -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/Introspect-iOS14.0 -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/KINWebBrowser -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/MLPAutoCompleteTextField -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/MZAppearance -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/MZFormSheetPresentationController -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PocketSVG -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/PromisesObjC -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/RevenueCat -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/SSZipArchive-iOS -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/SimulatorStatusMagic -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/SwifterSwift -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/TTTAttributedLabel -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/TUSafariActivity -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/UIColor-Utilities -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/WrappingHStack-iOS14.0 -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/nanopb -F/Users/chris/Code/SerpentiSei/StudyJapanese/Pods/OpenSSL-Universal/Frameworks -F/Users/chris/Code/SerpentiSei/StudyJapanese/Pods/Reveal-SDK/RevealServer -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/XCFrameworkIntermediates/OpenSSL-Universal -F/Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/XCFrameworkIntermediates/Reveal-SDK -filelist /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Objects-normal/arm64/Nihongo.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Objects-normal-ubsan/arm64/Nihongo_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -debug_variant -fobjc-arc -fobjc-link-runtime -fsanitize\=undefined -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Objects-normal-ubsan/arm64/StudyJapanese.swiftmodule -ObjC -all_load -liconv -lsqlite3 -lstdc++ -lxml2 -lz -framework AMPopTip -framework ARChromeActivity -framework CFNetwork -framework CHCSVParser -framework CloudKit -framework CocoaLumberjack -framework CoreData -framework CoreGraphics -framework CoreText -framework DeviceKit -framework Down -framework Ensembles -framework FBLPromises -framework FMDB -framework Introspect -framework KINWebBrowser -framework MLPAutoCompleteTextField -framework MZAppearance -framework MZFormSheetPresentationController -framework OpenSSL -framework PocketSVG -framework QuartzCore -framework RevealServer -framework RevenueCat -framework SSZipArchive -framework Security -framework SimulatorStatusMagic -framework StoreKit -framework SwifterSwift -framework TTTAttributedLabel -framework TUSafariActivity -framework UIColor_Utilities -framework UIKit -framework WrappingHStack -framework nanopb -weak_framework SwiftUI -weak_framework WebKit -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Nihongo.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Nihongo.app-Simulated.xcent.der -lz -lsqlite3 -framework SystemConfiguration -framework Security -framework CloudKit -lxml2 -framework Tokenizer -framework DictionaryFramework -framework Pods_AllTargets_iOS_NihongoAppAndVariants_StudyJapanese -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/StudyJapanese.build/Objects-normal-ubsan/arm64/Nihongo_dependency_info.dat -o /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Products/Light-iphonesimulator/Nihongo.app/Nihongo -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/UITestingPlus.build/Light-iphonesimulator/UITestingPlus.build/Objects-normal-ubsan/arm64/UITestingPlus.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/swift-collections.build/Light-iphonesimulator/Collections.build/Objects-normal-ubsan/arm64/Collections.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/swift-collections.build/Light-iphonesimulator/DequeModule.build/Objects-normal-ubsan/arm64/DequeModule.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/swift-collections.build/Light-iphonesimulator/OrderedCollections.build/Objects-normal-ubsan/arm64/OrderedCollections.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/swift-algorithms.build/Light-iphonesimulator/Algorithms.build/Objects-normal-ubsan/arm64/Algorithms.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/swift-numerics.build/Light-iphonesimulator/RealModule.build/Objects-normal-ubsan/arm64/RealModule.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/TelemetryClient.build/Light-iphonesimulator/TelemetryClient.build/Objects-normal-ubsan/arm64/TelemetryClient.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/AnimationSequence.build/Light-iphonesimulator/AnimationSequence.build/Objects-normal-ubsan/arm64/AnimationSequence.swiftmodule

ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture arm64:
  "_$s6XCTest7XCTFail_4file4lineySS_s12StaticStringVSutF", referenced from:
      _$sSo11XCUIElementC13UITestingPlusE11stringValue2inSSSo8_NSRangeVSg_tKF in UITestingPlus.o
  "_OBJC_CLASS_$_XCTNSPredicateExpectation", referenced from:
      objc-class-ref in UITestingPlus.o
      _$s13UITestingPlus26HittableElementExpectationCN in UITestingPlus.o
  "_OBJC_CLASS_$_XCTWaiter", referenced from:
      objc-class-ref in UITestingPlus.o
  "_OBJC_CLASS_$_XCTestExpectation", referenced from:
      objc-class-ref in UITestingPlus.o
  "_OBJC_CLASS_$_XCUIApplication", referenced from:
      objc-class-ref in UITestingPlus.o
  "_OBJC_CLASS_$_XCUIElement", referenced from:
      objc-class-ref in UITestingPlus.o
  "_OBJC_METACLASS_$_XCTNSPredicateExpectation", referenced from:
      _OBJC_METACLASS_$__TtC13UITestingPlus26HittableElementExpectation in UITestingPlus.o
  "_XCUIIdentifierCloseWindow", referenced from:
      _$sSo11XCUIElementC13UITestingPlusE17closeWindowButtonABvg in UITestingPlus.o
  "__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
      __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_UITestingPlus in UITestingPlus.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)```
chrisvasselli commented 1 year ago

Never mind. I realized the package was automatically linked to my main app target, which was causing the issue. As soon as I removed that link (and only linked it to my UI test targets) this issue went away.

mattmassicotte commented 1 year ago

Ah yes, this is a little trap for testing-only packages. It is possible to select the right target in your project, but it's very easy to miss it. Very glad you figured this out so quickly.