I'm trying to add SDL and SDL_ttf frameworks to my application and I've done it the usual way: added them in the "Link Binaries with Libraries" section and added a copy files phase that copies them to the Frameworks directory. This does create a app bundle with embedded frameworks. However, when I run the application, I get this error:
dyld: Library not loaded: @rpath/SDL_ttf.framework/Versions/A/SDL_ttf Referenced from: /Users/matthew.davies/Library/Developer/Xcode/DerivedData/MacHub-ambfqujqxbxyiqapaoctvsucpdeu/Build/Products/Release/MacHub.app/Contents/MacOS/MacHub Reason: image not found
I am not sure what else to do so that the app can find the frameworks despite being embedded in its bundle.
Any ideas please?
Adding A Framework TargetCreate a new Xcode target and select the framework template appropriate for your app's target platform. Add all of the framework source files to the new target's Compile Sources build phase. Set the visibility of header files needed by clients of the framework to Public.
You just need to go in your target -> build settings -> Linking -> Mach-o-Type. You can CHANGE the type of the framework to any other options. When you create a framework from Xcode it'll automatically set it to a dynamic library, but you can change it for whatever you want, as the image below shows.
A framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package. Multiple applications can use all of these resources simultaneously.
Apple keeps frameworks in /System/Library/Frameworks/ and /System/Library/PrivateFrameworks/. Inside these directories are *. framework files, which are themselves a directory of computing resources (binary executables, dynamically linked libaries, headers, etc.).
I discovered the reason why in a comment on a webpage. I needed to set the "Runpath Search Paths" build setting to "@loader_path/../Frameworks" and the frameworks are found.
Why frameworks are not automatically searched for in the Frameworks directory of an app bundle is a complete mystery to me? Are you listening Apple? :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With