Linker Error : Library not found #615

Closed
wm-j-ray opened this Issue Jul 12, 2015 · 18 comments

Comments

Projects
None yet
7 participants
@wm-j-ray

IOS 9 Target, Xcode beta 3 Build: 7A152u, simple Cartfile:

github "ReactiveCocoa/ReactiveCocoa" ~> 2.5

Library builds fine in Carthage/Build/IOS -> ReactiveCocoa.framework which is dragged and dropped into Target : Link With Libraries

RunScript:

/usr/local/bin/carthage copy-frameworks

InputFiles:

$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework

Yields This:

export IPHONEOS_DEPLOYMENT_TARGET=9.0
export     PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -L/Users/wmjray/Library/Developer/Xcode/DerivedData/test-dbfnrebkrpsfsbbdlhynjwvxttrj/Build/Products/Debug-iphonesimulator -F/Users/wmjray/Library/Developer/Xcode/DerivedData/test-dbfnrebkrpsfsbbdlhynjwvxttrj/Build/Products/Debug-iphonesimulator -filelist /Users/wmjray/Library/Developer/Xcode/DerivedData/test-dbfnrebkrpsfsbbdlhynjwvxttrj/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Objects-normal/x86_64/test.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.0 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -framework ReactiveCocoa -Xlinker -dependency_info -Xlinker /Users/wmjray/Library/Developer/Xcode/DerivedData/test-dbfnrebkrpsfsbbdlhynjwvxttrj/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Objects-normal/x86_64/test_dependency_info.dat -o /Users/wmjray/Library/Developer/Xcode/DerivedData/test-dbfnrebkrpsfsbbdlhynjwvxttrj/Build/Products/Debug-iphonesimulator/test.app/test

ld: framework not found ReactiveCocoa
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Question: Any idea where I'm messing up?

@mdiep

This comment has been minimized.

Show comment
Hide comment
@mdiep

mdiep Jul 12, 2015

Member

ReactiveCocoa.framework which is dragged and dropped into Target : Link With Libraries

From the error, it sounds like the problem was here. Maybe double check that it was added to the right target?

Member

mdiep commented Jul 12, 2015

ReactiveCocoa.framework which is dragged and dropped into Target : Link With Libraries

From the error, it sounds like the problem was here. Maybe double check that it was added to the right target?

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 12, 2015

Thanks,

I'm trying to run Colin Eberhardt's tutorial from here: http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 but without the Cocoapods...

Here's what I've got...

screen shot 2015-07-12 at 3 29 05 pm

Thanks,

I'm trying to run Colin Eberhardt's tutorial from here: http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 but without the Cocoapods...

Here's what I've got...

screen shot 2015-07-12 at 3 29 05 pm

@mdiep

This comment has been minimized.

Show comment
Hide comment
@mdiep

mdiep Jul 12, 2015

Member

Are you getting the ld error when the copy-frameworks script is run?

Member

mdiep commented Jul 12, 2015

Are you getting the ld error when the copy-frameworks script is run?

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 12, 2015

I don't think it makes it that far in the build process. It's confusing me. So I ran an experiment to verify that the script was indeed executing.

I removed the library, got rid of the input file setting for the script, and replaced the copy-frameworks with a simple echo to see if the script ran (checking View:Navigators:Reports Navigator). Simple script, one line - echo "Script ran". Built and ran fine, and the echo shows up on the report navigator. (I thought that maybe my bin/sh got screwed up some how, but alas, no...)

Then I put everything back in, the library, the input file and added a 2nd line to the script (copy frameworks), and left the echo in at line 1, so now I have a simple 2 line script. Cleaned.

When I tried to build I almost immediately got the framework not found abort and in the Report Navigator, there is no echo statement. (So I am assuming she didn't make it that far into the build)

This is the freshest version of xCode under IOS 9. I'm a little perplexed.

I don't think it makes it that far in the build process. It's confusing me. So I ran an experiment to verify that the script was indeed executing.

I removed the library, got rid of the input file setting for the script, and replaced the copy-frameworks with a simple echo to see if the script ran (checking View:Navigators:Reports Navigator). Simple script, one line - echo "Script ran". Built and ran fine, and the echo shows up on the report navigator. (I thought that maybe my bin/sh got screwed up some how, but alas, no...)

Then I put everything back in, the library, the input file and added a 2nd line to the script (copy frameworks), and left the echo in at line 1, so now I have a simple 2 line script. Cleaned.

When I tried to build I almost immediately got the framework not found abort and in the Report Navigator, there is no echo statement. (So I am assuming she didn't make it that far into the build)

This is the freshest version of xCode under IOS 9. I'm a little perplexed.

@ikesyo

This comment has been minimized.

Show comment
Hide comment
@ikesyo

ikesyo Jul 13, 2015

Member

What is the value of FRAMEWORK_SEARCH_PATHS? It seems that the setting is not correctly set up.

Member

ikesyo commented Jul 13, 2015

What is the value of FRAMEWORK_SEARCH_PATHS? It seems that the setting is not correctly set up.

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 13, 2015

FRAMEWORK_SEARCH_PATHS = $(SDKROOT)/Developer/Library/Frameworks $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)

FRAMEWORK_SEARCH_PATHS = $(SDKROOT)/Developer/Library/Frameworks $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)

@ikesyo

This comment has been minimized.

Show comment
Hide comment
@ikesyo

ikesyo Jul 13, 2015

Member

How about if you add $(SRCROOT)/Carthage/Build/iOS to FRAMEWORK_SEARCH_PATHS? Although I don't know why the path doesn't exist in the setting (it would be added by adding a framework to "Link Binary With Libraries"), this should work I think.

Member

ikesyo commented Jul 13, 2015

How about if you add $(SRCROOT)/Carthage/Build/iOS to FRAMEWORK_SEARCH_PATHS? Although I don't know why the path doesn't exist in the setting (it would be added by adding a framework to "Link Binary With Libraries"), this should work I think.

@ikesyo

This comment has been minimized.

Show comment
Hide comment
@ikesyo

ikesyo Jul 13, 2015

Member

(it would be added by adding a framework to "Link Binary With Libraries")

This is not the case for at least Xcode 7 beta 3, that might be an Xcode bug. 😲

Member

ikesyo commented Jul 13, 2015

(it would be added by adding a framework to "Link Binary With Libraries")

This is not the case for at least Xcode 7 beta 3, that might be an Xcode bug. 😲

@ikesyo ikesyo added the question label Jul 13, 2015

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 13, 2015

Added $(SRCROOT)/Carthage/Build/iOS to FRAMEWORK_SEARCH_PATHS

Now she compiles but I get:

dyld: Library not loaded: @rpath/ReactiveCocoa.framework/ReactiveCocoa
  Referenced from: /Users/wmjray/Library/Developer/CoreSimulator/Devices/57501A15-C011-400D-9E9F-74BBC34EBAF2/data/Containers/Bundle/Application/E0CC903E-17CA-4BE9-88D2-6240D1C236FF/RWReactivePlayground.app/RWReactivePlayground

As an aside, over the night I completely de-installed xCode Beta-3, fried developer directories, etc., and re-downloaded and installed Version 7.0 beta 3 (7A152u. Also ran xCode : Open developer tool : simulator to make sure was talking to the proper simulator instance.

Still quite perplexed...

Added $(SRCROOT)/Carthage/Build/iOS to FRAMEWORK_SEARCH_PATHS

Now she compiles but I get:

dyld: Library not loaded: @rpath/ReactiveCocoa.framework/ReactiveCocoa
  Referenced from: /Users/wmjray/Library/Developer/CoreSimulator/Devices/57501A15-C011-400D-9E9F-74BBC34EBAF2/data/Containers/Bundle/Application/E0CC903E-17CA-4BE9-88D2-6240D1C236FF/RWReactivePlayground.app/RWReactivePlayground

As an aside, over the night I completely de-installed xCode Beta-3, fried developer directories, etc., and re-downloaded and installed Version 7.0 beta 3 (7A152u. Also ran xCode : Open developer tool : simulator to make sure was talking to the proper simulator instance.

Still quite perplexed...

@ikesyo

This comment has been minimized.

Show comment
Hide comment
@ikesyo

ikesyo Jul 13, 2015

Member

Is there the Embed Frameworks build phase? If there isn't, you should add a new "Copy Files Phase", then select "Framrworks" for Destination, add frameworks to the list, and check "Code Sign On Copy" checkboxes.

EDITED: You should also add $(inherited) @executable_path/Frameworks to "Runpath Search Paths" setting. Because the sample/starter project you are using is a bit old (dynamic framework is introduced in Xcode 6/iOS 8, but the project was created by Xcode 5), those settings required for using dynamic frameworks are not set up.

Member

ikesyo commented Jul 13, 2015

Is there the Embed Frameworks build phase? If there isn't, you should add a new "Copy Files Phase", then select "Framrworks" for Destination, add frameworks to the list, and check "Code Sign On Copy" checkboxes.

EDITED: You should also add $(inherited) @executable_path/Frameworks to "Runpath Search Paths" setting. Because the sample/starter project you are using is a bit old (dynamic framework is introduced in Xcode 6/iOS 8, but the project was created by Xcode 5), those settings required for using dynamic frameworks are not set up.

@ikesyo

This comment has been minimized.

Show comment
Hide comment
@ikesyo

ikesyo Jul 13, 2015

Member

@wm-j-ray I've successfully compiled the starter project with the way in my latest comment. Could you please check that?

Member

ikesyo commented Jul 13, 2015

@wm-j-ray I've successfully compiled the starter project with the way in my latest comment. Could you please check that?

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 13, 2015

The starter project from here?

I'm trying to run Colin Eberhardt's tutorial from here: http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 but without the Cocoapods...

I made the change per your comment and I'm still getting the not loaded error. (I feel like a #@! Xcode noobie). Can you zip up that project and email it so I can finally see where I'm screwing up?

The starter project from here?

I'm trying to run Colin Eberhardt's tutorial from here: http://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 but without the Cocoapods...

I made the change per your comment and I'm still getting the not loaded error. (I feel like a #@! Xcode noobie). Can you zip up that project and email it so I can finally see where I'm screwing up?

@marlowcharite

This comment has been minimized.

Show comment
Hide comment
@marlowcharite

marlowcharite Jul 13, 2015

I was having the same issue. Seems that drag & dropping the frameworks from carthage was not also adding the $(SRCROOT)/Carthage/Build/iOS into the frameworks search path. Once I added that I was able to build and run

I was having the same issue. Seems that drag & dropping the frameworks from carthage was not also adding the $(SRCROOT)/Carthage/Build/iOS into the frameworks search path. Once I added that I was able to build and run

@wm-j-ray

This comment has been minimized.

Show comment
Hide comment
@wm-j-ray

wm-j-ray Jul 13, 2015

Confirmed. I want to thank all who helped out on this. I think we can close this one out.

Confirmed. I want to thank all who helped out on this. I think we can close this one out.

@wm-j-ray wm-j-ray closed this Jul 13, 2015

@mdiep

This comment has been minimized.

Show comment
Hide comment
@mdiep

mdiep Jul 13, 2015

Member

Thanks for helping out on this, @ikesyo!

Member

mdiep commented Jul 13, 2015

Thanks for helping out on this, @ikesyo!

@Gopitech21

This comment has been minimized.

Show comment
Hide comment
@Gopitech21

Gopitech21 Jun 9, 2016

I am facing the same issue "dyld: Library not loaded: @rpath/AlgoliaSearch.framework/AlgoliaSearch" . I am using xcode7.3, frameworks search path is et to = $(SRCROOT)/Carthage/Build/iOS, added add $(inherited) @executable_path/Frameworks to "Runpath Search Paths" settings. I am also having Pod file in the project, is this causing the issue ? can someone help me please.

Gopitech21 commented Jun 9, 2016

I am facing the same issue "dyld: Library not loaded: @rpath/AlgoliaSearch.framework/AlgoliaSearch" . I am using xcode7.3, frameworks search path is et to = $(SRCROOT)/Carthage/Build/iOS, added add $(inherited) @executable_path/Frameworks to "Runpath Search Paths" settings. I am also having Pod file in the project, is this causing the issue ? can someone help me please.

bonuelc added a commit to bonuelc/AdHawkSmartTipMockup that referenced this issue Aug 2, 2016

Fix 'Alamofire Library not loaded' bug
Bug: 'Embed Frameworks' is missing from Build Phase

Fix: Add a new 'Copy Files'Build Phase
Carthage/Carthage#615 (comment)
@nicolas-miari

This comment has been minimized.

Show comment
Hide comment
@nicolas-miari

nicolas-miari Dec 28, 2016

My 2 cents: Depending on where you have the Carthage directory relative to workspace/project etc. you might need to tweak the suggested Framework Search Path to (e.g.) $(SRCROOT)/../Carthage/Build/iOS.

My 2 cents: Depending on where you have the Carthage directory relative to workspace/project etc. you might need to tweak the suggested Framework Search Path to (e.g.) $(SRCROOT)/../Carthage/Build/iOS.

@JohnTheBastard

This comment has been minimized.

Show comment
Hide comment
@JohnTheBastard

JohnTheBastard Feb 5, 2018

I just wanted to point out that there are two stupid mistakes I have made that resulted in this error, in case it helps anyone that comes across this thread.

  • Once, in my build phase script, I accidentally cut and pasted /usr/local/bin/carthage copy-frameworks into the field for the shell (i.e. /bin/sh) instead of the correct field below it.

  • The other time, I accidentally made my Cartfile and and ran carthage update from the directory above my project file, instead of in the same directory, so the copy-frameworks script did not have a correct relative path to actually copy the frameworks.

I just wanted to point out that there are two stupid mistakes I have made that resulted in this error, in case it helps anyone that comes across this thread.

  • Once, in my build phase script, I accidentally cut and pasted /usr/local/bin/carthage copy-frameworks into the field for the shell (i.e. /bin/sh) instead of the correct field below it.

  • The other time, I accidentally made my Cartfile and and ran carthage update from the directory above my project file, instead of in the same directory, so the copy-frameworks script did not have a correct relative path to actually copy the frameworks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment