Library not loaded- Alamofire - ios

I have been plagued by a bug for hours. I am building a framework using Alamofire and am testing it in an iOS project. Whenever I run the project, I get this error:
dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire
Referenced from: /Users/theodorestrauss/Library/Developer/Xcode/DerivedData/TGClient-ecnnvvvxipoufihfghkpxlfccyoc/Build/Products/Debug-iphonesimulator/TGClient.framework/TGClient
Reason: image not found
I have scoured the web looking at GitHub issues, Stack articles, and more. I've cleaned, deleted Derived Data, added and deleted frameworks from embedded binaries, etc.
For anyone out there, this is not a duplicate. All other questions and answers are outdated.
If anyone can help, I'd immensely appreciate it. Thanks so much in advance. Cheers,
Theo

Make sure your build settings > Runpath search paths have be
• #executable_path/Frameworks
• $(inherited)
Also in your framework search path below entry is there
"$PODS_CONFIGURATION_BUILD_DIR/Alamofire"

This is what I do when I have this problem (and it really works!):
Remove Alamofire framework from target/embedded libraries and target/linked frameworks and libraries by highlighting it and clicking the minus sign. (click on your project name in the upper left corner if you don't see these areas in the center of your screen).
Perform a product clean (Shift-Cmd-K).
In Embedded Binaries section, click on the + sign. Add Alamofire. (or drag the Alamofire icon from the left column into this section and drop it there)
Xcode should fix everything, and it should now load onto the device properly.

I was getting this error while using Alamofire 4.5 + carthage, I added the framework as Linked Libraries in the build phase, the app was crashing on start. In XCode 9.1 I couldn't find the option of Embedded framework, so I added a Run Script to copy framework from Carthage and it started working.
So basically this
Add the framework to the build phases as you normally do.
Add the below Run Script
/usr/local/bin/carthage copy-frameworks
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework

Can you please clear derived data once and build the project again.
Here is how to clear derived data. Open the terminal and simply hit this command.
rm -rf ~/Library/Developer/Xcode/DerivedData

I solve it by unchecking run script only when installing in build phases menu

Related

ld: library not found for -lCocoaAsyncSocket - React Native

I have created a new react native project and when I try to run the app within an iOS emulator it always crashes.
When I open the .xcworkspace within Xcode I get the following error.
I have tried to update the search paths but this has not worked, I have also tried to reinstall pods but this hasn't worked.
This must be fixed on the framework side, however, the solution is the following steps:
On the Xcode bring the Build Settings tab
Find the Search Paths and then try to modify Library search paths
Add ${inherited} to the first of the list. It's important to be the first
Delete the build folder inside the ios folder of the project
Try to run the project again
It must fix the issue
This issue is basically related to the wrongly linking classes. Please follow these steps:
check make sure, you have install all the pods.
Please check your .js files, and check your import statements. To be make sure , every import statement package is installed in your project
clean project
Rebuild again
I can see that you state you have already checked search paths, but I had this same issue, and it was resolved by adding "${PODS_CONFIGURATION_BUILD_DIR}" as recursive to my Library Search Paths, under <Project> > Build Settings > Library Search Paths. However, now I'm stuck on the linker instruction -lcrypto, so it's not a complete solution.

xcode 7.1 for iOS 9 missing libc++.dylib required for Objective C Realm Static Framework

I am following this doc for integrating realm in my iOS app.
Realm static framework for iOS
My problem is in step 3. I am unable to find libc++.dylib. I find a few other .tbd ones but none of them are libc++.
I followed a few other SO posts on using the "add other" option and doing command+shift+G and find that library but it's not in that list either.
Does anyone know any workarounds?
I had the same problem. I found some kind of way around.
Go to Build Phases > Link Binary with Librairies > + > Add other
Once in the file selection window do "CMD"+Shift+G (Go to folder) and type /usr/lib/
From /usr/lib you can add : libc++.dylib and more...
Compile and have fun
This is a known issue in the Xcode 7 beta.
To work around this issue for now, please:
Delete all references to .tbd files from either your linked libraries phase, or from the copied bundle resources phase (where they sometimes will be added).
Add the library you want to link manually to the "Other Linker Flags" build settings, by adding the argument:
-l<library_name>
for each library you want to link (for example, add "-lsqlite3" (without quotes)).
For those who are curious, the .tbd files are new "text-based stub libraries", that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size.
-- copy from link
finally, you can add -lc++ in this Other link Flags setting
I have same problem. I cannot find libc++.dylib through xcode but I found it using terminal.
You can copy or create a link to visible folder in xcode like /Users//Downloads.
Command below maybe help to fix the problem.
ln -s /usr/lib/libc++.dylib /Users/<your user>/Downloads/libc++.dylib
I had a similar issue with Realm the other week after the iOS 9 update. I know you already tried the method of going to build phases, add other, CMD + shift + G without success. However this was the method I used to locate libc++.dylib and I just checked it out again now and was able find it.
It is also worth mentioning that after you do manage to add libc++.dylib you may have build errors. In which case the fix I used was to go into your target's build settings and change Enable Bitcode to No.

'Framework not found' in Xcode

I know this has been asked a couple of times. I followed instructions from these ones:
Adding frameworks to project in Xcode 5 and having *relative* paths added
xcode4: Linker error: Directory not found for option
Still Xcode is giving this error:
Here's my current configuration:
The bolts framework is so I can use the Parse SDK. I downloaded the blank project from here: https://parse.com/apps/quickstart#parse_data/mobile/ios/native/new
It's working. I tried to copy every config option, but it still doesn't work.
Try deleting Bolts.framework from linked framework and re-add it. Also, in your Framework Search Path keep path until Bolts.framework like $(PROJECT_DIR)/Bolts if it is inside Bolts folder at your project directory path.
I'm pretty new to iOS development. Apparently this problem for me was a result of opening the .xcodeproj Xcode project instead of the .xcworkspace Xcode workspace. I opened the workspace instead and the error has gone away.
error: Framework not found
If you use CocoaPods try to run:
pod deintegrate
pod update
Also use .xcworkspace instead of .xcodeproj
Delete the framework link from the Xcode project setting.
Move the framework to the Project Folder.
Re-add the framework in the Xcode project setting.
clean the project and re-compile it.
delete all frameworks from Embedded Binaries and re-add it
me too was getting this error , I moved the framework file to the root project folder and added to framework again and problem is solved.
1:- Delete the framework from the Xcode project. Quit the Xcode.
2:- Open your project in XCode and go to file under Menu and select Add files to "YourProjectName".
3:- Select "YourFramwork.framework" in the directory where you keep it.
4:- Click on the Copy items if needed checkbox.
5:- Click Add.
Make sure that you have the framework added in both Embedded Binaries and Linked Frameworks and Libraries under Target settings - General. As shown in the following images:-
Here is the solution :
Turn the "$(PROJECT_DIR)" attribute(might be non-recursive by default) into recursive option in Select Project Click on Targets Click - Build Settings Search for 'Framework Search Path' - Double click the input.
Scratched from https://stackoverflow.com/a/31298214/4493512
Besides from removing the framework from the Podfile and Linked Frameworks and Libraries, I also had to remove the reference to the framework in Other Linker Flags.
I just had the same situation (was having a hard time to address the OP's build error after adding a 3rd party framework) and it seems like a bug in Xcode (mine is 8.3.2 (8E2002)).
The problem was that a folder name in path to the framework contained spaces. In this case, Xcode incorrectly escaped them with backslashes like this in Build Settings -> Framework Search Paths:
$(PROJECT_DIR)/Folder\ with\ spaces/Lib
To fix this, just manually edit the entry to remove those backslashes and enclose the whole string in quotes like this:
"$(PROJECT_DIR)/Folder with spaces/Lib"
Delete the framework that is causing the issue (by removing the reference).
Then add it again, following these steps for adding FBSDK frameworks and libraries:
click project
general settings
linked framework and libraries
click the plus button and add all that you want
None of the above worked for me until I found that I had a blank "Any Architecture | Any SDK" line underneath Framework Search Paths / Debug under Build Settings.
Deleted the line and it works!
Error: Framework not found
If you use CocoaPods try to run these commands from terminal:
Intel chip:
pod deintegrate
pod update
Apple Silicon M1 chip:
pod deintegrate
arch -x86_64 pod update
Also use .xcworkspace instead of .xcodeproj
When this error occurred to me was because Pods folder was in iCloud and had no local copy on my computer. Go to your project's folder in Finder and check if there is iCloud's symbol in any of the folders inside it!
I realised that I hadn't run/built my framework with the Generic Device, which strangely lead to these issues. I just put the framework back in and it worked.
If you are using CocoaPods. Similar thing has happened to me. Although this question is old someone like me might still be struggling. So for to help:
after pod install it warns you about project files. I didn't notice till now. it says:
[!] Please close any current Xcode sessions and use
ProjectFile.xcworkspace for this project from now on.
So basically, do not continue working on .xcodeproj after installing Pods. If you do linker won't find files.
My framework has long name like FrameworkSDK_Light-1.0.6.framework so I renamed it to FrameworkSDK_Light.framework and it solved my problem.
I got the error 'AdBrixRM framework not found'. I checked the AdBrixRM.framework. I noticed that 'AdBrixRM' excution file is missed. I copied this file into the framework folder and the issue was gone.
I used to encounter this same exact issue in the past with Google Admob SDK. Most recently, this happened when trying to add Validic libraries. I tried the same old good trick this time around as well and it worked in a jiffy.
1) Remove the frameworks, if already added.
2) Locate the framework in Finder and Drag & Drop them directly into the Project Navigator pane under your project tree.
3) Build the project and Whooo!
Not sure what makes the difference, but adding the frameworks by the official way of going to the section "Linked Framework & Libraries" under project settings page (TARGET) and linking from there does not work for me. Hope this helps.
I found that the file.framework was referencing a file outside my project. So I dragged the file into my frameworks folder under my project and then got rid of the earlier file.framework file and it worked.
add github "BoltsFramework/Bolts-iOS" on your cartfile.
then carthage update.
after copy Bolts.framework from ../carthage/Build/iOS
Switching from iOS simulator to real device solved the problem for me.
Was facing the same error and solved it ---> Build Settings > Build Active Architecture Only = Yes
Please after adding both framework also open each Bolts and Parse framework and add Parse and Bolts to the project then problem will be solve
Running pod update in the root directory of the app fixed the issue for me.
If you are developing one module using cocoapods, try to comment the line
s.vendored_frameworks = "YOURMODULE.framework"
on YOURMODULE.podspec
The error will disappear after you generate and copy your YOURMODULE.framework to your project folder.
I had this issue on one of the project i worked, before you delete and readd the framework do a:
git status
on your project and check to see if the framework is not listed as deleted. In the event that it is either do a
git stash
or
git checkout *framework/file/path*

ld: framework not found Parse Xcode 7 beta

I succeed to install and use Parse framework with my new project, but I can't with a "template project".
The template is just a Slide Menu from Appcoda
You can download the project here.
I have this error :
ld: framework not found Parse
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And the same for Bolts.
I don't understand what the problem is, the initial project is just some View Controllers...
When I write the code "import Parse", the error message is :
No such module 'Parse'
I tried to drag and drop the frameworks, and also to add the frameworks in "Link Binary With Libraries".
PS : I am using Xcode 7 beta, and I tried on beta 1 and 2, same issue.
Here is the solution:
There seems to be an issue with Xcode 7 beta where the search path for manually added frameworks is missing.
To fix the issue add the search path by doing the following:
Select Project
Click on Targets
Click Build Settings
Search for: Framework Search Path
Add $(PROJECT_DIR) and choose Recursive option.
The project should build now.
Thanks to this post : Link to stack
None of the proposed solutions worked for me. Eventually I found that the solution was to drag the frameworks from a source folder that did not have spaces in it's name.
E.g.
Dragging the frameworks from 'iOS SDKS' > did not work
Dragging the frameworks from 'Downloads' > worked
It's not the first time that XCode has been shown to be problematic when working with paths that contain spaces.
Ensure that Parse is included in the "Link Binary With Libraries" section under "Build Phases".
Go to your Build Phases -> Linked Binary With Libraries remove your pod framework & add it back again. That does the trick.
Even I got the same issue. In my case, somehow there were multiple frameworks added to the project, and one of the framework is empty. After removing the empty framwork it started compiling.
This can also happen if you accidentally break your framework, e.g. if the framework contained an Alias, which is no longer there.
This can happen if you zip the file, as the Alias contains a direct link to the orignal file, and isnt updated when you move the zip. E.g. in my case I recieved a zip of the opencv framework, and inside it had just the 'Versions' folder and no aliases to Headers, Resources or the binary. You can just recreate the aliases, or compile the framework from source again.
This took a while to figure out!

dyld: Library not loaded: #rpath with iOS8

I'm creating an iOS framework with Xcode6 and iOS8. When I link this with an iOS app and try running it on the device I get this error
dyld: Library not loaded: #rpath/FrameworkName.framework/FrameworkName
Referenced from: /private/var/mobile/Containers/Bundle/Application/0F2C2461-A68B-4ABA-A604-B88E6E9D1BB1/AppName.app/AppName
Reason: image not found
The 'Runpath Search Paths' build setting for the framework is set by default to
'#executable_path/Frameworks', '#loader_path/Frameworks'
I could not find any documentation related to this. This was something new introduced with Xcode6 and I would expect it to just work by simply including the framework into any app that needs it.
To make this work
In the framework project settings change the install directory from
'/Library/Frameworks' to '#executable_path/../Frameworks'
In the project that includes this framework, add a copy files phase and copy this framework to the 'Frameworks' folder. Once you do this ensure that this framework is listed under the 'Embedded Binaries' section.
Issue resolved using this answer. According to #vladof81:
In the target's General tab, there is an Embedded Binaries field. When you add the framework there the crash is resolved.
Reference is here on Apple Developer Forums.
I also had same kind of problem where I was not able to launch the app & app was crashing with above message :
dyld: Library not loaded: #rpath/FrameworkName.framework/FrameworkName Referenced from: /private/var/mobile/Containers/Bundle/Application/xxxxxxxxxxxxxxxxxxx
Reason: image not found
Here is my approach that helped me to resolve this error:
From General Tab
Frameworks, Libraries, and Embedded Content
add the framework and make sure to make it Embed & Sign
From Build Phases
Dependences
add the framework to it
Check if you can find framework in context under :
Build Phases > Embed Frameworks >
If not just add that framework in "Embed Frameworks" after adding that framework in your project directory's "Frameworks" section.
I was getting this error on a library installed through CocoaPods. Cleaning the build folder (cmd + option + shift + k) and then doing a clean (cmd + shift + k) was what ended up resolving this issue for me.
If you are using Carthage
Run carthage update on terminal
Go to Project Settings -> Build Phases -> Carthage Copy Frameworks
Add line in Inputs files:
$(SRCROOT)/Carthage/Build/iOS/YOURLIBRARY.framework
Add this line to Output files:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/YOURLIBRARY.framework
For me it was because of the SSL issue, I had set my developer, distribution certificates on my Mac(Keychain) to 'Always Trust' for one of my other project. I had to change them back to 'Use System Defaults'. it was working for me then!!
Made the library which shows not loaded changed from required to optional in Linked binaries and frameworks. It is working perfectly now
I also had same kind of problem where I was not able to launch the app & app was crashing with above message :
dyld: Library not loaded: #rpath/FrameworkName.framework/FrameworkName
Referenced from: /private/var/mobile/Containers/Bundle/Application/xxxxxxxxxxxxxxxxxxx
Reason: image not found
Here is my approach that helped me to resolve this error:
1.Please delete your app from device, Clean the build and and rebuild and run on the device.
2.If above steps does not help you, then please check for below settings :
From "TARGET">"Build Settings">"Runpath Search Paths" & then check for values "$(inherited)" & "#executable_path/Frameworks", Feel free to add incase they don't exist.
Build your app and run it on device
In addition to the above solutions, recheck the paths of frameworks included in your application under
Build Settings --> Search Paths --> Framework Search Paths
When non of those solution works:
(Optional) Get a clear knowledge from here on different search path type
Make sure that your .framework file paths are added in Build Settings -> Framework Search Paths. You can keep all framework files somewhere in App/libs/ and add this folder and enable recursively.
Make sure that your .a files paths are added in Build Settings -> Library Search Paths.
I installed third party libraries using Cocoapods. Got the same error, tried everything but finally realised I havent had use_frameworks! in my pod file.
So removed the currently installed library, added use_frameworks! line in pod file, reinstalled the libraries and all worked for me.
The way tested by me is well.
In "Linked Binary With Libraries" change the missing framework to "Embedded Framework".
Because, "Do not Embedded" do not copy to the App, but Embedded Framework will copy into it.

Resources