# Firebase Remote Config iOS Setup Guide Important references: - Refer to the `firebase-basics` skills, particularly those for iOS setup, before proceeding. - Refer to the `xcode-project-setup` skills. ## Project and App Setup Use the `firebase-tools` CLI to set up the project if necessary. 1. **Find Bundle ID:** Read the Xcode project to find the iOS bundle ID. Check the `PRODUCT_BUNDLE_IDENTIFIER` value in the `.pbxproj` file or the `Info.plist` file. 1. **Create Firebase Project:** If no project exists, create one: `npx -y firebase-tools@latest projects:create --display-name="My Awesome App"` 1. **Create Firebase App:** Register the iOS app with the discovered bundle ID: `npx -y firebase-tools@latest apps:create IOS ` 1. **Link the GoogleService-Info.plist file:** Use the script in the `xcode-project-setup` skill to obtain the config and link. ## Add Swift Package Dependencies Install the Remote Config and Analytics SDKs using the Swift package manager. Install the `FirebaseRemoteConfig` and `FirebaseAnalytics` packages from the [https://github.com/firebase/firebase-ios-sdk.git](https://github.com/firebase/firebase-ios-sdk.git) repository. ## Initialize Firebase in App Code Modify the application's entry point to initialize Firebase. Refer to the iOS setup reference in the firebase-basics skill. ## Follow up Steps The following steps cover the essential patterns for using Remote Config effectively in your iOS app. ### Set In-App Defaults Define default values so your app behaves as intended before it connects to the backend. Create a property list file (e.g., RemoteConfigDefaults.plist): ```` ```xml welcome_message Welcome to the app! is_feature_enabled ``` ```` Then, initialize the SDK and set the defaults: ```` ```swift import FirebaseRemoteConfig let remoteConfig = RemoteConfig.remoteConfig() remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults") ``` ```` ### Fetch and Activate Values To retrieve values from the cloud and apply them to your app: ```` ```swift remoteConfig.fetchAndActivate { (status, error) in if status == .successFetchedFromRemote || status == .successUsingPreFetchedData { print("Config fetched and activated!") } else { print("Config not fetched") } // Access a value let message = remoteConfig.configValue(forKey: "welcome_message").stringValue } ``` ````