Carthage: dyld: Library not loaded: @rpath/XCTest.framework/XCTest

Created on 18 Jan 2017  路  18Comments  路  Source: Carthage/Carthage

  • carthage version: 0.18.1
  • xcodebuild -version: Xcode 8.2.1 Build version 8C1002
  • Are you using --no-build? no
  • Are you using --no-use-binaries? no
  • Are you using --use-submodules? no

Cartfile

git "/Users/mhillebrand/work/app/SDK.git"
github "ReactiveX/RxSwift"
github "RxSwiftCommunity/RxAlamofire"
github "RxSwiftCommunity/RxDataSources"

Carthage Output

*** Fetching RxDataSources
*** Fetching RxAlamofire
*** Fetching RxSwift
*** Fetching SDK
*** Fetching Alamofire
*** Fetching Willow
*** Fetching PureLayout
*** Fetching AlamofireImage
*** Checking out Alamofire at "4.3.0"
*** Checking out AlamofireImage at "3.2.0"
*** Checking out PureLayout at "v3.0.2"
*** Downloading RxSwift.framework binary at "Galois"
*** Checking out RxAlamofire at "3.0.2"
*** Checking out RxDataSources at "1.0.2"
*** Checking out Willow at "3.0.0"
*** Checking out SDK at "0.1.2"
*** xcodebuild output can be found in /var/folders/ml/d9hzjcrd3mv_3hj_3qqf__brkdn63y/T/carthage-xcodebuild.MYiMkA.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "AlamofireImage iOS" in AlamofireImage.xcworkspace
*** Building scheme "PureLayout_iOS" in PureLayout.xcodeproj
*** Building scheme "RxAlamofire-iOS" in _.xcodeproj
*** Building scheme "RxDataSources-iOS" in RxDataSources.xcworkspace
*** Building scheme "Willow iOS" in Willow.xcworkspace
*** Building scheme "SDK" in SDK.xcodeproj
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
/Users/mhillebrand/work/app/Carthage/Checkouts/PureLayout/PureLayout/PureLayout/PureLayout+Internal.h:32:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated
warning: section "__textcoal_nt" is deprecated
warning: section "__const_coal" is deprecated

Xcode Console

dyld: Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /Users/mhillebrand/Library/Developer/CoreSimulator/Devices/0A21A5CF-49A8-4770-B5AF-6B17A3541E00/data/Containers/Bundle/Application/D5D8FF28-A388-40D1-8B4B-3DE33EADADEF/app.app/Frameworks/libswiftXCTest.dylib
  Reason: image not found
question

Most helpful comment

I figured it out. Installing RxSwift with Carthage also builds the RxBlocking and RxTest frameworks, which I foolishly included in my main target, rather than my test target. :)

All 18 comments

I should point out that my SDK is another dynamic framework Xcode project with its own Cartfile:

Embedded SDK Cartfile

github "Alamofire/Alamofire"
github "Alamofire/AlamofireImage"
github "PureLayout/PureLayout"
github "Nike-Inc/Willow"

If I bundle the iPhoneSimulator x86 version of XCTest.framework, my app works in the simulator but not on a device. Conversely, if I bundle the arm version of XCTest.framework, my app works on the device but not in the simulator.

I tried adding the framework search path $(PLATFORM_DIR)/Developer/Library/Frameworks as a hack, but it doesn't help.

What can I do? Why is Carthage even causing this? None of my unit tests are associated with my non-test targets. Argh.

Why are you bundling XCTest in your app?

Believe me, I don't want to bundle XCTest. Now that I'm using Carthage, though, my app is crashing with that messed up error message above. Something about Carthage is causing this. I didn't have this problem yesterday, when I was still using CocoaPods.

dyld: Library not loaded: @rpath/XCTest.framework/XCTest

Seems that you somehow link XCTest framework in your SDK.xcodeproj for your framework target, not for its test target. Carthage does not have any special logic related to XCTest.

@ikesyo Of course, I had the same thought when I saw this bizarre Carthage error and quickly proved it to be false. Nobody in their right mind would try to ship an app and/or framework that attempted to link Apple's XCTest framework.

If you could provide a minimal reproducible sample project that's really helpful. Without that we are quite not sure what's really happening. 馃槥

@ikesyo @mdiep Okay, I've created a watered-down version of the SDK and the App that consumes it, but now I'm getting a different dyld error at run time. What's worse is that it's intermittent:

dyld: Symbol not found: _CLSDevelopmentPlatformNameKey
  Referenced from: /Users/mhillebrand/Library/Developer/Xcode/DerivedData/App-hkyjqjvnovjldyexqpnjigxpeavo/Build/Products/Debug-iphonesimulator/SDK.framework/SDK
  Expected in: /Users/mhillebrand/Library/Developer/Xcode/DerivedData/App-hkyjqjvnovjldyexqpnjigxpeavo/Build/Products/Debug-iphonesimulator/SDK.framework/SDK
 in /Users/mhillebrand/Library/Developer/Xcode/DerivedData/App-hkyjqjvnovjldyexqpnjigxpeavo/Build/Products/Debug-iphonesimulator/SDK.framework/SDK
(lldb) 

Please note that I manually installed Crashlytics, Fabric, and GoogleInteractiveMediaAds into the SDK. I also had to use CocoaPods in the App for two dependencies that don't play nicely with Carthage, EVReflection and Google. Luckily, there were no dependency/naming collisions.

I really wish I could show you the actual code, but I don't think my employer would like that. Thanks in advance for any advice.

Weird. I removed an oddly placed SDK.framework entry, and now everything works fine. I guess I'll just recreate my SDK from scratch (again) and see if the problem persists.

This XCTest problem is still plaguing my real project. I think one of my QA coworkers did something kooky with schemes, but I can't for the life of me find the culprit. I think I'll just start a new project from scratch. I don't know why this issue didn't rear its ugly head while using CocoaPods. Anyway, thanks for your time! I'm digging Carthage. 馃憤

ARGH. I created everything from scratch, and the Xcode console is yielding the same bizarre error:

dyld: Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /Users/mhillebrand/Library/Developer/CoreSimulator/Devices/0A21A5CF-49A8-4770-B5AF-6B17A3541E00/data/Containers/Bundle/Application/D5D8FF28-A388-40D1-8B4B-3DE33EADADEF/app.app/Frameworks/libswiftXCTest.dylib
  Reason: image not found

I figured it out. Installing RxSwift with Carthage also builds the RxBlocking and RxTest frameworks, which I foolishly included in my main target, rather than my test target. :)

@mhillebrand money!

@mhillebrand thx! Since I'm not working with RX I had no idea of its frameworks.

@mhillebrand you saved my life, bro! Thanks so much!

@mhillebrand thanks!

@mhillebrand brand One more saved live over here!

@mhillebrand +1 thank you :)

Was this page helpful?
0 / 5 - 0 ratings