Firebase는 Google에서 제공하는 모바일 및 웹 애플리케이션 개발 플랫폼으로, 서버 구축 없이도 다양한 기능을 제공하여 개발 효율성을 높입니다.
| 기능 | 설명 |
|---|---|
| Authentication | 이메일, 소셜 로그인(Google, Facebook 등), 익명 로그인 |
| Firestore | 실시간 NoSQL 클라우드 데이터베이스 |
| Realtime Database | 실시간 데이터 동기화 |
| Storage | 이미지, 동영상 등의 파일 저장 |
| Cloud Functions | 서버리스 함수 실행 |
| Crashlytics | 앱 크래시 리포트 및 분석 |
| Push Notifications | Firebase Cloud Messaging을 통한 푸시 알림 |
Firebase Console에서 프로젝트 생성
iOS 앱 등록 후 GoogleService-Info.plist 다운로드
Xcode 프로젝트에 GoogleService-Info.plist 추가
Swift Package Manager로 Firebase SDK 설치
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "10.0.0")
AppDelegate 또는 SceneDelegate에서 초기화
import FirebaseCore
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}
import FirebaseFirestore
let db = Firestore.firestore()
db.collection("users").document("user_1").setData([
"name": "Alice",
"age": 25
]) { error in
if let error = error {
print("Error writing document: \(error)")
} else {
print("Document successfully written!")
}
}
db.collection("users").document("user_1").getDocument { (document, error) in
if let document = document, document.exists {
print("Document data: \(document.data() ?? [:])")
} else {
print("Document does not exist")
}
}
import FirebaseAuth
Auth.auth().createUser(withEmail: "test@example.com", password: "password123") { authResult, error in
if let error = error {
print("Error: \(error)")
} else {
print("User signed up: \(authResult?.user.uid ?? "")")
}
}
Firebase는 iOS 앱 개발에서 인증, 데이터베이스, 푸시 알림 등 백엔드 기능을 손쉽게 구현할 수 있는 강력한 도구입니다.
프로토타입부터 상용 서비스까지 유연하게 활용할 수 있습니다.