Facebook SDK 3.0 HelloFacebookSample构建错误 [英] Facebook SDK 3.0 HelloFacebookSample build errors

查看:95
本文介绍了Facebook SDK 3.0 HelloFacebookSample构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编译Facebook SDK 3.0随附的HelloFacebookSample应用程序时遇到问题.

I'm having trouble compiling the HelloFacebookSample app that comes with Facebook SDK 3.0.

首先,我应该说我正在使用Xcode 4.0.2,iOS SDK 4.3和OS X 10.6.8. (我一直在努力寻找一种无需升级到Lion或Mountain Lion即可下载Xcode 4.2的方法,我不愿意这样做.)

Firstly, I should say I'm using Xcode 4.0.2, iOS SDK 4.3 and OS X 10.6.8. (I'm struggling to find a way to download Xcode 4.2 without upgrading to Lion or Mountain Lion, which I'm reluctant to do.)

当我尝试构建示例项目时,出现以下构建错误:

When I try to build the sample project, I get the following build errors:

1)程序中出现意外的"@"

1) Unexpected '@' in program

int main(int argc, char *argv[])
{
    @autoreleasepool {    // error on this line
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([HFAppDelegate class]));
    }
}

2)预期标识符

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBSession.activeSession handleOpenURL:url];    // error on this line
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // FBSample logic
    // if the app is going away, we close the session object
    [FBSession.activeSession close];                       // error on this line
}

我可以解决"这些问题(不确定是否正确解决了这些问题),但是随后出现以下链接错误:

I can "resolve" these problems (not sure if I resolved them correctly), but then I then get the following linking error:

找不到框架帐户

Framework not found Accounts

命令/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang失败,退出代码为1

有人可以帮我吗?如果我什至无法构建示例项目,我将不会很幸运将Facebook集成到我的应用程序中!

Can anyone help me at all? I won't have much luck integrating Facebook into my app if I can't even build the sample projects!

推荐答案

我解决了所有问题.看来该示例并不立即与iOS 4.3或Xcode 4.0.2兼容.这是我所做的:

I resolved all the issues. It appears the sample is not immediately compatible with iOS 4.3 or Xcode 4.0.2. Here's what I did:

1)程序中的@意外;更改为以下内容:

1) Unexpected @ in program; changed to the following:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([HFAppDelegate class]));
}

2)预期标识符;替换

2) Expected identifier; replaced

    return [FBSession.activeSession handleOpenURL:url];    // error on this line
...
    [FBSession.activeSession close];                       // error on this line

使用

    return [[FBSession activeSession] handleOpenURL:url];
...
    [[FBSession activeSession] close];

3)找不到框架帐户;事实证明它不是必需的,所以我只是从项目导航器的框架"组中删除了该框架.

3) Framework not found Accounts; turns out it's not required, so I just deleted the framework from the Frameworks group in the Project Navigator.

4)我忘了在原始帖子中说:关键字strong是未知的,因此我在文件 FacebookSDK/FacebookSDK.h 的顶部将其作为retain宏如下:

4) I forgot to say in my original post: keyword strong was unknown, so I macro'd it as retain at the top of the file FacebookSDK/FacebookSDK.h as follows:

#define strong retain

现在,HelloFacebookSample应用程序可以编译,没有错误或警告,并且可以正常运行.与Facebook的所有互动均有效.

And now the HelloFacebookSample app compiles with no errors or warnings and it works fine. All interactions with Facebook work.

希望这对以后的人有所帮助!如果有帮助,请投票!

Hope this helps someone else in the future! If it helps you, please vote it up!

这篇关于Facebook SDK 3.0 HelloFacebookSample构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆