directory not found Apple Mach-O linker warning bu

2020-05-17 02:17发布

问题:

I'm getting these messages:

ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed"'
ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed/../../../Downloads"'

But when I go to Build Settings (as suggested at ‘ld: warning: directory not found for option’), Library Search Path and Framework Search Path are empty, so there's nothing to delete.

Thoughts on other things I can do to get rid of this warning?

回答1:

Here is a description how to avoid a problem based on Apple Dev Forum posted before. It works for me so I repost description for those people who don't want to go and register at the forum.

The bug is due to an error in XCode 5 when it deals with the user adding new files or folders to the project.

Xcode is modifying the 'Library Search Paths' build setting, and making a god-awful mess of it. Instead of adding $(SRCROOT)/ it is adding fully rooted paths to all new items, and adding random amounts of /// into other elements of the string. It also seems to be duplicating source paths in some instances, probably because it's broken the existing ones, and thinks they need adding again.

The solution:

  1. Copy out your Library Search Paths string into a text editor.
  2. Remove any fully rooted paths that shouldn't be there, and replace them with the usual $(SRCROOT)/MyFiles/ type paths.
  3. Remove all extraneous slashes and make sure each path has a " character at beginning and end to protect against spaces in filenames.
  4. Paste the edited string back into Build Settings.
  5. Clean, then Build. Should be back to normal.

This error may well recur if you add new files to your project, so beware.



回答2:

My project.pbxproj looked like this:

LIBRARY_SEARCH_PATHS = (
        "$(inherited)",
        "\\\"$(SRCROOT)/AdMob-v6.4.1\\\"",
        "/MyProject/AdMob-v6.5.1",
); 

I closed MyProject, deleted the line containing AdMob-v6.4.1, reopened the project, performed a "validate project settings", cleaned, and built, and now all is well.



回答3:

Yeah, Xcode is jenky sometimes.

Did you try cleaning your build (Product > Clean Build Folder / Shift-Cmd-K) and trying again?

Another thing you can do is to search for the two entries in [project_name].xcodeproj/project.pbxproj, remove them, close XCode, re-open, Clean Build Folder and try again.

Good luck!



回答4:

To summarise what @user2963906 is suggest, I show my solution to this problem, which I think much easy.

I assume that you have all your files and libraries in your project folder.

  1. Open your project Targets
  2. Find Search Paths topic and Library Search Paths
  3. Choose and remove all paths here
  4. Then add path like this: $(SRCROOT)/"Your App Name"
  5. In the same window change drop-down list from the right from non-recursive to recursive
  6. Shift-⌘-K and Run your project


回答5:

I found a solution for this with my case on the iOS Developer Forums. It happened to me with Xcode 5. See Massive Linker Error Warnings (directory not found for option) yet . For me it was caused by Xcode 5 junking up the "Library Search Paths" build setting.



回答6:

Easy Solution :

It's work for me

when you want to add new files or folders to the project through xcode 5 and above error display.Just follow below simple step.(Please don't forgot to get backup of your project).

  1. Open your Project in Old XCode (I recommend XCode 4.6.3)
  2. Add your files or folder. (it will not mess your library search path as it mess in XCode 5)
  3. Close the old xcode and open your project with XCode 5 and start to code.


回答7:

I faced the same problem but was unable to fix it as per the steps since no library folders were getting displayed in the Project properties window.

So I solved it in another way (you need to be able to use the Terminal and the VIM editor. Also take a backup of the project just in case)

  1. Open a Terminal window
  2. Go to the project folder.
  3. The XCode project is a folder. use cd project name to go into that folder.
  4. use vim to open and edit the project.pbxproj file.
  5. Remove reference to the offending lines by searching using / and using the dd command on that line to delete it.
  6. Save using :wq command

Open the project in XCode and build. Works like a charm.



回答8:

I had to escape any spaces with a \

So for example:

/Users/Me/Folder\ with\ spaces\(and\ brackets\)

in Library Search Paths



回答9:

This worked for me :

Create this real directories (with no content), add them to project, remove via remove reference, clean, delete for real



回答10:

In project folder -> target , under 'Build Setting' search 'library search paths' and simply delete previous path in Debug & Release area.

Now add the line below line using + symbol

$(PROJECT_DIR)/Library

Note: After adding the above line click out from popup. its automatically display the full path.Then check this path with your Finder if any correction add after the $(PROJECT_DIR)/

Clean , Build and Run … Simple its cleared that error. :)

-Anup



标签: ios xcode