【问题标题】:OneSignal not working on iOSOneSignal 无法在 iOS 上运行
【发布时间】:2018-05-04 08:40:02
【问题描述】:

我正在开发一个 react 本机应用程序(分离)并尝试安装 OneSignal 以进行推送通知,它在 android 上运行良好,但我在 ios 上遇到问题。

最初我收到此错误:'React/RCTAnimationType.h' 文件未找到。 然后在谷歌搜索错误后,我看到我需要将 OneSignal 指定到 pod 文件中(OneSignal 文档没有说明这一点,或者我错过了)。

在我将以下内容添加到 pod 文件后:

pod 'react-native-onesignal', 
        :path => '../node_modules/react-native-onesignal'

然后它抱怨 pod spec 的东西,我也在他们的 GitHub OneSignal 存储库上找到了这个文件。

所以我改成:

pod 'react-native-onesignal', 
        :podspec => "../node_modules/react-native-onesignal/react-native-onesignal.podspec",
        :path => '../node_modules/react-native-onesignal'

运行命令pod install

看起来它解决了一些问题,但随后我收到另一个错误,如下所示:

https://github.com/danieljvdm/react-native-onesignal/blame/620717a0027538999cd98e1f225d0e4d9a804445/react-native-onesignal.podspec

[!] 安装 react-native-onesignal 时出错 [!] /usr/local/bin/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 link react-native-onesignal 为 android 和 iOS 链接了库。

【问题讨论】:

    标签: ios react-native-android react-native-ios onesignal


    【解决方案1】:

    我已经在我的项目的 1 个中实现了 onesignal,它运行得非常好,我没有安装 pod,我已经在这个博客帮助下实现了,它在 android 和 ios 上都做得很好。

    OneSignal Push Notification in React Native Blog

    希望对您有所帮助,如果您需要任何帮助,请尽管问我。

    【讨论】:

    • @Mizlul 不看项目我不能说,但可能你做的比要求的多,你可以浏览博客,我现在能找到的是因为pods 它是冲突的,因为我可以看到许多文件没有包含在 podfile 中,因为它们已经存在
    猜你喜欢
    • 2013-07-17
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2022-10-15
    相关资源
    最近更新 更多