Adding Options in Settings App
The reason I need Options in settings I need to change my Environments in the outside app so while developing I can easily test the functionality between different Environment’s & Run Script for Enable and Disable for Different Targets
Adding Settings Bundle
- Choose File > New > New File.
- Under iOS, choose Resource, and then select the Settings Bundle template.
- Name the file
Settings.bundle

The new Settings bundle has the following structure:

Click on the Root.plist file. You’ll see a property list like this:

I will remove all the prefernces and create new multi-value & add Title as Environments & add Titles and Values

now create a helper struct to get the selected Environment
struct SettingsBundleHelper {
struct SettingsBundleKeys {
static let Environment = “environments”
}
static func getSettingsBundleEnvironment() -> String {
if let value = UserDefaults.standard.string(forKey: SettingsBundleKeys.Environment) {
return value
}
return “D”
}
}

That’s it Run the app and Go to the settings app you can see the Environment options


Also, I want to Hide these settings options when app on When Live so I will create a run script to hide that
# Run EnvironmentSwitcher
BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
# enable Environment Switcher for Debug , Debug-Scheme-Q
if [ “${CONFIGURATION}” == “Debug-Scheme-D” || “Debug-Scheme-Q” || “Debug-Scheme-P”]; then
cp -r $BUILD_APP_DIR/Settings.bundle
fi
# Disable Environment Switcher for Release
if [ “$CONFIGURATION” == “Release”]; then
rm -Rf $BUILD_APP_DIR/Settings.bundle
echo “Removed Settings Bundle”
fi
