我正在开发一个本机应用程序(已分离)并尝试安装OneSignal用于推送通知,它在Android上运行得非常好,但我在ios上遇到问题。
最初我收到此错误:找不到'React / RCTAnimationType.h'文件。 然后在谷歌搜索错误之后,我看到我需要将OneSignal指定到pod文件中(OneSignal文档没有说明这一点,或者我错过了它。)
将以下内容添加到pod文件中后:
pod 'react-native-onesignal',
:path => '../node_modules/react-native-onesignal'
然后它抱怨pod规格的东西,我在他们的GitHub OneSignal回购中找到了这个文件。
所以我换成了:
pod 'react-native-onesignal',
:podspec => "../node_modules/react-native-onesignal/react-native-onesignal.podspec",
:path => '../node_modules/react-native-onesignal'
运行命令 pod install
看起来它解决了一些事情,但后来又出现了另一个错误:
[!]安装react-native-onesignal [!] / usr / local / bin / git时出错 克隆 GIT中+ https://github.com/geektimecoil/react-native-onesignal.git.git 在/ var /文件夹/ HP / 96xj1gkj76s_x7hbh3rd2vs80000gn / T / d20180504-46105-1fdo6c6 --template = --single-branch --depth 1 --branch v3.1.4
克隆到 '在/ var /文件夹/ HP / 96xj1gkj76s_x7hbh3rd2vs80000gn / T / d20180504-46105-1fdo6c6' ... 致命:无法找到'git + https'
的远程助手
我的最终podfile如下所示:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'my app' do
pod 'ExpoKit',
:git => "http://github.com/expo/expo.git",
:tag => "ios/2.4.4",
:subspecs => [
"Core",
"CPP",
"GL"
]
pod 'React',
:path => "../node_modules/react-native",
:inhibit_warnings => true,
:subspecs => [
"Core",
"ART",
"RCTActionSheet",
"RCTAnimation",
"RCTCameraRoll",
"RCTGeolocation",
"RCTImage",
"RCTNetwork",
"RCTText",
"RCTVibration",
"RCTWebSocket",
"DevSupport",
"CxxBridge"
]
pod 'yoga',
:path => "../node_modules/react-native/ReactCommon/yoga",
:inhibit_warnings => true
pod 'DoubleConversion',
:podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec",
:inhibit_warnings => true
pod 'Folly',
:podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec",
:inhibit_warnings => true
pod 'glog',
:podspec => "../node_modules/react-native/third-party-podspecs/glog.podspec",
:inhibit_warnings => true
pod 'react-native-onesignal',
:podspec => "../node_modules/react-native-onesignal/react-native-onesignal.podspec",
:path => '../node_modules/react-native-onesignal'
post_install do |installer|
installer.pods_project.main_group.tab_width = '2';
installer.pods_project.main_group.indent_width = '2';
installer.pod_targets.each do |target|
if target.pod_name == 'ExpoKit'
target.native_target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'
# needed for GoogleMaps 2.x
config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= []
config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Base/Frameworks'
config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Maps/Frameworks'
end
end
if ['Amplitude-iOS','Analytics','AppAuth','Branch','CocoaLumberjack','FBSDKCoreKit','FBSDKLoginKit','FBSDKShareKit','GPUImage','JKBigInteger2'].include? target.pod_name
target.native_target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
# Build React Native with RCT_DEV enabled
next unless target.pod_name == 'React'
target.native_target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
end
end
end
end
我只是感觉我做了太多需要做的事情,也许有人能让我知道我在这里做错了什么吗?
忘记提及,在做任何事情之前,我使用 react-native link react-native-onesignal 为Android和iOS链接了库。
答案 0 :(得分:0)
我已经在我的项目中实现了一个信号,并且它运行得非常好,我没有安装pod,我已经实现了这个博客帮助,并且它对android和ios完全没问题。
OneSignal Push Notification in React Native Blog
希望这会帮助你,如果你需要任何帮助,请问我。