# Starting with iOS

To run on a physical device:

* Connect the device
    
* Turn on Developer Mode on iPhone (Settings &gt; Privacy & Security &gt; Developer Mode)
    
* Trust the Developer App on iPhone ( Settings &gt; General &gt; VPN & Device Management)
    
* Establish a Team in XCode (Project &gt; Signing & Capabilities &gt; Team)
    

Getting Firestore up and running

* [<s>https://firebase.google.com/codelabs/firestore-ios#2</s>](https://firebase.google.com/codelabs/firestore-ios#2) out dated
    
* Need to drag the GoogleService-Info.plist to your project directory
    
* Need to Add SDK
    
    * In Xcode, with your app project open, navigate to **File &gt; Add Packages**
        
    * When prompted, enter the Firebase iOS SDK repository URL \`[https://github.com/firebase/firebase-ios-sdk](https://github.com/firebase/firebase-ios-sdk)\`
        
    * Choose at least the Firestore packages (but not all of the packages and not the combined packages)
        
* Add the following code to the App file
    

```swift
import SwiftUI
import FirebaseCore
import FirebaseFirestore
//import FirebaseFirestoreSwift

class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    FirebaseApp.configure()
    addDoc()
    return true
  }
}

func addDoc(){
    let db = Firestore.firestore()
    //db.collection("Documents").addDocument(data: ["name": "ming"])
    let docRef = db.collection("Restaurants").document("hello")
    docRef.setData(["name": "Favorite Restaurant!!"]) { error in
        if let error = error {
            print("Error writing document: \(error)")
        } else {
            print("Document successfully written!")
        }
    }
}

@main
struct FirestoreApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
```
