Auth0.plist for iOS with different keys per stage

Can I set the keys with code rather then the auto load form auth0.plist?

I need to set them differently depending on build scheme, ie. dev and prod.

Or can I add them to the Info.plist instead somehow, since I do have individual Info.plist per stage.

What was your solution?

Could not find one. I now manually change it when I have to build for production, which is not great.

I was going to do the same thing as described here xcode - Copy files to bundle depending on active configuration - Stack Overflow

yeah I guess that would work… so you keep the file in different sub folders then copy it in… Seems like a lot of hassle though for something that would be very simple it auth0 just used the normal Info.plist rather than their own…

The way I resolved this problem is by including a Run Script in the Build Phases underneath the Copy Bundle Resources phase. It looks like this:

![Run Script][1]

The script itself is fairly simple:

RESOURCE_PATH=$SRCROOT/PathToAuth0Plists

FILENAME_IN_BUNDLE=Auth0.plist

BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app

if  "$CONFIGURATION" == "Debug" ]; then
cp $RESOURCE_PATH/Auth0Debug.plist $BUILD_APP_DIR/$FILENAME_IN_BUNDLE
else
cp $RESOURCE_PATH/Auth0Release.plist $BUILD_APP_DIR/$FILENAME_IN_BUNDLE
fi

The only thing that needs to be changed for the above script is RESOURCE_PATH=$SRCROOT/PathToAuth0Plists. You should make this the path to the Auth0Debug.plist and Auth0Release.plist.

Then you need to add a Auth0Debug.plist and an Auth0Release.plist each defining the appropriate clientID and domain.

This isn’t ideal, but it works. Hopefully Auth0 will support this need in the future.

1 Like