I'm having issues running xcTests after importing the SnapshotTesting framework available from -> https://github.com/pointfreeco/swift-snapshot-testing#installation
The build succeeds but the test fails
I always get a "Symbol not found: " saying it expected to find it in ....Frameworks/libswiftCore.dylib
e.g.
2018-12-11 17:39:48.799290+1100 Life[38438:3178136] Failed to load test bundle from file:///Users/garrypugh/Library/Developer/Xcode/DerivedData/Life-cowbtmytjcqvmqgvgonauprqpbpa/Build/Products/Debug-iphonesimulator/Life.app/PlugIns/LifeTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Users/garrypugh/Library/Developer/Xcode/DerivedData/Life-cowbtmytjcqvmqgvgonauprqpbpa/Build/Products/Debug-iphonesimulator/Life.app/PlugIns/LifeTests.xctest/LifeTests, 265): Symbol not found: _$SSS8UTF8ViewVs8SequencesWP Referenced from: /Users/garrypugh/Library/Developer/Xcode/DerivedData/Life-cowbtmytjcqvmqgvgonauprqpbpa/Build/Products/Debug-iphonesimulator/Life.app/PlugIns/LifeTests.xctest/Frameworks/SnapshotTesting.framework/SnapshotTesting Expected in: /Users/garrypugh/Library/Developer/CoreSimulator/Devices/BA4AAED2-B310-4590-BCEB-AF28312A0B35/data/Containers/Bundle/Application/A7A23001-D0C6-47C9-ADED-F31A1136A0BB/Life.app/Frameworks/libswiftCore.dylib
I have followed the Carthage Instructions here ->
https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos
and here ->
https://github.com/Carthage/Carthage#adding-frameworks-to-unit-tests-or-a-framework
And have successfully (seemingly) downloaded and built the frameworks
Set up Cartfile
Run carthage update - which built the 3 frameworks (Mac, iOS, tvOS) i.e. SnapshotTesting.framework and their related SnapshotTesting.framework .dSYM files
Then when attempting to include this in the Testing Target of my iOS App I followed the following steps
Dragged the iOS SnapshotTesting.framework file to the Build Phases - Link Binary with Libraries Section
Added a /usr/local/bin/carthage copy-frameworks with
Input Files $(SRCROOT)/Carthage/Build/iOS/SnapshotTesting.framework
Output Files $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SnapshotTesting.framework
I have ensured that my Runpath Search Paths (within Build Settings tab) has -> @loader_path/Frameworks
I am running Xcode 10.1
I'm not sure if this is a Issue with
Carthage setup
The SnapshotTesting framework
My build settings in Xcode
Or a restriction with dynamic verses static frameworks?
I have tried a few variations on locations of the Input / Output files, running the the Runscript before and after the Link Binary Section
Does anyone recognise this issue, Is there some other build settings that need to change enable this to work.
Problem Solved
First, Don't drag and drop the carthage generated framework to the Test Target / Build Phases (tab) Link Binary With Libraries (section). Instead use the + button and "Add Other" navigating to the .../Carthage/Build/iOS and choose the framework file in question. Delete the .framework file if you have previously dragged it (and it copied it into the directory)
Second, Add a New Copy Files section in the Build Phases Tab (Last step) with a Destination of Frameworks. Again use the + button to select the SnapshotTesting.framework within Carthage/Build/iOS Remove the Run Script Phase - With - "/usr/local/bin/carthage copy-frameworks" if you have previously added it.
Thanks to the guys at www.pointfree.co