React Native集成react-native-fbsdk-next遇FBSDKCoreKit加载失败求助
React Native集成
react-native-fbsdk-next时iOS端运行报错问题 我正尝试在React Native应用中集成react-native-fbsdk-next库以实现Facebook登录按钮功能。已按照Facebook的安装指南完成iOS端Facebook SDK的配置,应用编译成功,但运行时出现如下错误:
dyld[54430]: Library not loaded:@rpath/FBSDKCoreKit.framework/FBSDKCoreKit Referenced from: /Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/react_native_fbsdk_next.framework/react_native_fbsdk_next Reason: tried: '/Users/user/Library/Developer/Xcode/DerivedData/eCommercialApp-dehghjkotvmxkidrbfdhdrffgutk/Build/Products/Debug-iphonesimulator/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/Xcode/DerivedData/eCommercialApp-dehghjkotvmxkidrbfdhdrffgutk/Build/Products/Debug-iphonesimulator/PackageFrameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/react_native_fbsdk_next.framework/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/usr/lib/swift/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file) Library not loaded: @rpath/FBSDKCoreKit.framework/FBSDKCoreKit Referenced from: /Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-4795-8218-83D7D7F9F778/eCommercialApp.app/Frameworks/react_native_fbsdk_next.framework/react_native_fbsdk_next Reason: tried: '/Users/user/Library/Developer/Xcode/DerivedData/eCommercialApp-dehghjkotvmxkidrbfdhdrffgutk/Build/Products/Debug-iphonesimulator/FBSDKCoreKit.framework/FBSDKCoreKit' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'arm64,x86_64', need 'x86_64')), '/Users/user/Library/Developer/Xcode/DerivedData/eCommercialApp-dehghjkotvmxkidrbfdhdrffgutk/Build/Products/Debug-iphonesimulator/PackageFrameworks/FBSDKCoreKit.framework/FBSDKCoreKit' (no such file), '/Users/user/Library/Developer/CoreSimulator/Devices/B0556C9E-4F68-4C77-9C53-17AC58D85278/data/Containers/Bundle/Application/97EBA641-370F-47 (lldb)
解决方案尝试
1. 彻底清理缓存与重建项目
- 关闭Xcode,执行以下命令清理React Native和CocoaPods缓存:
rm -rf node_modules package-lock.json yarn.lock npm install cd ios pod deintegrate rm -rf Podfile.lock Pods pod install cd .. - 删除Xcode派生数据:打开Xcode → 顶部菜单栏
Xcode→Preferences→Locations→ 点击Derived Data右侧的箭头,删除当前项目的文件夹。
2. 修正架构兼容性设置
从错误信息可见,框架存在架构不兼容问题(提示包含arm64、x86_64但需要x86_64):
- 打开Xcode项目,选中主应用target →
Build Settings - 找到
Architectures选项:- 设置
Architectures为Standard Architectures (arm64, x86_64) - 展开
Excluded Architectures,在Debug-iphonesimulator配置下添加arm64
- 设置
- 同样检查
react-native-fbsdk-next的target架构设置,确保和主应用保持一致。
3. 验证FBSDKCoreKit的集成与嵌入设置
- 确认Podfile中已正确引入Facebook SDK依赖,示例:
pod 'FBSDKCoreKit', '~> 17.0' pod 'FBSDKLoginKit', '~> 17.0' - 执行
pod install后,检查Pods目录下是否存在FBSDKCoreKit.framework - 在Xcode的
Frameworks, Libraries, and Embedded Content中,确保FBSDKCoreKit.framework已添加,且Embed选项设置为Embed & Sign
4. 检查运行路径配置
- 选中主应用target →
Build Settings→Runpath Search Paths - 确保路径列表中包含
@executable_path/Frameworks和@loader_path/Frameworks,如果没有则添加。
内容的提问来源于stack exchange,提问作者TranPhu
相关产品推荐
相关产品推荐

