Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker Error : Library not found #615

Closed
wm-j-ray opened this issue Jul 12, 2015 · 19 comments
Closed

Linker Error : Library not found #615

wm-j-ray opened this issue Jul 12, 2015 · 19 comments
Labels

Comments

@wm-j-ray
Copy link

@wm-j-ray wm-j-ray commented Jul 12, 2015

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
Copy link
Member

@mdiep 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
Copy link
Author

@wm-j-ray wm-j-ray commented 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

@mdiep
Copy link
Member

@mdiep mdiep commented Jul 12, 2015

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

@wm-j-ray
Copy link
Author

@wm-j-ray wm-j-ray commented 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.

@ikesyo
Copy link
Member

@ikesyo 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
Copy link
Author

@wm-j-ray wm-j-ray commented Jul 13, 2015

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

@ikesyo
Copy link
Member

@ikesyo 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
Copy link
Member

@ikesyo 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
Copy link
Author

@wm-j-ray wm-j-ray commented 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...

@ikesyo
Copy link
Member

@ikesyo 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
Copy link
Member

@ikesyo 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
Copy link
Author

@wm-j-ray wm-j-ray commented 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?

@marlowcharite
Copy link

@marlowcharite marlowcharite commented 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

@wm-j-ray
Copy link
Author

@wm-j-ray wm-j-ray commented Jul 13, 2015

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
Copy link
Member

@mdiep mdiep commented Jul 13, 2015

Thanks for helping out on this, @ikesyo!

@Gopitech21
Copy link

@Gopitech21 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
Bug: 'Embed Frameworks' is missing from Build Phase

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

@nicolas-miari nicolas-miari commented 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.

@JohnTheBastard
Copy link

@JohnTheBastard JohnTheBastard commented 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.

@seljabali
Copy link

@seljabali seljabali commented Jan 1, 2020

My mistake: The Run Script which did /usr/local/bin/carthage copy-frameworks had additional logic in there. I created a new Run Script and moved that additional logic into it instead.

@Carthage Carthage locked as resolved and limited conversation to collaborators Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.