views:

109

answers:

2

I'm looking to remove the Facebook API from my iPhone project for 2 reasons:

1) My Facebook functionality is unfinished and I'd like to submit the app minus ALL of the FB functionality 2) I don't want to include the Facebook API as it contains encryption and I don't want to fill out additional forms etc.

So. I need a simple way to remove all of my Facebook functionality and not put build the facebook API as part of the binary. I was thinking of commenting out my FB code... but how do I disconnect the FB api so that I can easily put it back in later?

Thanks!

+1  A: 

You could use conditional compilation. You use #ifdef and #endif statements to surround blocks of code that you want to exclude. These blocks will only be compiled if the specified constant is defined.

#define FACEBOOK 1

#if FACEBOOK
    // Facebook code here.
#endif

This way, you can just remove the constant and all your Facebook code will not be compiled. To add your Facebook stuff back in, just and the constant again.

Check out this article on objective-C conditional compilation for more details.

Simon P Stevens
This is perfect! Any idea about actually telling the app not to build the referenced Facebook API too? I believe this is a property thing, not something I can define in code?
mac_55
@mac_55: No, sorry. I don't actually do iPhone dev, it just happens conditional compilation is a pretty common technique. Usually everything is defined in some kind of project file somewhere, if this project file is in a nice open format (like XML etc) you might be able to open it up and modify it to remove the references, and just keep a copy of the original file. Try opening up non-code files and see what you can find. (Sorry, poor suggestion I know, but it's the best I've got)
Simon P Stevens
+1  A: 

Hi,

I think that the easiest way to remove it from the finished binary is to make a new target and remove the files from the Compiled Sources section.

The way to do that is to right click on your app in the Targets group and choose Duplicate. Then all you have to do is remove the facebook files from the Compiled Sources and build that target.

The build will probably fail as you will have to comment out / #define out any code that refers to the facebook api i.e. button event handlers etc.

When you are ready to put it back in, just change target back to your original one again.

deanWombourne