没有这样的模块“OneSignal” - XCode Swift 编译器错误

Mar*_*Itz 11 xcode ios react-native onesignal expo

我目前正在尝试将 OneSignal 添加到我的 React Native Expo(裸)IOS 版本中,并遵循 OneSignal 的指南,如下所示:https ://documentation.onesignal.com/docs/react-native-sdk-setup

然而,Xcode 标记了一个编译器错误:没有这样的模块“OneSignal”

编译错误

这是我的 Podfile,其中包含OneSignalXCFramework导入:

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

platform :ios, '12.0'

require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

target '<NAME>' do
  use_expo_modules!
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
  )

  # Uncomment to opt-in to using Flipper
  #
  # if !ENV['CI']
  #   use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  # end

  post_install do |installer|
    react_native_post_install(installer)

    # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
    # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
    installer.pods_project.targets.each do |target|
      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
    
    target.build_configurations.each do |config|
    # some older pods don't support some architectures, anything over iOS 11 resolves that
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

Run Code Online (Sandbox Code Playgroud)

作为旁注,我已经尝试将pod 'OneSignal'或添加use_frameworks!到 PodFile 中。以前有其他人遇到过这个问题吗?

MAL*_*MAN 11

Xcode 14.0.1 更新和 Swift 5.7 - 使用 SPM(Swift 包管理器)

最近我使用 SPM 将一个信号集成到我的项目中。它工作得很好,直到我尝试将构建上传到应用程序商店连接,它开始向我显示相同的错误。这是我解决此问题的方法。

第 1 步: 删除单信号依赖性

步骤2: 再次添加一个信号通知框架作为依赖项。在此输入图像描述

在“选择包产品”弹出窗口中。

  1. 选择 OneSignal 作为目标添加到项目中。
  2. 选择要添加到 oneSignalNotificationService 扩展作为目标的 OneSignalExtension。
  3. 现在转到 OneSignalNotificationExtension 中的“NotificationService.swift”文件,并将 > import Onesignal 替换为 >import OneSignalExtension。
  4. 还将代码中的 oneSignal 替换为 OneSignalExtension。
  5. 添加包并构建。

  • 为了查看这两个软件包产品,您必须使用 https://github.com/OneSignal/OneSignal-iOS-SDK 而不是 https://github.com/OneSignal/OneSignal-XCFramework (2认同)
  • 这很烦人并且阻止我分发我的应用程序。谢谢你! (2认同)