您好,我为我的 ios 应用程序配置了 firebase。
但是我从终端看到一堆这样的注释:
Prepare packages
Computing target dependency graph and provisioning inputs
Create build description
Build description signature: 5b4e366011110c238ef7eb0e2f1dc896
Build description path: /Users/ali/Library/Developer/Xcode/DerivedData/Cypien-fzcypiyubvmmrxeseqhayuvqdhfm/Build/Intermediates.noindex/XCBuildData/5b4e366011110c238ef7eb0e2f1dc896-desc.xcbuild
note: Building targets in dependency order
note: Removed stale file '/Users/ali/Library/Developer/Xcode/DerivedData/Cypien-fzcypiyubvmmrxeseqhayuvqdhfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/fmt.build/Script-46EB2E0001F240.sh'
....
但对我来说仍然不起作用,我删除了 firebase 依赖项,一切正常。
这是我的 Podfile:
target 'Cypien' do
config = use_native_modules!
use_frameworks! :linkage => :static # for Firebase
$RNFirebaseAsStaticFramework = true # for Firebase
# Flags change depending on the env values.
flags = get_default_flags()
pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
#import <Firebase.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } // for Firebase
self.moduleName = @"Cypien";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show]; // here
return didFinish;
}
Package.json:
"react": "18.2.0",
"react-native": "0.71.11",
"@react-native-firebase/app": "^15.6.0",
"@react-native-firebase/messaging": "^15.6.0",
我尝试过这个命令:
尝试以下操作:
首先删除node_modules、pods、podfile.lock然后安装
npm install --save @react-native-firebase/app
然后安装 Pod
cd ios
pod install
正确添加
GoogleService-Info.plis
t 文件。从这里参考
为此,请打开
/ios/{projectName}/AppDelegate.mm file (or AppDelegate.m
(如果使用较旧的反应本机),然后添加以下内容:
在文件顶部,在
'#import "AppDelegate.h"'
: 之后导入 Firebase SDK
#import <Firebase.h>
在现有的
didFinishLaunchingWithOptions
方法中,将以下内容添加到方法顶部:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add me --- \/
[FIRApp configure];
// Add me --- /\
// ...
}
无需向 podfile 添加任何内容。
Package.json:
"react": "18.2.0",
"react-native": "0.71.8",
"@react-native-firebase/app": "^16.4.6",
"@react-native-firebase/crashlytics": "^16.4.6",
"@react-native-firebase/messaging": "^16.4.6",