这是ios上的react-native应用程序,我想用firebase来改进它的推送通知。但是当我通过命令"react-native run-ios"构建项目时,它就崩溃了。或者用xcode。我寻找解决方案,但答案是:
(-打开终端,进入你的项目ios目录
- 输入pod init(如果不存在),然后pod install
- 打开工作区项目并从ios文件夹中删除build
- 从终端运行react-native Run -ios) -不适合我的项目,我也尝试了命令"pod更新"它也没有帮助我。
我附加了两个文件Podfile和appdelegate .h的内容,它们可能有问题。
#Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'appName' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
pod 'RNFBMessaging', :path => '../node_modules/@react-native-firebase/messaging'
target 'appNameTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'appName-tvOS' do
# Pods for appName-tvOS
target 'appName-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
##AppDeligate.h
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
你的podfile部署目标是10.0,你能验证这是否与Xcode中项目中的目标设置相同吗?有时,由于部署目标不匹配,我们会遇到这个问题。