마모리(My Memory) 프로젝트
[react native / 리액트 네이티브] firebase 설치방법
huipark
2023. 7. 14. 23:11
IOS
# Using npm
npm install --save @react-native-firebase/app
# Using Yarn
yarn add @react-native-firebase/app
우선 firebase 설치해 주고
project/ios/Podfile
target 'project_name' do
config = use_native_modules!
밑에 코드를 추가해 준다
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseAnalytics'
pod 'FirebaseAuth'
pod 'FirebaseFirestore'
$ pod install
초기화 코드
#import "AppDelegate.h"
#import <Firebase.h> // <----추가
#import <React/RCTBundleURLProvider.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//---------추가------------------
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
//-----------------------------
self.moduleName = @"project_name";
Firebase 라이브러리
$ npm install @react-native-firebase/auth
Firebase의 인증 서비스를 이용할 수 있게 해주는 라이브러리입니다.
$ npm install @react-native-firebase/firestore
Firebase의 NoSQL 데이터베이스인 Cloud Firestore를 이용할 수 있게 해주는 라이브러리입니다.
$ npm install @react-native-firebase/storage
Firebase의 클라우드 스토리지 서비스를 이용할 수 있게 해주는 라이브러리입니다.
$ npm install @react-native-firebase/messaging
Firebase의 푸시 알림 서비스인 Cloud Messaging을 이용할 수 있게 해주는 라이브러리입니다.
$ npm install @react-native-firebase/analytics
Firebase의 앱 사용 통계를 수집할 수 있는 서비스인 Analytics를 이용할 수 있게 해주는 라이브러리입니다.
$ pod install
하니까 이런 에러가 난다
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `FirebaseStorage` depends upon `FirebaseAppCheckInterop`, `FirebaseAuthInterop`, `Firebase
CoreExtension`, and `GTMSessionFetcher`, which do not define modules. To opt into those targets generating
module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
project/ios/Podfile 수정
use_modular_headers! # 이 부분을 추가
target 'your_target_name' do
# Pods for target_name
pod 'FirebaseStorage', :modular_headers => true # 이 부분을 추가
# 기타 라이브러리들...
end
$ pod install