ios - OneSignal 无法在 iOS 上运行
问题描述
我正在开发一个反应本机应用程序(分离)并尝试安装 OneSignal 以进行推送通知,它在 android 上运行良好,但我在 ios 上遇到问题。
最初我收到此错误:找不到“React/RCTAnimationType.h”文件。然后在谷歌搜索错误后,我看到我需要将 OneSignal 指定到 pod 文件中(OneSignal 文档没有说明这一点,或者我错过了)。
在我将以下内容添加到 pod 文件后:
pod 'react-native-onesignal',
:path => '../node_modules/react-native-onesignal'
然后它抱怨了 pod spec 的东西,我也在他们的 GitHub OneSignal repo 上找到了这个文件。
所以我改为:
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 clone git+ https://github.com/geektimecoil/react-native-onesignal.git.git /var/folders/hp/96xj1gkj76s_x7hbh3rd2vs80000gn /T/d20180504-46105-1fdo6c6 --template= --single-branch --depth 1 --branch v3.1.4
克隆到“/var/folders/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 链接 react-native-onesignal为 android 和 iOS 链接了库。
解决方案
我已经在我的项目的 1 中实现了 onesignal,它运行得非常好,我没有安装 pod,我已经用这个博客帮助实现了,它在 android 和 ios 上都做得很好。
React Native 博客中的 OneSignal 推送通知
希望这对您有所帮助,如果您需要任何帮助,请尽管问我。
推荐阅读
- java - 为什么不同的字符串与模式匹配?
- mongodb - 选定查询的猫鼬 $substr 部分
- node.js - npm 删除无关包
- android - 无法单击微调器上文本旁边的空白部分
- .net - 使用一次登录进行多个应用程序身份验证
- python-2.7 - 如何从其他字典创建字典?
- excel - VBA,Excel。执行偏移和调整范围大小然后复制它的代码。“编译错误:无效的监视表达式”
- wordpress - Wordpress:在自定义帖子类型循环之前和之后插入的 HTML 代码
- selenium - 如何在 zalenium 容器中安装 python 依赖项?
- mysql - 在特定条件下引用外键