I have little to no knowledge about linking and referencing files/resources when it comes to compiled languages (I'm a Ruby programmer).
I'm trying my best using general tutorials on "how to add a framework to XCode 4 project", but I'm having a rough time trying to understand how am I supposed to do this, as everything I do fails in the end.
I've simply created a new cocoa application, went to build phases / Link Binary With Libraries and added Gosu.framework there. I didn't do anything else.
Now when I try to run the application, I get this error:
dyld: Library not loaded: #executable_path/../Frameworks/Gosu.framework/Versions/A/Gosu
Referenced from: /Users/ellmo/Library/Developer/Xcode/DerivedData/gosuTest-hkmqdspnwjepredgslldpnmuhlvx/Build/Products/Debug/gosuTest.app/Contents/MacOS/gosuTest
Reason: image not found
What should I do?
Related
So I followed this tutorial:
http://locomoviles.com/ios-tutorials/create-ios-cocoa-touch-framework-using-xcode/
Everything went fine except when I went to run the program I got the following error:
> dyld: Library not loaded:
> #rpath/SwiftFramework.framework/SwiftFramework Referenced from:
> /Users/bluke/Library/Developer/CoreSimulator/Devices/40677D10-F22B-4AE4-B767-06439AB7887A/data/Containers/Bundle/Application/8C6A5F76-C666-4B69-9353-A0ABD7DA085B/UseFramework.app/UseFramework
> Reason: image not found
I was able to solve this problem by adding the framework as an embedded binary, but I don't understand why this was needed to solve the problem.
I thought that the framework would be included in my application bundle as a dynamically linked library (i.e. not embedded in my application's binary directly) and then linked at run time. Is this assumption incorrect?
Just in case my question was unclear, I've added the following pictures.
This is what was producing the error:
If I add the framework to the embedded binaries it works:
I thought that the framework would be included in my application
bundle as a dynamically linked library (i.e. not embedded in my
application's binary directly) and then linked at run time. Is this
assumption incorrect?
Yes, it's incorrect. iOS apps link 3rd party frameworks statically, not dynamically. This prevents apps from downloading and dynamically linking code that hasn't been vetted by the app store review process.
This allows apps coded in Swift to run on devices running a version of iOS pre-dating Swift (earlier than iOS8).
Non-Apple frameworks can be embedded on iOS8 and above only.
It is also nice to add a prefix the the name identifying the developer organization so as to avoid comflicts and confusion. "SwiftFramework" looks so much like an Apple framework.
I want to use the libclang library included with Xcode to do some simple source code parsing.
This is how I do it.
Figure out the libclang.dylib using echoxcode-select --print-path/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
Copy the libclang.dylib file to my project folder.
Add it to a clean Xcode project (a Cocoa Application one).
Build and run the app
The built process runs fine but the app crash on start up with this error
dyld: Library not loaded: #rpath/libclang.dylib
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/ClassStructureAnalyzer-cthpbscauprydagysmerutpnhpua/Build/Products/Debug/ClassStructureAnalyzer.app/Contents/MacOS/ClassStructureAnalyzer
Reason: image not found
Adding the /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib to the runpath doesn't solve the problem.
I understand that this question may have been asked many times, but after googling for the whole day, I haven't figure out the answer yet :(
Thanks in advance!
So I've been working on a c++ project in XCode and am making use of an external framework (SFML http://www.sfml-dev.org/ ).
I recently decided to upload my project to github and then tried checking out the project on another Mac.
However, when I try to run my program on the new computer, I get this error
dyld: lazy symbol binding failed: can't resolve symbol __ZN2sf5ImageC1Ev in
/Users/myname/Library/Developer/Xcode/DerivedData/projectname-
fufhzxbkoeekzeayzzlrtvgajvnn/Build/Products/Debug/projectname because dependent
dylib #3 could not be loaded
I have no idea what this means and have been having a hard time finding out online what exactly the issue is.
That error message indicates that you are linking against a Shared Library (dylib) which is not available in the library path at run time when you are executing it.
If you have installed the framework in one of the standard locations (such as /Library/Frameworks) on your original build and in the same place when you checked it your and rebuilt, then you should be OK. However, there are some complexities to framework linking that can cause trouble if you are not careful, especially if you use embedded frameworks. It looks like you are not building an application, so I assume you're not embedding the framework.
Compare the installation locations of your frameworks on both the new and old computer and if they are not the same, that's likely your problem.
If things look like they are in the same place, you may need to check the DYLD_LIBRARY_PATH (good stack exchange question about dyld).
so first off, I want to say that this question:
Bundle framework with application in XCode
and this question:
OSX: changing path of .framework
were both extremely helpful getting me up to this point, but I'm still not quite there.
So, like both the Original Posters for the two previous questions, I'm trying to embed a framework inside my app bundle. Or, rather, the issue is that I'm trying to embed MULTIPLE frameworks in my app bundle, some of which depend on eachother. I believe that even though my application can successfully find the frameworks (i've changed the install directory so the frameworks know where they are), the ones that reference each other are still looking for the frameworks to be installed in the normal ~/Library/Frameworks directory.
This is the output I'm getting when trying to run my app:
Dyld Error Message:
Library not loaded: #rpath/SDL.framework/Versions/A/SDL
Referenced from: /Users/Daly/Library/Developer/Xcode/DerivedData/Coin_Checkers_2-cibyiolfgsmcicdrcfxufftxzbsk/Build/Products/Debug/Coin Checkers 2.app/Contents/MacOS/../Frameworks/SDL_image.framework/SDL_image
Reason: image not found
Binary Images:
0x7fff5fc00000 - 0x7fff5fc3be0f dyld 132.1 (???) <29DECB19-0193-2575-D838-CF743F0400B2> /usr/lib/dyld
It seems to me that It's correctly loading SDL_image, but failing when SDL_image references SDL. Is there any similar trick I can use to direct the SDL_image framework to the correct location for my embedded SDL framework?
Thanks a bunch!
Oh, never mind. I hadn't seen this question until it showed up in the related section on the side:
Embedding frameworks in a Mac App Bundle
Apparently all I needed to do was set the runpath searchpath, and that solved all my problems. I had tried setting the Frameworks search path, but that didn't seem to help.
In fact, I redownloaded the frameworks to see if the install_name_tool steps were even necessary, and it seems they are not. they worked without it. Interesting.
I have an Xcode 4 project, a Cocoa application with Spotlight, Core Data and unit tests. The app uses a custom framework named TBPluginManager I wrote to load bundles. I originally wrote the framework in Xcode 3 but when I used it in Xcode 4 GDB kept complaining, so I recreated the framework in Xcode 4. This made GDB happy, until I tried to run the built-in unit-test and got:
[Switching to process 3840 thread 0x0]
dyld: Library not loaded: > Library/Frameworks/TBPluginManager.framework/Versions/A/TBPluginManager
Referenced from: /Users/elise/Library/Developer/Xcode/DerivedData/BookManager-cooglmktssmptpatjuetculukiqd/Build/Products/Release/BookManager.app/Contents/MacOS/BookManager
Reason: image not found
sharedlibrary apply-load-rules all
No memory available to program now: unsafe to call malloc
Now I can understand why the unit test cannot find the framework since it lives not at Library/Frameworks/TBPluginManager.framework but at /Library/Frameworks/TBPluginManager.framework. But how do I tell that to the unit-test bundle? I've tried setting the Framework, Header and Library Search path build setting, but to no avail.
BTW, I've gone back to GHUnit but I'd like to get this working as well.
FOLLOW-UP: Much as it bugs me that Grady Player got an account just to tell me that I'm an idiot, it just may be that he or she is right. My lovely, dependable framework is generating warnings and errors like they're going out of fashion and so I've turned the problem over to Apple Developer Technical Support. If anything interesting comes out of it, I'll post it here. Otherwise, I'll delete the question.
make sure that the framework installed at /Library/Frameworks/TBPluginManager.framework is valid and the same arch as you are trying to link it to. If you are in doubt recompile the framework again, put it in a custom location and set that custom location in your framework search path.