ChatGPT解决这个技术问题 Extra ChatGPT

‘ld: warning: directory not found for option’

When I'm building my Xcode 4 apps I'm getting this warning:

ld: warning: directory not found for option '-L/Users/frenck/Downloads/apz/../../../Downloads/Google Analytics SDK/Library'
ld: warning: directory not found for option '-L/Users/frenck/Downloads/apz/../Google Analytics SDK/Library'

But I do not have Google Analytics in my app, I deleted all of it how can I remove the error? And archiving an app gives me the error:

clang: error: no such file or directory: 'armv6'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

I've tried so many things but I'm still getting this error when I'm trying to make an .IPA file

Note that there is a very similar warning, but with -F rather than -L: directory not found for option '-F/.... See @macayer's answer below for the difference.
Note: Make sure directories with spaces are quoted. eg $(PROJECT_DIR)/my folder should be`"$(PROJECT_DIR)/my folder"
I ran into this issue when my class did not have the proper target membership specified.
@Jackson That fixed it for me. I had the -F warning, and I fixed it by quoting as you instructed in the 'Framework Search Paths' in Build Settings. Thanks
Regular backup is best practice.

B
Blazer

You need to do this:

Click on your project (targets) Click on Build Settings

if your error includes the -L flag, then delete the values in Library Search Paths

if your error includes the -F flag, then delete the values in Framework Search Paths

And regarding the second error, sorry i can't help you out with that one. Hope someone else can help you out.


This broke my project, but I just commented out my Google Analytics #imports and deleted the SDK, quit xcode, re-added and uncommented my #imports and it worked again :)
Be careful of deleting if you actually need that library path. Verify that the path specified in the error exists. The location of the library on disk may have been moved.
After delete Library Search Paths I got the error: ld: library not found for -lMoboSDK clang: error: linker command failed with exit code 1 (use -v to see invocation) (lMoboSDK is my static library)
I had to delete the paths under 'Framework Search Paths' on my 'AppTests' TARGET to clear the error.
For those seeing the error @lee saw... make sure you open and build the workspace instead of the project.
D
Dave Liepmann

There are two errors that people seem to be confusing.

If it is a "directory not found for option '-L/..." error, that means it's a Library Error, and you should try to:

Click on your project (targets)

Click on Build Settings

Under Library Search Paths, delete the paths

If it is a "directory not found for option '-F/...", that means it's a Framework Error, and you should try to:

Click on your project (targets)

Click on Build Settings

Under Framework Search Paths, delete the paths

This might happen when you move the referenced file around.


Why can't all answers be as concise and helpful as yours? Thank you. I have a side question: where does one learn about the cryptic -L/-F errors? I'm new to the whole linking/compiling/building game, and Xcode's built-in documentation isn't exactly something to write home about. I'm assuming most of this stuff can be accessed via command line. Am I right in this assumption? It's just been difficult for me to even know where to begin with all this stuff. I'm used to web development, so as you could assume, finding info in that realm is a bit easier.
on delete the Search Paths it again shows FacebookSDK not found. It is a -F error. I am using Xcode 6.1
Worked for me. I had to delete framework search paths in the targets for both the project and the testing module (upon project upgrade from iOS8.3 to iOS9).
Come on Apple, what happened to "it just works" ... this should apply to dev too. At least offer us suggestions on how to resolve these sort of issues instead of these cryptic messages. Kinda reminds of Microsoft, ew.
Thank you much for "-L is for Library Search Paths" and "-F is Framework Search Paths" guideline, it worked perfect for me.
l
lujop

My problem was that I opened the original .xcodeproj instead of the .xcworkspace that was generated by CocoaPods.


Damn this really saved me after 3 hours of pounding my head on the keyboard
Yeah took me one hour to find out that I had done the same "mistake". Just "getting things done" is nothing Xcode is any good at... F#ing feature bloat.
b
backslash-f

I had to remove the references at:

Target

Build Settings

Framework Search Paths

https://i.stack.imgur.com/ITm2S.png

Then the build was broken (expected). So I removed the Framework (FB SDK), re-added it and voila. No more errors or warnings. :)


L
Lazar Kukolj

I use cocoa pods so for me, I quit Xcode and ran

pod install

again and reopened the project. This fixed everything!


Not sure why you're being downvoted when your suggestion can actually be a solution to a similar issue! Specifically, it is a solution if you're experiencing similar error messages after adding new build configuration to your project. Since adding new build configuration automatically implies duplicating an existing configuration, you need to run pod install to adjust the “Based on Configuration File” column value.
Also, cocoa pods generates a workspace. make sure to open that, not the project file. pod install + open the workspace file fixed my problem.
In ionic this works for me when I ran the pod install inside the platforms/ios folder
Thank you for sharing this, it worked for me as well.
I
Iron Mike

For me the problem was a missing escape "\" character.

My search paths were broken up on several lines in the Library Search Paths. Conveniently, they were breaking at spaces in my path. Adding the escape "\" fixed it for me.

$(PROJECT_DIR)/My\ Project\ Name/My\ Directory

This is the perfect answer! Tested April 2014
It's pathetic that this is still broken in Xcode 6, Feb. 2015. Spaces in paths should not need to manually be escaped.
The accepted and higher voted answers above did not work for me, but this did. My hint that it was this issue is that Xcode was throwing 2 -L errors, with each error being a fragment of the complete path and it was breaking on the space. Agreed that in 2015 we shouldn't have to worry about escaping spaces, that should be handled behind the scenes for us!
Yeah, this is a long-standing issue in Xcode that occurs when your search path is added automatically by the system (i.e. due to dragging a library into 'embedded binaries' - for some reason it doesn't escape the spaces automatically and subsequently interprets them as separate file paths.
J
Jasper

I found the reference which I had to remove at:

Target

Build Settings

Header Search Paths


Using Google to find a solution for ‘ld: warning: directory not found for option’, finding my own answer as solution
S
Sam B

In my case the problem was Framework Search paths that had incomplete, dead, old links or multiple frameworks of same type. Remove them and your project will compile without any problem.

be sure to do Build -> clean

https://i.stack.imgur.com/Gufjy.png


F
Francesco

I ran into the same problem (the first one) after an Xcode crash and none of the solutions proposed worked. To suppress the warning I have done:

• manage schemes...

• deleted the current scheme

• Autocrate Schemes Now


We should have the author of this original question post a Note to run through all of these solutions. A list. Try first one, second next solution, next solution... because this did it for my migration of an older project and other solutions are reasonable solutions. If I did not try out all , I would not have found this one... moved on and been swimming in confusion. Thx Francesco!
M
Major MacGregor

This is what worked for me:

Click on Project Click on Build Settings Search for "Framework Search Paths" Clear the path and type "$(inherited)"


B
Brad Folkens

I got bit by what appears to be the same issue too (this time in XCode 5.0.2). In my case, what happened was XCode decided to escape the quotes already in the "Build Settings". So for example:

"$(SRCROOT)/../GoogleAdMobAdsSdkiOS-6.4.1"

became

\"$(SRCROOT)/../GoogleAdMobAdsSdkiOS-6.4.1\"

which caused the build to fail...

Once I removed the escapes on the quotes everything worked fine again. In addition, it would probably be best to remove the quotes altogether unless you need them.


HUGE +1 for this. Those escapes on the " were the cause of the "directory not found" error for both -L and -F options.
very useful tip...in my project xcode 5.0.2 escaped quotes in the beginning, middle and end of paths....it had also duplicated paths for some frameworks in a weird way...removed escapes, let just "real frameworks paths" for the ones the project is using and got rid of warnings...it also was necessary to remove / add again frameworks after correcting the paths
G
Gaurav Chaturvedi

If this happens after you've added a Podfile to your project and run pod install, go to your project folder, you'll see a new file that has been created "{ProjectName}.xcworkspace" -- open that file in xcode

The pods that have been installed will be properly linked to your project in this file


Could be that you opened the project file instead of the workspace.
M
Madhu Kumar

there might be a mismatch in deployment targets. pods are installed for 11.0 and the Xcode is searching in 10.0 folders


C
Cesare

Follow this step-by-step solution:

Click on your project (targets); Click on Build Settings; Under Library Search Paths, delete the paths; Add ./** on Library Search Paths.


S
Suragch

Supplemental answer

All the answers said to either delete the Framework or Library search paths from the target. I had two problems:

First, I was looking at my main project target rather than the Unit Test target.

Second, I couldn't figure out how to delete the framework search path. It turned out that it was just clicking it to get in edit mode and then just deleting the string.


I want to try this, but Im worried it will break the app. Are you sure everything worked after you did this?
@Supertecnoboff If you are worried that it won't work, then save the string before you delete it. You can always paste it back in. My app was already broken, so I just had to keep trying things until something worked. My answer above is what worked for me.
s
studiou

For me the problem seemed to be that I hadn't included the appropriate frameworks (when copying addons from another project I didn't copy the frameworks files as well)


C
Chris Klingler

The key for this type of error is to go into build settings and look at each of the search paths sections such as Library Search Paths, Framework Search Paths and possibly even Header Search Paths and clear out any of the paths that no longer apply that your app is having a hard time trying to find. Remove them and carry on good sir


c
chings228

go check out which framework is missing , then go to

=> Build Phases => Link Binary With Libraries

remove the library and then add back


p
prankin

I had a similar problem that went away when I created a new scheme and used it to rebuild???


V
Vincent

For me I have also Tests enabled. The search path for tests was also filled incorrect.

Clear the Framework Search Path for both the regular code and the test code!


A
Alperen Adatepe

Because of the custom directories that have entered to the search paths ( frameworks and library ), the project overrides pod's directories. so it can't find it.

To solve this problem, delete all custom directories from

Search Paths -> Library Paths and Framework Paths,

only see ${inherited}.

I hope this helps. It worked for me.


V
Viral Savaliya

If you installed any new pod and then got this error, just quit the xcode > open again > build the project


J
James Wong

https://i.stack.imgur.com/cepVf.png

Add $(inherited) -Objc -lcrypto - lssl in Project -> Build Setting -> Search path -> Library Search Path


The above solution is working fine for me, If It is not working for you, please share the screenshot.
J
JJIqbal

If this happens after a pod install with some dependencies, the problem might be you are using the old version of the app(.xcworkspace) on Xcode.

After a pod install, this is the output you may see.

The output of a pod install.

https://i.stack.imgur.com/zh1P1.png

Do exactly that, close your current Xcode window and open the new .xcworkspace.

Opening the new xcworkspace]

https://i.stack.imgur.com/R5JgN.png


k
kingboylee0595

you should check option for this:

Build Settings-> Framework Search Paths-> {input Your Project Path}


M
Mohammed Fathy

I've looked into all [Library Search Paths - Framework Search Paths - Header Search Paths]. but there are no paths to remove, so I was able to make this alert go away by going into the Xcode bundle and creating an empty directory at the path location that the alert was complaining about.


O
Ofir Malachi

Make sure only 1 "libFlurry.a" selected in target

worked for me.

https://i.stack.imgur.com/iRf76.png


C
Community

Do not forget to create the same configuration for Pod project in your workspace, If you change into MainApps new configuration.

For example,

In my case, to resolve this issue I had to create ReleaseOfficial configuration as well for Pod projects when I created ReleaseOfficial configuration for my MainApp.


E
EmpireJones

If the typical solution doesn't resolve the issue, what fixed it for me was ensuring that all iOS versions in the xcode project (e.g. IPHONEOS_DEPLOYMENT_TARGET) / deployment targets, podfiles (if applicable), etc. are set to the same version number.


A
Ahmed Samir

1- select your target

2- open build settings

3- search for "framework search paths"

4- delete all "framework search paths"

5- then install the pods again

6- add in the "framework search paths" $(inherited)

7- clear cmd + k

8- build cmd + b