React-native-onesignal: 无法找到 libRCTOneSignal.a

创建于 2018-08-16  ·  26评论  ·  资料来源: OneSignal/react-native-onesignal

描述:
我已按照此处的 React Native SDK 说明进行操作 - https://documentation.onesignal.com/docs/react-native-sdk-setup

我添加了 npm 包,执行了react-native linkpod install 。 一切都很顺利。

然后我继续创建通知扩展。 当我到达指示我在Link Binary with Libararies设置中添加libRCTOneSignal.a时,我无法在 Xcode 显示的列表中找到它。 这是我搜索 One Signal 时看到的全部内容:

screen shot 2018-08-16 at 12 55 02 pm

这是我的标题搜索页面设置:
screen shot 2018-08-16 at 12 55 26 pm

现在我尝试添加libreact-native-onesignal.a ,但是在构建时出现此链接错误:

ld: library not found for -lreact-native-onesignal
clang: error: linker command failed with exit code 1 (use -v to see invocation)

环境

  1. react-native-one-signal - 3.2.6
  2. 注册护士 - 0.55.4
  3. Xcode - 9.2
Help Wanted dependencies iOS

最有用的评论

结果react-native link没有像往常一样正常工作:DI 只需要手动将RCTOneSignal项目添加到Libraries ,然后我就可以添加libRCTOneSignal.a

我认为如果你们能在react-native link之外添加手动链接的说明会很好,这样人们就可以验证链接是否正常工作:)

所有26条评论

结果react-native link没有像往常一样正常工作:DI 只需要手动将RCTOneSignal项目添加到Libraries ,然后我就可以添加libRCTOneSignal.a

我认为如果你们能在react-native link之外添加手动链接的说明会很好,这样人们就可以验证链接是否正常工作:)

你是怎么添加的?

还试图弄清楚如何将 RCTOneSignal 项目添加到库中

@nickyhajal @abdul-elah-js @steverob有人可以解释一下如何手动将RCTOneSignal项目添加到Libraries吗?

这个问题也应该在文档中。

@pacozaa您可以在此处按照 Facebook 的说明进行操作: https : //facebook.github.io/react-native/docs/linking-libraries-ios

打开 node_modules/react-native-onesignal/ios 然后将 RCTOneSignal.xcodeproj 拖放到 XCode 项目文件夹 Libraries,然后 libRCTOneSignal.a 将出现在搜索中。

screenshot at nov 30 16-21-30

我已经更新了 React-Native 设置中的文档以反映这一点。 感谢您提出这一点并帮助我们改进文档!

没有库文件夹。

@rgomezp对不起,你能重新打开这个问题吗? 在 Xcode 12 的扩展中找不到 libRCTOneSignal.a。但适用于 Xcode 11.7

@Alekhin 先生
尝试进入ios目录并运行pod deintegrate && pod install

这在 Xcode 12 中发生在我身上。不使用 pod。

你好,
对于那些使用 Xcode 12 并且 _not_ 使用 Cocoapods 的人来说,这听起来像是一个问题。

重新打开以跟踪此问题。

另一个使用 Xcode 12 而不使用具有相同问题的 pod。 :(

不得不将 lib 移动到 pods,但它对我的暂存目标不起作用😢伙计们请尽快检查🙏

@rgomezp抱歉,有任何更新吗? 尝试使用 cocoapods 但 OneSignal 由于某种原因未初始化。 使用 React Native 0.59

react-native-onesignal有问题。 这是 Pod 示例:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'



target 'example' do
  # Comment the next line if you don't want to use dynamic frameworks
  # Pods for example
  pod 'Branch', '0.28.1'
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
  pod 'React', :path => '../node_modules/react-native/'
end

target 'exampleDev' do
  # Comment the next line if you don't want to use dynamic frameworks
  # Pods for exampleDev
  pod 'Branch', '0.28.1'
  pod 'React', :path => '../node_modules/react-native/'
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
end

target 'OneSignalNotificationServiceExtension' do
  # Comment the next line if you don't want to use dynamic frameworks
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
  # Pods for OneSignalNotificationServiceExtension
end

target 'DevOneSignalNotificationServiceExtension' do
  # Comment the next line if you don't want to use dynamic frameworks
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
  # Pods for DevOneSignalNotificationServiceExtension
end

@rgomezp有人在研究这个吗?

我们的项目使用 react-native 0.59(没有 cocoapods)并且由于这里的问题,它不是在 XCode 12 上构建的

@rgomezp有人在研究这个吗?

我们的项目使用 react-native 0.59(没有 cocoapods)并且由于这里的问题,它不是在 XCode 12 上构建的

同样在这里。 上次更新后 react-native 0.59 和 Xcode 12 我有描述的错误。 更新前一切正常。 我什至删除并重新安装了 react-native-onesignal 3.9.2

clang: error: no such file or directory: '/Users/leonardo/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphonesimulator/libRCTOneSignal.a' Command Ld failed with a nonzero exit code

image

更新 1:
如果我为生产构建应用程序,它就可以工作......问题是当我尝试在模拟器上运行时(所有这些都使用不同的 iOS)

更新 2:
我什至可以在物理设备上调试。

更新 3:
我可以调试,但 onesignal 不提示用户同意,因此通知不起作用。 我什至更新了最新版本 3.9.2。

我的解决方案是将 xcode 降级到 11.7 并使用 ios 文件夹的备份。 问题似乎与 xcode 12+ 有关

正如@Tebrynn所说,我试图降级 XCode,但我仍然遇到同样的问题。
对我来说,唯一的解决办法是用 Cocoapods 安装代替手动安装。
我只是按照文档(https://documentation.onesignal.com/docs/react-native-sdk-setup)中的说明进行操作。

有什么解决办法吗?

我刚刚更新到 Xcode12,我在构建时也遇到了这个错误。

我最近更新到 Xcode 12。我遇到了同样的问题,找不到 libRCTOneSignal.a。 我相信我遵循了其他人尝试过的步骤和解决方法。 我难住了。
我阅读了几篇关于为 OneSignal 排除 arm64 的文章。 到目前为止,我尝试过这些都没有运气。 然而,由于它只影响模拟器,我可能不会在这个问题上花太多时间。

同样的问题,Xcode 12.4 和 RN 0.59.10。

同样的问题在这里。

你好,
听起来手动安装不知何故中断了。 我们需要进一步挖掘以进行调查。

谢谢你的耐心。

同时,如果可能,尝试切换到 Cocoapods 安装方法

我面临同样的问题。 有什么解决办法吗?

您好,从 React-Native-OneSignal 版本 4.0.0 开始,RCTOneSignal.xcodeproj 中包含的二进制文件没有更新,这意味着您需要使用 Cocoapods 将 OneSignal 添加到 NotificationServiceExtension。
您可以通过将以下内容添加到您的 Podfile 来实现:

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

如果您使用的是 Swift,则将 NotificationService 文件更新为以下内容

import UserNotifications

import OneSignal

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: <strong i="10">@escaping</strong> (UNNotificationContent) -> Void) {
        self.receivedRequest = request;
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

        if let bestAttemptContent = bestAttemptContent {
            OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }

    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }

}

或者如果您使用的是 Objective-C,则以下内容

#import <OneSignal/OneSignal.h>

#import "NotificationService.h"

<strong i="14">@interface</strong> NotificationService ()

<strong i="15">@property</strong> (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
<strong i="16">@property</strong> (nonatomic, strong) UNNotificationRequest *receivedRequest;
<strong i="17">@property</strong> (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

<strong i="18">@end</strong>

<strong i="19">@implementation</strong> NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.receivedRequest = request;
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    [OneSignal didReceiveNotificationExtensionRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];

    // DEBUGGING: Uncomment the 2 lines below and comment out the one above to ensure this extension is excuting
    //            Note, this extension only runs when mutable-content is set
    //            Setting an attachment or action buttons automatically adds this
    // NSLog(@"Running NotificationServiceExtension");
    // self.bestAttemptContent.body = [@"[Modified] " stringByAppendingString:self.bestAttemptContent.body];

    self.contentHandler(self.bestAttemptContent);
}

- (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.

    [OneSignal serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];

    self.contentHandler(self.bestAttemptContent);
}

<strong i="20">@end</strong>

可以在此处找到完整的设置指南

此页面是否有帮助?
0 / 5 - 0 等级