Dejell
Dejell

Reputation: 14317

Facebook iOS 3.7 FacebookAppId

I just installed from pkg the SDK 3.7 for Facebook.

I see that I need to put there a value for FacebookAppId. However I have 2 apps: one for testing and one for production.

Since I need to support variables for Debug and Release, I am using an Environment file which determines the value based on the configuration value. (Debug or Release)

How can I "tell" the SDK to use the relevant one for each release type, without changing it manually when building it?

I didn't check in the source code. Just the compiled one.

Is there a way to do it?

Upvotes: 2

Views: 555

Answers (3)

Naz Mir
Naz Mir

Reputation: 1028

Here's a simpler approach,

Recent Xcode project templates already have a DEBUG=1 macro defined for the Debug build configuration.

enter image description here

You can use it in combination with #ifdef

#ifdef DEBUG
    #define FACEBOOK_APP_ID                     @"FB_DEVELOPMENT_ID"

#else
    #define FACEBOOK_APP_ID                     @"FB_PRODUCTION_ID"
#endif

Upvotes: 0

Nilesh Patel
Nilesh Patel

Reputation: 6394

You can use the Preprocessor macros over here..

How to use it :

  1. Go to Build settings of your project.

  2. Search "Preprocessor macros". Here define your macros like for eg FBDebugAPPID for debug moed & FBReleaseAPPID for release mode.

  3. FBSettings class used to override the default facebook AppId.

    Then after add below code in your delegate method..

    #if defined(FBDebugAPPID)
    **Use your debug app id**
    [FBSettings setDefaultAppID:@"DEBUGAPPId"]
    #elif defined(FBReleaseAPPID)
    **Use your release app id**
    [FBSettings setDefaultAppID:@"RELEASEAPPId"]
    #endif
    

Hope it resolve your problem..

Upvotes: 1

Simon
Simon

Reputation: 18073

You can change you enviornment.plist variables by adding a run script build phase

To add a Run Script Build Phase in Xcode

  1. Select your application target in your project, then select "Build Phases".
  2. In the menu bar, click "Editor", select "Add Build Phase", and then click on "Add Run Script Build Phase".
  3. You should now see a Run Script section in the middle of your Build Phase options, as shown above.
  4. Inside the body of the Run Script Build Phase, paste in the script.
#!/bin/bash
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :FacebookAppID 321" "$INFOPLIST_FILE"
else
/usr/libexec/PlistBuddy -c "Set :FacebookAppID 321" "$INFOPLIST_FILE"
fi

Upvotes: 0

Related Questions