The linker warns that a search path directory was not found
ld: warning: directory not found for option '-L/Users/me/Project/build/Release-iphoneos'Short answer
The linker was told to search a folder that no longer exists. A -L option comes from Library Search Paths or Other Linker Flags, a -F option from Framework Search Paths. Find the exact path in the warning, locate the setting that holds it in every target, and remove or correct that entry.
Fix it fast
1Find out which cause you have
Print the search path settings for the target and look for the path from the warning.
xcodebuild -showBuildSettings -project MyApp.xcodeproj -scheme MyApp | grep "SEARCH_PATHS\|OTHER_LDFLAGS"2Match what you see, then jump to its fix
- 1
The warning says option '-L/some/path'A stale entry in Library Search Paths (-L)Fix - 2
The warning says option '-F/some/path'A stale entry in Framework Search Paths (-F)Fix - 3
The path in the warning stops at the first spaceA path with spaces that is not quotedFix - 4
The path is not in any search path setting, yet the warning remainsThe -L flag is hard-coded in Other Linker FlagsFix
- 1
What does the error look like?
ld: warning: directory not found for option '-L/Users/me/Project/build/Release-iphoneos'ld: warning: directory not found for option '-F/Users/me/Project/Frameworks'
Cause 1 of 4
A stale entry in Library Search Paths (-L)
1Check
Library Search Paths is the list of folders the linker searches for libraries. A project moved to another machine or a deleted build folder leaves old absolute paths behind.
xcodebuild -showBuildSettings -project MyApp.xcodeproj -scheme MyApp | grep "LIBRARY_SEARCH_PATHS"2Fix
In the target's Build Settings, open Library Search Paths and delete or correct the entry. The value can come from the target, the project or a build configuration file: select the Levels filter in Build Settings to see which level holds it, and delete it there.
# Build Settings > Search Paths > Library Search Paths: remove the stale line3Verify
Build again and confirm the warning no longer appears.
xcodebuild -project MyApp.xcodeproj -scheme MyApp build 2>&1 | grep "directory not found"Confirmed by developer.apple.com
Cause 2 of 4
A stale entry in Framework Search Paths (-F)
1Check
Framework Search Paths lists folders searched for frameworks, by the compiler and by the linker. A folder of vendor frameworks that you moved or deleted shows up here.
xcodebuild -showBuildSettings -project MyApp.xcodeproj -scheme MyApp | grep "FRAMEWORK_SEARCH_PATHS"2Fix
Remove the dead path or point it at the folder where the frameworks now live. Prefer a path relative to the project over an absolute path from one machine.
FRAMEWORK_SEARCH_PATHS = $(inherited) /path/to/Frameworks3Verify
The build log is free of the warning.
xcodebuild -project MyApp.xcodeproj -scheme MyApp build 2>&1 | grep "directory not found"Confirmed by developer.apple.com
Cause 3 of 4
A path with spaces that is not quoted
1Check
Paths in these settings are separated by whitespace, so a path with a space must be quoted. Without quotes, the linker sees two broken paths.
xcodebuild -showBuildSettings -project MyApp.xcodeproj -scheme MyApp | grep "SEARCH_PATHS"2Fix
Quote each path that contains spaces.
LIBRARY_SEARCH_PATHS = $(inherited) "/path/with space/Libraries"3Verify
Build again; the truncated paths no longer appear in the warning.
xcodebuild -project MyApp.xcodeproj -scheme MyApp build 2>&1 | grep "directory not found"Confirmed by developer.apple.com
Cause 4 of 4
The -L flag is hard-coded in Other Linker Flags
1Check
Options in Other Linker Flags are passed straight to the linker, so a -L entry there produces the same warning.
xcodebuild -showBuildSettings -project MyApp.xcodeproj -scheme MyApp | grep "OTHER_LDFLAGS"2Fix
Delete the dead -L option from Other Linker Flags, or replace it with the correct path.
OTHER_LDFLAGS = $(inherited) -lz3Verify
The warning is gone after a clean build.
xcodebuild -project MyApp.xcodeproj -scheme MyApp clean build 2>&1 | grep "directory not found"Confirmed by developer.apple.com
How do I stop it coming back?
- Use project-relative paths, not absolute paths from one machine.
- Delete search path entries when you remove a library or framework from a project.
- Check every target (app, tests, extensions) when you clean up build settings.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
Xcode fails to link with 'library not found for -lPods' or 'framework not found Pods'
ld: library not found for -lPods-MyApp
The linker is looking for the Pods library and nothing is there to link.
4 causes, each with a fixMobile apps
UserDefaults logs 'Failed to read values in CFPrefsPlistSource' for an app group
Settings saved by the app are not visible to its extension, widget or sibling app that share the group
This log comes from the preferences system when UserDefaults is opened for an app group's suite.
3 causes, each with a fixMobile apps
iOS app crashes: Google Maps SDK must be initialized via provideAPIKey
Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use
The Maps SDK throws this when a Maps object is created before GMSServices.provideAPIKey has run.
3 causes, each with a fixMobile apps
UIKit app crashes because it cannot find the storyboard
Could not find a storyboard named 'Main' in bundle NSBundle
UIStoryboard throws this exception when no storyboard file with that name exists in the bundle it searches.
3 causes, each with a fixMobile apps
Firebase on iOS asks for the FCM token before APNs has given one
Be sure to re-retrieve the FCM token once the APNS device token is set.
The Firebase Messaging SDK needs the APNs device token from iOS before it hands out an FCM token.
3 causes, each with a fixMobile apps
A test push from the Firebase console never shows up on the iPhone
didReceiveRegistrationToken prints a token, yet no notification arrives
When a console message is accepted but the iPhone stays silent, the break is between Firebase and APNs or inside the app.
4 causes, each with a fix