I’m having trouble compiling the HelloFacebookSample app that comes with Facebook SDK 3.0.
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) Unexpected ‘@’ in program
int main(int argc, char *argv[])
{
@autoreleasepool { // error on this line
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HFAppDelegate class]));
}
}
2) Expected identifier
- (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
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
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!
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) Unexpected @ in program; changed to the following:
2) Expected identifier; replaced
with
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) I forgot to say in my original post: keyword
strongwas unknown, so I macro’d it asretainat the top of the file FacebookSDK/FacebookSDK.h as follows: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!