Fix: ‘directory not found for option’ Warning in Xcode

Fix: 'directory not found for option' Warning in Xcode

Written by

in

Quick answer: This warning occurs when Xcode passes a deleted or moved folder path to the linker using the -L (libraries) or -F (frameworks) flag. Open your Target’s Build Settings, search for ‘Library Search Paths’ (for -L) or ‘Framework Search Paths’ (for -F), and remove the invalid or empty directory entries.

Why this happens

During compilation, Xcode invokes the Apple linker (ld) and provides flags instructing it where to locate precompiled binaries and dependencies. When you see the warning ld: warning: directory not found for option '-L...' or ld: warning: directory not found for option '-F...', the linker was told to check a directory that no longer exists on disk.

The flag prefix indicates the specific build setting responsible for the path:

  • -L specifies a Library Search Path (LIBRARY_SEARCH_PATHS). The linker is looking for static libraries (.a) or dynamic libraries (.dylib).
  • -F specifies a Framework Search Path (FRAMEWORK_SEARCH_PATHS). The linker is looking for compiled Apple frameworks (.framework or .xcframework).
  • -I (less common at link time, but appears during compilation) specifies a Header Search Path (HEADER_SEARCH_PATHS).

This issue typically appears after deleting a third-party SDK, moving project files to a new directory, checking out a repository on another developer’s machine, or modifying CocoaPods / Carthage configurations. Xcode automatically adds search paths when you drag binaries into a project, but it does not automatically delete those paths when you remove the files.


How to fix it

1. Delete stale entries from Build Settings

Inspect your build settings to find and remove the path printed in the warning.

  1. In Xcode’s Project Navigator (left sidebar), select the blue project file at the top.
  2. In the main pane, select your target under Targets.
  3. Click on the Build Settings tab and make sure All and Combined (or Levels) are selected.
  4. In the filter search bar in the top-right corner, search for the setting indicated by the flag:
    * Search for Library Search Paths if your warning begins with -L.
    * Search for Framework Search Paths if your warning begins with -F.
  5. Double-click the value field next to the setting to open the path pop-up list.
  6. Select the invalid path (often highlighted or referencing a deleted folder such as Downloads or an old SDK) and click the minus (-) button to remove it.
  7. Check for empty rows. A blank row will resolve to an invalid directory flag. Select any empty lines and press delete.
  8. Repeat this check under Project (above Targets) to verify the path wasn’t defined at the project level.

2. Clean the build folder

After modifying search paths, clear any cached build products so the linker runs fresh.

  1. Go to the menu bar and choose Product > Clean Build Folder (or press Cmd + Shift + K).
  2. Rebuild your project (Cmd + B).
  3. Check the Report Navigator (the speech-bubble tab in the left sidebar) to confirm the warning is gone.

3. Check configuration files (.xcconfig)

If the build setting field is populated from an external configuration file (such as one generated by CocoaPods), the path will not be editable directly through the Xcode UI.

  1. In the Project Navigator, check for .xcconfig files linked to your project.
  2. Search your project for the missing path using the Find navigator (Cmd + Shift + F).
  3. If CocoaPods manages the settings, run the following in your terminal:
pod deintegrate
pod install

This removes stale CocoaPods paths and regenerates clean .xcconfig files based on your current Podfile.

4. Remove ghost entries directly from project.pbxproj

Sometimes an empty string or malformed quote remains in Xcode’s internal project file without showing up clearly in the GUI.

  1. Close Xcode completely.
  2. Right-click your .xcodeproj bundle in Finder and select Show Package Contents.
  3. Open project.pbxproj in a text editor (such as TextEdit or VS Code).
  4. Search for LIBRARY_SEARCH_PATHS or FRAMEWORK_SEARCH_PATHS.
  5. Look for lines matching the path cited in your build log, or lines containing "" (empty string entries).
  6. Delete those lines, save the file, and reopen your project in Xcode.

How to prevent it

  • Clean search paths when deleting dependencies: When manually removing a framework or .a file from your project, immediately visit Build Settings to delete its corresponding search path.
  • Use Swift Package Manager: Swift Package Manager handles dependencies and search paths automatically without adding hardcoded absolute paths to your project file.
  • Avoid absolute user paths: Never leave paths containing /Users/username/... or /Downloads/... in your project settings. Always use build variables like $(PROJECT_DIR) or $(SRCROOT) with recursive lookups disabled if local files are required.

FAQ

Does this warning break app distribution or cause App Store rejection?

No. The warning alone will not prevent your app from passing validation or uploading to App Store Connect. However, it indicates a misconfigured build setup that can mask missing dependency errors or slow down build times.

What is the difference between the -L and -F linker flags?

The -L flag tells the linker which directories to search for raw static libraries (.a) or dynamic libraries (.dylib). The -F flag tells the linker which directories to search for packaged Apple frameworks (.framework or .xcframework).

Why does the warning persist after I deleted the path in Build Settings?

Check both the Target and Project levels in Build Settings, as well as any active .xcconfig files. If any level defines the path, Xcode will still pass it to the linker. Remember to perform a Clean Build Folder (Cmd + Shift + K) after making adjustments.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 3.0; this article is shared under the same license.