添加自定义DehancerNavigation.framework后出现框架未找到错误
I'm learning framework development, and have completed these steps:
- Created a standalone Cocoa Framework project
- Migrated code and successfully compiled to generate
DehancerNavigation.framework - Added this framework to a new blank test project's Embedded Binaries (under the General tab), and it also appeared in the Linked Frameworks and Libraries list automatically
However, when compiling the test project, I get this linker error:
Ld /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Products/Debug/DehancerNavigationTestUsageProject.app/Contents/MacOS/DehancerNavigationTestUsageProject normal x86_64
cd /Users/yefim/Documents/Projects/DehancerNavigationTestUsageProject
export MACOSX_DEPLOYMENT_TARGET=10.13
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -L/Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Products/Debug -F/Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Products/Debug -filelist /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Intermediates.noindex/DehancerNavigationTestUsageProject.build/Debug/DehancerNavigationTestUsageProject.build/Objects-normal/x86_64/DehancerNavigationTestUsageProject.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -mmacosx-version-min=10.13 -Xlinker -object_path_lto -Xlinker /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Intermediates.noindex/DehancerNavigationTestUsageProject.build/Debug/DehancerNavigationTestUsageProject.build/Objects-normal/x86_64/DehancerNavigationTestUsageProject_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -Xlinker -add_ast_path -Xlinker /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Intermediates.noindex/DehancerNavigationTestUsageProject.build/Debug/DehancerNavigationTestUsageProject.build/Objects-normal/x86_64/DehancerNavigationTestUsageProject.swiftmodule -framework DehancerNavigation -Xlinker -dependency_info -Xlinker /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Intermediates.noindex/DehancerNavigationTestUsageProject.build/Debug/DehancerNavigationTestUsageProject.build/Objects-normal/x86_64/DehancerNavigationTestUsageProject_dependency_info.dat -o /Users/yefim/Library/Developer/Xcode/DerivedData/DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp/Build/Products/Debug/DehancerNavigationTestUsageProject.app/Contents/MacOS/DehancerNavigationTestUsageProjectld: framework not found DehancerNavigation
clang: error: linker command failed with exit code 1 (use -v to see invocation).
What additional configurations do I need to make to use this framework successfully?
Solutions to Fix the Framework Link Error
Let’s walk through the most common fixes for this linker issue:
1. Verify Framework Path & Update Framework Search Paths
Xcode can’t find your framework because it’s looking in the wrong directory. Here’s how to fix it:
- First, move the
DehancerNavigation.frameworkto a stable location relative to your test project (like a dedicatedFrameworksfolder inside your test project’s directory). Avoid leaving it in the framework project’s build folder—this path changes when you clean builds. - Open your test project’s Build Settings, search for
Framework Search Paths. Add the path to the folder containing your framework using a relative path like$(PROJECT_DIR)/Frameworks(adjust if you placed it elsewhere). Check therecursivebox if needed.
2. Confirm Framework Architecture Matches Your Test Project
Your test project is compiling for x86_64 (as seen in the error log), so your framework must support this architecture. To check:
- Open Terminal, navigate to the folder with
DehancerNavigation.framework, then run:lipo -info DehancerNavigation.framework/DehancerNavigation - If
x86_64isn’t listed, go back to your framework project’s Build Settings:- Set
ArchitecturestoStandard Architectures (x86_64, arm64)(or justx86_64if you only need Intel Mac support) - Set
Build Active Architecture OnlytoNofor the Debug configuration (so it builds all required architectures)
- Set
- Recompile the framework and re-add it to your test project.
3. Double-Check Embedding Configuration
Even if the framework shows up in Linked Frameworks, improper embedding can cause path issues:
- Go to your test project’s Build Phases tab.
- Look for the
Embed Frameworksphase. Make sureDehancerNavigation.frameworkis listed here, with the Embed setting set toEmbed & Sign. - If it’s missing, drag the framework from the Project Navigator into the
Embed Frameworksphase—this will automatically update Linked Frameworks too.
4. Clean Xcode Cache
Corrupted derived data often causes weird linker glitches. Let’s clear it:
- Go to Xcode > Preferences > Locations, click the arrow next to the Derived Data path to open the folder. Delete the folder for your test project (
DehancerNavigationTestUsageProject-eqegtcmqsajracgiyxgidupllvbp). - Back in Xcode, press
Cmd + Shift + Kto clean the build folder. - Rebuild your test project.
After trying these steps, your linker error should be resolved. If you’re still stuck, double-check that you didn’t rename the framework after compiling—Xcode relies on exact naming for linking.
内容的提问来源于stack exchange,提问作者Efim Plotnikov

