xcode React Native facebook iOS sdk 构建失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38963594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
React native facebook iOS sdk build failed
提问by Alaa Attya Mohamed
I've follow all the guidelines listed on Facebook developer guide for the iOS react native sdk but i'm still unable to build the app. Attached a screenshot of my config and the build log
我已遵循 Facebook 开发人员指南中列出的所有 iOS React Native sdk 指南,但我仍然无法构建应用程序。附上我的配置和构建日志的屏幕截图
Ld /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/Alnomad.app/Alnomad normal x86_64 cd /Applications/MAMP/htdocs/marscodes/alnomad-ios/ios export IPHONEOS_DEPLOYMENT_TARGET=8.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -L/Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator -F/Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator -F/Applications/MAMP/htdocs/marscodes/alnomad-ios/ios/../node_modules/react-native-facebook-login/FacebookSDK -F/Applications/MAMP/htdocs/marscodes/alnomad-ios/ios -F. -FAlnomad -FAlnomadTests -Fbuild -FFacebookSDK -Fbuild/Build -Fbuild/Logs -FFacebookSDK/AccountKitStrings.bundle -FFacebookSDK/DocSets -FFacebookSDK/FacebookSDKStrings.bundle -FFacebookSDK/Samples -Fbuild/Logs/Build -FFacebookSDK/AccountKitStrings.bundle/Resources -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset -FFacebookSDK/FacebookSDKStrings.bundle/Resources -FFacebookSDK/Samples/Configurations -FFacebookSDK/Samples/FBAudienceNetwork -FFacebookSDK/Samples/Iconicus -FFacebookSDK/Samples/RPSSample -FFacebookSDK/Samples/Scrumptious -FFacebookSDK/Samples/ShareIt -FFacebookSDK/Samples/SwitchUserSample -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents -FFacebookSDK/Samples/FBAudienceNetwork/AdUnitsSample -FFacebookSDK/Samples/FBAudienceNetwork/NativeAdSample -FFacebookSDK/Samples/Iconicus/Configurations -FFacebookSDK/Samples/Iconicus/Iconicus -FFacebookSDK/Samples/RPSSample/RPSSample -FFacebookSDK/Samples/Scrumptious/scrumptious -FFacebookSDK/Samples/ShareIt/ShareIt -FFacebookSDK/Samples/SwitchUserSample/SwitchUserSample -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources -FFacebookSDK/Samples/FBAudienceNetwork/AdUnitsSample/AdUnitsSample -FFacebookSDK/Samples/FBAudienceNetwork/NativeAdSample/NativeAdSample -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Classes -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Constants -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents/css -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents/img -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Protocols -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents/Classes -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents/Constants -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents/css -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents/img -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS.docset/Contents/Resources/Documents/Protocols -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Classes -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Constants -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents/css -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents/img -FFacebookSDK/DocSets/FacebookSDK-4_13-for-iOS.docset/Contents/Resources/Documents/Protocols -F/Applications/MAMP/htdocs/marscodes/alnomad-ios/ios/FacebookSDK -filelist /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Intermediates/Alnomad.build/Debug-iphonesimulator/Alnomad.build/Objects-normal/x86_64/Alnomad.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -ObjC -lc++ -fobjc-arc -fobjc-link-runtime /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libReact.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTActionSheet.a -framework FBSDKLoginKit /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTGeolocation.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTImage.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTLinking.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTNetwork.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTSettings.a -framework FBSDKShareKit /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTText.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTVibration.a /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/libRCTWebSocket.a -lRNVectorIcons -framework FBSDKCoreKit -lRNI18n -lRCTFBSDK -Xlinker -dependency_info -Xlinker /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Intermediates/Alnomad.build/Debug-iphonesimulator/Alnomad.build/Objects-normal/x86_64/Alnomad_dependency_info.dat -o /Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator/Alnomad.app/Alnomad
ld: warning: Auto-Linking supplied 'FacebookSDK/Bolts.framework/Bolts', framework linker option at FacebookSDK/Bolts.framework/Bolts is not a dylib Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FBSDKHashtag", referenced from: objc-class-ref in libRCTFBSDK.a(RCTConvert+FBSDKSharingContent.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
sdk -L/Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr/Build/Products/Debug-iphonesimulator -F/Users/alaaattya/Library/Developer/Xcode/DerivedData/Alnomad-fcoerljazsnnxbggcygydgyxmimr调试iphonesimulator -F/Applications/MAMP/htdocs/marscodes/alnomad-ios/ios/../node_modules/react-native-facebook-login/FacebookSDK -F/Applications/MAMP/htdocs/marscodes/alnomad-ios/ios -F。-FAlnomad -FAlnomadTests -Fbuild -FFacebookSDK -Fbuild/Build -Fbuild/Logs -FFacebookSDK/AccountKitStrings.bundle -FFacebookSDK/DocSets -FFacebookSDK/FacebookSDKStrings.bundle -FFacebookSDK/Samples -Fbuild/Logs/Build -FFacebookSDK/AccountKitStrings.bundle/Resources -FFacebookSDK/DocSets/FacebookAudienceNetworkSDK-4_13-for-iOS.docset -FFacebookSDK/DocSets/FacebookMessengerShareKitSDK-1_3-for-iOS。
ld:警告:自动链接提供了“FacebookSDK/Bolts.framework/Bolts”,FacebookSDK/Bolts.framework/Bolts 上的框架链接器选项不是 dylib 架构 x86_64 的未定义符号:“_OBJC_CLASS_$_FBSDKHashtag”,引用自:objc- libRCTFBSDK.a(RCTConvert+FBSDKSharingContent.o) 中的类引用:ld:找不到架构 x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
回答by tropicalfish
I am recently doing the same thing on my react native project and I have spent quite some time to make it work too.
我最近在我的 React Native 项目上做同样的事情,我也花了相当多的时间让它工作。
Your case seems to be that you did not include Bolts.framework, a dependency of the FBSDKCoreKit.framework, in your project folder. I believe that's the reason why the Facebook official doc recommends everyone to keep the SDK files in ~/Documents, so you don't miss dependency files, or having to duplicate these files on each of your project.
您的情况似乎是您没有在项目文件夹中包含Bolts.framework, 的依赖项FBSDKCoreKit.framework。我相信这就是为什么 Facebook 官方文档建议大家将 SDK 文件保存在~/Documents.
Below are some troubleshooting steps for anyone who is having issues with the integration:
以下是一些遇到集成问题的人的一些故障排除步骤:
1. Link react-native-fbsdkto your project. (Edit: As of lately, linking doesn't work with the SDK. According to @chez.mosey's answer below, you may follow steps in this blogto manually add the SDK to your project.)
1. 链接react-native-fbsdk到您的项目。(编辑:最近,链接不适用于 SDK。根据下面@chez.mosey 的回答,您可以按照本博客中的步骤手动将 SDK 添加到您的项目中。)
rnpm link react-native-fbsdk
rnpm link react-native-fbsdk
react-native link react-native-fbsdk
Edit: rnpmhas been integrated into React Native since 1 Aug, 2016. From then on, use react-native linkto link your dependencies.
编辑:rnpm自 2016 年 8 月 1 日起已集成到 React Native 中。从那时起,用于react-native link链接您的依赖项。
The linkfunction updates your project by linking all native dependencies, and in this case, we link react-native-fbsdkto the native FacebookSDK.
该link函数通过链接所有本机依赖项来更新您的项目,在本例中,我们链接react-native-fbsdk到本机 FacebookSDK。
2. Add libRCTFBSDK.ato Build Phases -> Link Binary with Libraries in Xcode.
2. 添加libRCTFBSDK.a到 Build Phases -> Link Binary with Libraries in Xcode。
This should be automatically added when you run react-native link, but make sure it's there.
这应该在您运行时自动添加react-native link,但请确保它在那里。
3. Import FacebookSDK framework files manually
3.手动导入FacebookSDK框架文件
Speaking from experience, if you are using Cocoapods to download the FBSDK framework files, Xcode won't build them along with libRCTFBSDK.a. Follow the steps in the official FB doc, download the files, unzip them to ~/Documents/FacebookSDK, and drag them to your Xcode project without copying them. Add the path to your framework search path.
(If anyone knows the reason why Cocoapods won't work, I'm all ears)
根据经验,如果您使用 Cocoapods 下载 FBSDK 框架文件,Xcode 不会将它们与libRCTFBSDK.a. 按照官方 FB 文档中的步骤,下载文件,~/Documents/FacebookSDK将它们解压到. 将路径添加到您的框架搜索路径。(如果有人知道 Cocoapods 不起作用的原因,我全神贯注)
4. Clean your Xcode project and delete derived data
4.清理你的Xcode项目并删除派生数据
Do that to avoid having the previously built files messing with your current settings.
这样做可以避免以前构建的文件与您当前的设置混淆。
回答by Arpit Jain
When you download FacebookSDK from (https://developers.facebook.com/docs/ios/) the folder will be named as FacebookSDKs-iOS-4.20.1. So, try renaming it to FacebookSDK.
当您从 ( https://developers.facebook.com/docs/ios/)下载 FacebookSDK 时,该文件夹将被命名为 FacebookSDKs-iOS-4.20.1。因此,尝试将其重命名为 FacebookSDK。
Then clean and build your Xcode project again.
然后再次清理并构建您的 Xcode 项目。
回答by chez.mosey
As others have suggested, make sure your follow all of the configuration steps for the SDK here: https://developers.facebook.com/docs/react-native/configure-ios/
正如其他人所建议的,请确保您在此处遵循 SDK 的所有配置步骤:https: //developers.facebook.com/docs/react-native/configure-ios/
After doing this, I encountered the issue mentioned in the Troubleshooting section, "If you get a build error like 'Warning: Native component for 'RCTFBLikeView' does not exist,' verify that libRCTFBSDK.a shows up in the Link Binary with Libraries section of your build target's Build Phases." Which I believe is the issue you are encountering.
执行此操作后,我遇到了故障排除部分中提到的问题,“如果您收到类似'警告:'RCTFBLikeView' 的本机组件不存在'之类的构建错误,请验证 libRCTFBSDK.a 显示在链接二进制与库部分中构建目标的构建阶段。” 我相信这是您遇到的问题。
The problem is, I didn't know how to resolve the fact that libRCTFBSDK.a wasn't showing up. Turns out, it was because react-native-fbsdk wasn't linking properly, and thus I had to link it manually, which I was able to do following the wonderful steps provided here: http://www.namvo.me/manual-setup-for-facebook-sdk-in-react-native/
问题是,我不知道如何解决 libRCTFBSDK.a 没有出现的事实。原来,这是因为 react-native-fbsdk 没有正确链接,因此我不得不手动链接它,我能够按照此处提供的精彩步骤进行操作:http: //www.namvo.me/manual -setup-for-facebook-sdk-in-react-native/
回答by Zach
Make sure to download and keep the FacebookSDK folder on your computer (https://developers.facebook.com/docs/ios/). I usually place it in ~/Documents/FacebookSDK and reference it from the build settings. This is in addition to dragging over the 3 framework files into the Frameworks folder.
确保在您的计算机上下载并保留 FacebookSDK 文件夹(https://developers.facebook.com/docs/ios/)。我通常将它放在 ~/Documents/FacebookSDK 并从构建设置中引用它。这是将 3 个框架文件拖入 Frameworks 文件夹的补充。


