简体   繁体   English

iPhone ARC和Facebook SDK

[英]iPhone ARC & Facebook SDK

I'm getting all kinds of build errors with Facebook's SDK because my app uses ARC. 因为我的应用程序使用ARC,我在Facebook的SDK中遇到了各种构建错误。 I try to remove the Facebook files from the compiler to avoid this, but I get an Apple Mach-O error when I remove the Facebook.m file. 我尝试从编译器中删除Facebook文件以避免这种情况,但是当我删除Facebook.m文件时出现Apple Mach-O错误。 If I put that back in the compile sources, I get the ARC errors. 如果我把它放回编译源中,我会收到ARC错误。

Anyone run into this? 有人碰到这个吗?

Do you exclude them from arc with Compiler flag -fno-objc-arc ? 你用Compiler标志-fno-objc-arc从弧中排除它们吗? You can see a Answer here 你可以在这里看到答案

And this is why distributing a shared library by copy and pasting files is bad . 这就是为什么通过复制和粘贴文件来分发共享库的原因很糟糕 A library should be distributed as it's own Xcode projects with a static library target, so that the build setting requirements of your projects and the libraries you use can not screw up one or the other. 应该使用静态库目标来分发库,因为它自己的Xcode项目,因此项目的构建设置要求和您使用的库不能搞砸其中一个。

File a bug for the Facebook SDK here: https://github.com/facebook/facebook-ios-sdk/issues 在此处提交Facebook SDK的错误: https//github.com/facebook/facebook-ios-sdk/issues

And in the mean time add the -fno-objc-arc flag to the implementation files in the Facebook SDK. 同时将-fno-objc-arc标志添加到Facebook SDK中的实现文件中。 You can do this by; 你可以这样做;

  1. Select your application target 选择您的应用目标
  2. Go to the Build Phases tab 转到Build Phases选项卡
  3. Add for each file under the Compile Sources section. 为“ 编译源”部分下的每个文件添加。

The new SDK does not explicitly support ARC out of the box, but there is a shell scrip to build a static library that can be used within your ARC project. 新的SDK没有明确支持开箱即用的ARC,但是有一个shell脚本可以构建一个可以在ARC项目中使用的静态库。 Just navigate to your local git repo and run 只需导航到您当地的git仓库并运行即可

% ~/facebook-ios-sdk/scripts/build_facebook_ios_sdk_static_lib.sh

This will create the static library under the /lib/facebook-ios-sdk folder (eg ~/facebook-ios-sdk/lib/facebook-ios-sdk). 这将在/ lib / facebook-ios-sdk文件夹下创建静态库(例如〜/ facebook-ios-sdk / lib / facebook-ios-sdk)。 You may then drag the facebook-ios-sdk folder into the app Xcode project to include the iOS Facebook SDK static library. 然后,您可以将facebook-ios-sdk文件夹拖到应用程序Xcode项目中,以包含iOS Facebook SDK静态库。

there are actually very few changes needed to make the Facebook iOS sdk compatible with ARC. 实际上,只需很少的更改就可以使Facebook iOS sdk与ARC兼容。 I have made the changes in my code , but , I do not know who to send it back to the community, any pointers ? 我已经在我的代码中进行了更改,但是,我不知道将其发回给社区的人,有什么指针吗?

here is a post I made to explain how to use it with ARC the simple way on Xcode 4.2: http://nabtech.wordpress.com/2012/02/02/facebook-ios-sdk-and-arc/ 这是我在Xcode 4.2上用简单的方法解释如何使用ARC的一篇文章: http//nabtech.wordpress.com/2012/02/02/facebook-ios-sdk-and-arc/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM