Removing facebook API from my project
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!
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.
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.
精彩评论