ld: library not found for -lASIHTTPRequest : XCode13.4 - ios

I've opened a old project, I can not able to run the code because of the following error
ld: library not found for -lASIHTTPRequest
I tried
Re Install all the pods
I Opened .WorkSpace
I Tried,
Delete Library Search Paths
I Tried, $(inhereted) in Library paths

Sometimes it happens when the pod gets updated, and the pod owner gets rid of some internal dependencies (in your case ASIHTTPRequest), but the Cocoapods fails to remove all the references to the removed dependency completely for some unknown to me reason.
In such cases you can do that manually.
Open the build settings of your target, and search for "Other Linker Flags".
Double click on it, locate ASIHTTPRequest, and remove both: that line and the line before it: "-framework".

Related

Unable to build Project after pod init in an old xcode project

I am trying to init pod in an old code base. Whatever I do, I am not able to run my project after git init. There is always build error. I am getting following error,
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKShareKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookCore'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookShare'
ld: framework not found FBSDKCoreKit
Even if my dependency pod file is empty then I get
pods framework not found.
My Framework Search Paths is set to to $(inherited), which is build/Debug-iphoneos/FBSDKCoreKit.. I have also tried to set this path to pods folder under project. But nothings works. Even I have same issue with another project also.
Xcode version : 12.3
Code base is in Objective C.
I have experienced a similar problem before in the past, using FacebookSDK frameworks.
Of course, if you were using Swift, you could easily import it with Swift Package Manager.
Try to perform the following steps
1. Edit your podfile
Making explicit reference to the version and project name
pod 'FBSDKCoreKit', ‘version’ :project_name => ‘myapp’
2. Delete build data
MyApp-some_code being the appropriate folder name for your app
~/Library/Developer/Xcode/DerivedData/MyApp-some_code
3. Reinstall your pods
The command that you have probably tried a couple of times already
pod deintegrate
pod install
4. Manually add FBSDKCoreKit in Link Binary with Libraries
Navigate to Project->Targets->Build Phases->Link Binary With Libraries
From there click on the plus button and manually add the FBSDKCoreKit framework
5. Deselect copy items to destination's group folder
As per Facebook official documentation, available here.
Check out the point number 3, in particular.

Error - linker command failed with exit code 1

I'm new to XCode Mac and IPhone development. So probably I'm missing something obvious here.
While trying to build the project I'm getting the following warnings and error. I can't figure out what is wrong here, I've looked at this answer and checked my Framework Search Path value and there is none in BuildSettings.
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Release-iphoneos'
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Debug-iphoneos'
ld: framework not found Pods_<app_name>
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been banging my head for several hours now and finally given up.
The path mentioned in the error does not exist and when I looked into where build folder is located in XCode project, I realized they are in a shared directory ~/Library/Developer/Xcode/DerivedData. So I don't understand why XCode is looking for these files in the project's relative path, where build folder doesn't exist.
I'm using
XCode 10.1
CocoasPod 1.5.3 1.8.4
MacOS High Sierra
Note: The same workspace builds successfully on another system.
Edit:
If I copy the project.pbxproj from the other system onto this one, the project on this machine builds successfully too. project.pbxproj is located under *.xcodeproj file.
Also if I select Generic iOS Device the project builds fine, but as soon as I switch to any other target device I get the same error.
Edit 2:
I see a couple of framework files in red in the left side folder/directory's panel.
Foundation.framework
Pods_<application_name>.framework
Solution:
So right now I've found a solution what I believe to be a workaround and not the actual solution.
In my project's folder structure I saw multiple .framework files in red. some of them had different extensions then the ones present in the xCode package. So I updated them with the newer extension files and that got rid of most of the red file frameworks and left just one Pods_.framework the same framework in the error above. I removed the framework from the Libraries and Framework list in the General section. After I did that project build fine and I was able to run the app.
However, I noticed the Pods_<app_name>.framework file is always regenerated after running pod install. So I have to manually remove this unwanted dependency from the list each time starting a new workspace which is pain to say the least.
And so now I'm looking for a way to correct this so I don't have to remove the Pods_<app_name>.framework file each time.
While I was searching for the solution I found a closed cocoapods bug which reported the same issue for an older version. I've lost the thread and cannot find it again otherwise I would've linked the bug.
As noted in one of the answer's comment I now have updated cocoapods version 1.8.4.
Edit 3:
Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '7.0'
# Uncomment this line if you're using Swift
use_frameworks!
target '<app_name>' do
pod 'Google-Mobile-Ads-SDK', '~> 7.39.0'
end
Based on your comment and build logs I believe the podfile Pods_<application_name> is not available to your project(its added but not downloaded).
Pods are a way to share code across projects and maintain versioning.
You just need to update the pod so that it gets downloaded and added to your project. For that just launch Terminal app, cd to your project folder and fire pod update (you may refer to https://freakycoder.com/ios-notes-12-how-to-update-pods-249ecf88fe57)
If you do not have pod installed you can head to https://guides.cocoapods.org/using/using-cocoapods.html
I used to run into that problem once but I already solved it the same way #alxlive answer and it worked.
The problem happened to me because of the pod that we already installed.
During that time, I already installed my cocoapod for my project. Then, I added 2 new Build Configurations.
Your problem might be the same because you did mention copying others project.pbxproj from other system and it made your project work fine. So that might be the case.
By deintegrate and install the pod back on, that will solve the problem.
Xcode has different build system for simulator and real devices. So it will generate different app for both. If you select any Simulator target then it will builds app for simulator and if you select Generic iOS Device or any real device target then it will builds different build.
May be you are using some frameworks which are builded for iOS devices, So
follow this steps,
Differentiate that frameworks which gives you an error and remove that pods from your pod file and run pod install command and delete DerivedData.
Download that framework's code in your system.
Add project files of framework in your workspace. For that you can refer this and this.
If you don't want to add whole code of framework in your project then you can add particular( for device or simulator ) build of framework in your xcode project.
For that follow this steps,
Open your downloaded project of framework.
Select any simulator target and build project.
Get generated .framework file from Products folder.
Add this framework in your project like this.
Now build your project for simulator.
Follow above steps for devices target if you want to build for devices.
For Google Mobile Ads you can follow this guidelines. Add the -ObjC linker flag to Other Linker Flags in your project's build settings
I hope this will work for you.
Adding -ObjC $(inherited) in the Other Linker Flags fixes my issue
For me it was due to having a space in the Configuration name like "Development Debug". Once I removed the space and made it "DevelopmentDebug", the error message went away.
The pods need to be installed once per mac. The configuration set in the project.pbxproj depends on the Cocoapods version and the Xcode version on the machine.
Try the following:
1 - Delete the Podfile.lock file and the Pods folder from the local project
2 - Delete the content of the Derived Data folder: ~/Library/Developer/Xcode/DerivedData
3 - Run the command:
pod deintegrate
4 - Run the command
pod install
5 - Run the project again

iOS/Google Ads giving Linker Code Failure

Trying to insert Google Ads/Firebase into a test app. Suspect I've almost got this working but. Using the Google notes from https://firebase.google.com/docs/admob/ios/quick-start
When I compile I receive "Linker code failed with exit code 1":
ld: warning: directory not found for option '-L/Users/edward/Library/Developer/Xcode/DerivedData/TotalConversion-gtwxqoywudjqpodqkpfpwcnovyuz/Build/Products/Debug-iphoneos/GoogleToolboxForMac'
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have created the Podfile as instructed with:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ’7.0’
target 'TotalConversion' do
pod 'Firebase/Core'
pod 'Firebase/AdMob'
end
and then run a pod update. I don't see a .xcworkspace file referred to in the docs. Does the iOS, '7.0' line above need to be altered?
I presume that using pods GoogleAds is instead of the standard framework (Build Phases/Link Binary) approach.
If there is a linker error, this might be few things. First, check if you haven't open .xcodeproj instead of .xcworkspace by mistake. If not, the solution might be simple project cleaning by pressing cmd+shift+k. At last, check if those libraries are linked with project and are having status required in your target's general/build phases (Pods_YourProjectName.framework).
In Podfile you can actually comment out lines with source and platform by placing # in front of them. Go to terminal, cd to your project directory and try pod install once again, maybe that will do the job.
Sorry for not placing this in comments but my reputation doesn't allow me doing it.
The {projectName}.xcworkspace folder should be in the same folder as the .xcodeproj that you have open. Close Xcode {projectName}.xcodeproj instance and open {projectName}.xcworkspace using the Finder, command line, or Xcode open.

How to remove all references to a library?

I have a pretty classical error during my project building:
ld: library not found for -lAppLovinSdk
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Originally I got the library from Cocoapods pod, but then I started having a lot of errors and decided to remove the pod from the Podfile and executed pod update
My Podfile looks like this:
I've tried to clean project, reinstall the Podfile, deleting Pods folder and Podfile.lock file, "Build Active Architecture Only" is set to "No", but I still have the error. I assume I still have some references to libraries from the deleted Pod. What is the way to get rid of them?
UPDATE: Here is a full error message:
Ok, so I figured out the problem:
I had to go to Target -> Build Settings -> Linking -> Other Linking Flags and there I had to remove all deleted libraries references, manually. And then it worked!

Xcode 7 build failed due to ld: library not found for -lGoogleAnalyticsServices

I have been struggling to get my xcode project to build for the last couple hours. I keep getting the following error:
ld: library not found for -lGoogleAnalyticsServices
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried almost everything. I saw that the Google Developers website said to use pod 'Google/Analytics', even after trying almost everything I could find on StackOverflow and Google regarding the error, I have had absolutely no luck.
I upgraded to XCode 7 yesterday, everything seemed to work yesterday but today suddenly I started getting this error.
If someone has anything I can do about this error, please help!
Pointing me in the right direction to get it fixed would be awesome too!
Thanks in advance for your help.
The linker flag has been renamed to:
-lGoogleAnalytics
but the Cocoapods settings have not been updated yet. Rename the entry in "Other Linker Flags" and your problem will be solved.
Also, the library (as of the moment I write is version 3.13.0) does not support Bitcode yet, thus please turn off Bitcode in Build Options > Enable Bitcode > Select "No". Clean & Rebuild afterwards.
Same problem occurred in my project. What I did, I just updated all my pods and after that my app got compiled.
Run "pod update" command from terminal in your project directory where the pod file is located.
Please make sure you opened .xcworkspace not .xcodeproj.
Go to Library Search Paths in Build settings and
add
$(PROJECT_DIR)/Pods/build/Debug-iphoneos
$(inherited)
pod install again.
Update cocoapods to the newest version that supports 64 arch.
sudo gem update cocoapods
Delete all Valid Architectures and Re-Add the architectures that you just removed.
Clean and run
Without looking directly at your build settings, there's a number of things that could be causing this. The main issue is in your linker flags you likely have something lingering/incorrect. Most of your pods have the prefix of:
-lPods-WhichIt-SomePodsLib
However your GoogleAnalyticsLibrary has the prefix:
-lGoogleAnalyticsServices
This might indicate a lingering flag from your. Try looking for this entry in Other Linker Flags (Under Build Settings) and clear this out and re-running pod install.
Other things to check:
Cocoapods version is latest stable version
You are using the latest version of Google's official Analytics pod
Your library/framework search paths (build settings) are correctly pointing to the analytics library in question.
For the record, I've had issues with pods and using google libs before they officially started releasing in cocoapods. If all else fails, remove the pod entry from your Podfile and try adding the library manually.

Resources