Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find libRCTOneSignal.a #604

Closed
steverob opened this issue Aug 16, 2018 · 27 comments
Closed

Unable to find libRCTOneSignal.a #604

steverob opened this issue Aug 16, 2018 · 27 comments
Assignees
Labels
Dependencies Pull requests that update a dependency file Help Wanted iOS

Comments

@steverob
Copy link

steverob commented Aug 16, 2018

Description:
I've followed the instructions for React Native SDK from here - https://documentation.onesignal.com/docs/react-native-sdk-setup

I've added the npm package, performed react-native link and also pod install. Everything went smooth.

Then I proceed to create the Notification Extension. When I get to the part where I'm instructed to add libRCTOneSignal.a in the Link Binary with Libararies setting, I'm not able to find it in the list that Xcode shows. Here's all I see when I search for One Signal:

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

Here is my header search pages setting:
screen shot 2018-08-16 at 12 55 26 pm

Now I tried adding the libreact-native-onesignal.a, but when building I get this linking error:

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

Environment

  1. react-native-one-signal - 3.2.6
  2. RN - 0.55.4
  3. Xcode - 9.2
@steverob
Copy link
Author

Turns out react-native link did not work correctly as usual :D I just had to manually add the RCTOneSignal project into Libraries and then I was able to add libRCTOneSignal.a

I think it would be nice if you guys can add the instructions for manually linking in addition to react-native link so people can verify if link worked correctly :)

@abdul-elah-js
Copy link

how did you add it ?

@nickyhajal
Copy link

Also trying to figure out exactly how to add the RCTOneSignal project into Libraries

@pacozaa
Copy link

pacozaa commented Nov 30, 2018

@nickyhajal @abdul-elah-js @steverob Can someone explain how to manually add the RCTOneSignal project into Libraries?

This problem should be in documentation as well.

@sonlexqt
Copy link

@pacozaa you can follow Facebook's instructions here: https://facebook.github.io/react-native/docs/linking-libraries-ios

@cassmtnr
Copy link

Open node_modules/react-native-onesignal/ios then drag and drop RCTOneSignal.xcodeproj to XCode project folder Libraries, then the libRCTOneSignal.a will appear on the search.

screenshot at nov 30 16-21-30

@rgomezp rgomezp reopened this Jan 25, 2019
@rgomezp
Copy link
Contributor

rgomezp commented Jan 29, 2019

I have updated the documentation in the React-Native setup to reflect this. Thanks for bringing this up and helping make our documentation better!

@rgomezp rgomezp closed this as completed Jan 29, 2019
@doganarif
Copy link

No Libraries folder.

@MrAlekhin
Copy link

@rgomezp Sorry, could you please reopen the issue? libRCTOneSignal.a cannot be found in extension in Xcode 12. But works on Xcode 11.7

@rgomezp
Copy link
Contributor

rgomezp commented Oct 5, 2020

@MrAlekhin ,
Try going into the ios directory and running pod deintegrate && pod install

@luco
Copy link

luco commented Oct 22, 2020

This is happening for me in Xcode 12. Not using pods.

@rgomezp rgomezp reopened this Oct 27, 2020
@rgomezp
Copy link
Contributor

rgomezp commented Oct 27, 2020

Howdy,
It sounds like this is an issue for those of you who are using Xcode 12 and are not using Cocoapods.

Reopening to track this issue.

@rgomezp rgomezp added Dependencies Pull requests that update a dependency file Help Wanted iOS labels Oct 27, 2020
@GerardCasadevall
Copy link

Another using Xcode 12 without using pods that have the same problem. :(

@MrAlekhin
Copy link

Had to move the lib to pods, but it's not working on my staging target😢 guys please review that ASAP 🙏

@MrAlekhin
Copy link

MrAlekhin commented Nov 8, 2020

@rgomezp sorry, any updates on that? tried to use cocoapods but OneSignal is not initialized for some reason. using React Native 0.59

Having issues with react-native-onesignal. Here is the Pod example:

# 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

@victormartingarcia
Copy link

@rgomezp is anyone looking into this?

Our project uses react-native 0.59 (no cocoapods) and it's not building on XCode 12 because of the issue here

@Tebrynn
Copy link

Tebrynn commented Nov 10, 2020

@rgomezp is anyone looking into this?

Our project uses react-native 0.59 (no cocoapods) and it's not building on XCode 12 because of the issue here

Same here. react-native 0.59 and Xcode 12 after last update i have the error described. All working fine before update. I even removed and reinstalled 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

Update 1:
If i build the app for production it works...The problem is when i try to run on simulator (all of them with different iOS)

Update 2:
I can debug even on physical device.

Update 3:
I can debug but onesignal does not prompt user consent so notifications not working. I even updated latest version 3.9.2.

@Tebrynn
Copy link

Tebrynn commented Nov 18, 2020

The solution for me was to downgrade xcode to 11.7 and use a backup of ios folder. The problem seems to be related to xcode 12+

@ramonsenadev
Copy link

ramonsenadev commented Nov 26, 2020

I tried to downgrade the XCode, as @Tebrynn said, but I continue getting the same issue.
For me, the only solution was to replace the manual installation with the Cocoapods installation.
I just followed the instructions in the documentation (https://documentation.onesignal.com/docs/react-native-sdk-setup).

@fabioplaka
Copy link

Any solution for this?

I just updated to Xcode12 and I am facing this error on build too.

@rider1971
Copy link

rider1971 commented Jan 28, 2021

I recently updated to Xcode 12. I'm getting the same problem with not finding libRCTOneSignal.a. I believe I followed the steps and workarounds others have tried. I'm stumped.
[Update]: This is only an issue with the simulator in Xcode 12. I am able to build to an iOS device. Xcode 11 builds/runs in the simulator fine - only Xcode 12.
I read several articles about excluding arm64 for OneSignal. I tried these with no luck so far. However, since it only affects the simulator, I will probably not spend much more time on this issue.

@croshim
Copy link

croshim commented Feb 4, 2021

Same issue, Xcode 12.4 and RN 0.59.10.

@hugoh59
Copy link

hugoh59 commented Mar 1, 2021

Same issue here.

@rgomezp
Copy link
Contributor

rgomezp commented Mar 3, 2021

Howdy,
It sounds like manual installations broke somehow. We will need to dig further to investigate.

Thanks for your patience.

In the meantime, if possible, try switching to a Cocoapods installation method

@Dumidu
Copy link

Dumidu commented Mar 19, 2021

I am facing the same issue. Any solution?

@emawby
Copy link
Contributor

emawby commented Mar 26, 2021

Hello, as of React-Native-OneSignal version 4.0.0 the binary contained in the RCTOneSignal.xcodeproj is not be updated meaning that you will need to use Cocoapods to add OneSignal to the NotificationServiceExtension.
You can do so by adding the following to your Podfile:

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

Then update the NotificationService file to the following if you are using Swift

import UserNotifications

import OneSignal

class NotificationService: UNNotificationServiceExtension {
    
    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?
    
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (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)
        }
    }
    
}

Or the following if you are using Objective-C

#import <OneSignal/OneSignal.h>

#import "NotificationService.h"

@interface NotificationService ()

@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNNotificationRequest *receivedRequest;
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

@end

@implementation 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);
}

@end

The complete setup guide can be found here

@emawby emawby closed this as completed Mar 26, 2021
@abheesree
Copy link

Turns out react-native link did not work correctly as usual :D I just had to manually add the RCTOneSignal project into Libraries and then I was able to add libRCTOneSignal.a

I think it would be nice if you guys can add the instructions for manually linking in addition to react-native link so people can verify if link worked correctly :)

how can i copy this to the libraries , i am kind of new to react native & IOS , been trying to fix from last 2 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Pull requests that update a dependency file Help Wanted iOS
Projects
None yet
Development

No branches or pull requests