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

[Bug]: OneSignal/OneSignal.h file not found #1440

Closed
2 of 3 tasks
brunoleitem opened this issue Oct 14, 2022 · 38 comments
Closed
2 of 3 tasks

[Bug]: OneSignal/OneSignal.h file not found #1440

brunoleitem opened this issue Oct 14, 2022 · 38 comments

Comments

@brunoleitem
Copy link

brunoleitem commented Oct 14, 2022

What happened?

Hello, im currently trying to do Archive on my XCode and failing with
Lexical or Preprocessor Issue => OneSignal/OneSignal.h file not found

Already tried reinstalling pods and creating a new notifications extension following the installation guide.

Steps to reproduce?

XCode 13
IOS 13
React Native 0.63.4

Steps on XCode
1. Clean build
2. Archive

What did you expect to happen?

I expected to complete the xcode archive.

React Native OneSignal SDK version

4.3.3

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@brunoleitem brunoleitem changed the title [Bug]: [Bug]: OneSignal/OneSignal.h file not found Oct 14, 2022
@jayshah123
Copy link

Facing same issue with following environment:

System:
    OS: macOS 12.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 124.86 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    Yarn: 1.18.0 - ~/.nvm/versions/node/v16.17.1/bin/yarn
    npm: 8.18.0 - ~/Documents/rippling-mobile/node_modules/.bin/npm
    Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.2 => 0.68.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

react-native-onesignal version according to yarn.lock:

[email protected]:
     resolved "https://registry.yarnpkg.com/react-native-onesignal/-/react-native-onesignal-4.4.0.tgz#731651bf074bac7d5e1576e8670a5850aacce362"

Onesignal contents in Podfile.lock:

  - OneSignalXCFramework (3.11.2):
    - OneSignalXCFramework/OneSignalCore (= 3.11.2)
    - OneSignalXCFramework/OneSignalExtension (= 3.11.2)
    - OneSignalXCFramework/OneSignalOutcomes (= 3.11.2)
  - OneSignalXCFramework/OneSignalCore (3.11.2)
  - OneSignalXCFramework/OneSignalExtension (3.11.2):
    - OneSignalXCFramework/OneSignalCore
    - OneSignalXCFramework/OneSignalOutcomes
  - OneSignalXCFramework/OneSignalOutcomes (3.11.2):
    - OneSignalXCFramework/OneSignalCore

@jedi2209
Copy link

jedi2209 commented Oct 17, 2022

Have the same problem, but on a different package version.
react-native-onesignal@^4.4.1

The environment is the same:

  • Xcode 14.0.1
  • arm64 Apple M1
  • macOS 12.5
  • react-native 0.70.3

@jayshah123
Copy link

jayshah123 commented Oct 18, 2022

I see this in Debug builds and not on Release configuration, e.g. react-native run-ios will break.

@hinh-eoh
Copy link

Facing the same issue with Xcode 14, but can achieve success.

@kingkongqn4444
Copy link

the same issuse

@jayshah123
Copy link

jayshah123 commented Nov 8, 2022

The solution seems to be:
If you are excluding arm64 via excluded architechtures build setting,
Make sure it is excluded for all targets (even the pods project).

After doing the above, error should not appear.

@pingkungjaza
Copy link

pingkungjaza commented Nov 15, 2022

OneSignal/OneSignal.h is in https://documentation.onesignal.com/docs/react-native-sdk-setup

Please see "Manually updating iOS OneSignalNativeSDK" above step 6.
Then download "Source code" and do the step in manually.

@pingkungjaza
Copy link

pingkungjaza commented Feb 17, 2023

[Update] If you install all of package. then you open file.xcworkspace and build
It's work for me.

! file.xcodeproj has some bug

@Dajust
Copy link

Dajust commented Mar 29, 2023

rm -rf node_modules
pod deintegrate
yarn
pod install

Fixed for me!

@gorkemogut
Copy link

Xcode 15.0 beta 3 has same problem with M2 Mac

@Mr-Anonymous
Copy link

Has anyone found any solution for this? I get the same error: 'OneSignal/OneSignal.h' file not found

@kamaravichow
Copy link

kamaravichow commented Aug 28, 2023

I think the documentation was updated and needs to be updated to OneSignalFramework/OneSignalFramework.h

@killerchip
Copy link

I am having the same issue.
I use latest Expo (SDK 49.0.0), and we have tweaked the `onesignal-expo-config' to add to podFile:

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
end`;

I can see it installs:

[INSTALL_PODS] Installing react-native-onesignal (5.0.0)
[INSTALL_PODS] Installing OneSignalXCFramework (5.0.1)

But when fastlane is run I get the dreaded:

(ios/OneSignalNotificationServiceExtension/NotificationService.m:1:9)

> 1 | #import <OneSignal/OneSignal.h>
    |         ^ 'OneSignal/OneSignal.h' file not found

Any idea?

@aindong
Copy link

aindong commented Sep 7, 2023

I am having the same issue. I use latest Expo (SDK 49.0.0), and we have tweaked the `onesignal-expo-config' to add to podFile:

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
end`;

I can see it installs:

[INSTALL_PODS] Installing react-native-onesignal (5.0.0)
[INSTALL_PODS] Installing OneSignalXCFramework (5.0.1)

But when fastlane is run I get the dreaded:

(ios/OneSignalNotificationServiceExtension/NotificationService.m:1:9)

> 1 | #import <OneSignal/OneSignal.h>
    |         ^ 'OneSignal/OneSignal.h' file not found

Any idea?

for this issue, I've used patch-package to not only update the iosContants but also the support/serviceExtensionFiles/NotificationService.m and replace

#import <OneSignal/OneSignal.h>

with

#import <OneSignalFramework/OneSignalFramework.h>

since react-native-onesignal uses OneSignalFramework header now instead of OneSignal, works for me @killerchip

@Diaa-Ghonim
Copy link

same issue here.

I spent all of the day to resolve it but nothing worked.

'OneSignal.h' file not found

@killerchip
Copy link

same issue here.

I spent all of the day to resolve it but nothing worked.

'OneSignal.h' file not found

@Diaa-Ghonim See @aindong response
#1440 (comment)

@Diaa-Ghonim
Copy link

same issue here.
I spent all of the day to resolve it but nothing worked.
'OneSignal.h' file not found

@Diaa-Ghonim See @aindong response #1440 (comment)

it is not a completed answer, which parts I have to patch them.
and I am not using expo I am using react-native
and I use react-native-onesignal 4.4.1

and I added this to my pod file

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

anyone can explain clear steps please to fix this issue??

my machine is mac m1
my xcode is 14.3

@killerchip
Copy link

1.3.2 [Bug]: 'onesignal/onesignal.h' file not found react native OneSignal/onesignal-expo-plugin#182

it should be pod 'OneSignalXCFramework', '>= 5.0', '< 6.0' (see versions)

Also check if you have a NotificationService.m file. Replace
#import <OneSignal/OneSignal.h>
with
#import <OneSignalFramework/OneSignalFramework.h>

@Diaa-Ghonim
Copy link

1.3.2 [Bug]: 'onesignal/onesignal.h' file not found react native OneSignal/onesignal-expo-plugin#182

it should be pod 'OneSignalXCFramework', '>= 5.0', '< 6.0' (see versions)

Also check if you have a NotificationService.m file. Replace #import <OneSignal/OneSignal.h> with #import <OneSignalFramework/OneSignalFramework.h>
I apologize for any confusion. Here's a corrected version in English:

Unfortunately, the issue remains unresolved. I upgraded the react-native-onesignal library to the latest version and updated the Podfile from version 5 to 6. However, I'm still encountering this error:

'OneSignalFramework/OneSignalFramework.h' file not found

I am using react-native version "0.63.3".

@arnaudambro
Copy link

arnaudambro commented Sep 12, 2023

https://documentation.onesignal.com/docs/ios-sdk-setup#4-notification-service-extension

maybe in the objective-c file, write OneSignalExtension where you have OneSignal or OneSignalFramework ?

#import <OneSignalExtension/OneSignalExtension.h>

instead of

#import <OneSignal/OneSignal.h> // or #import <OneSignalFramework/OneSignalFramework.h>

not sure about it though, but at home it seems to compile

@Diaa-Ghonim
Copy link

Here is the issue in this file in node_modules.

Screenshot 2023-09-12 at 3 18 14 PM

@Diaa-Ghonim
Copy link

any idea?

@arnaudambro
Copy link

I confirm on my side: for OneSignal v5+, I replace #import < OneSignalFramework/OneSignalFramework .h> or #import <OneSignal/OneSignal.h> with

#import <OneSignalExtension/OneSignalExtension.h>

and it's compiling

@Diaa-Ghonim
Copy link

Hello @arnaudambro,

Thank you for your reply.

Where exactly should I add this line?

Here is my react-native-onesignal package in node_modules (version 4.4.1) (first image).

And here, as well, is the pods file and the react-native-onesignal pod (second image).

So, what should I do exactly to make the compilation succeed?

Screenshot 2023-09-14 at 2 36 44 PM Screenshot 2023-09-14 at 2 38 45 PM

@arnaudambro
Copy link

you should have a Notification Service Extension: https://documentation.onesignal.com/docs/ios-sdk-setup#4-notification-service-extension

quoting:

The OneSignalNotificationServiceExtension allows your iOS application to receive rich notifications with images, buttons, and badges. It's also required for OneSignal's Confirmed Delivery analytics features.
In Xcode Select File > New > Target...
Select Notification Service Extension then press Next.
Enter the product name as OneSignalNotificationServiceExtension and press Finish.
Do not select Activate on the dialog that is shown after selecting Finish.
Press Cancel on the Activate scheme prompt.
By canceling, you are keeping Xcode debugging your app, instead of the extension you just created.
If you activated by accident, you can switch back to debug your app within Xcode (next to the play button).
In the project navigator, select the top-level project directory and select the OneSignalNotificationServiceExtension target in the project and targets list.
Ensure the Deployment Target is set to the same value as your Main Application Target. Unless you have a specific reason not to, you should set the Deployment Target to be iOS 11 or above.
In the project navigator, click the OneSignalNotificationServiceExtension folder and open the NotificationService.m or NotificationService.swift and replace the whole file's contents with the following code. Ignore any build errors at this point. We will import OneSignal which will resolve any errors.

#import <OneSignalExtension/OneSignalExtension.h>

#import "NotificationService.h"

@interface NotificationService ()

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

this is where the OneSignal/OneSignal.h file not found comes from, because it used to be #import <OneSignal/OneSignal.h>, now it's #import <OneSignalExtension/OneSignalExtension.h>

@aindong
Copy link

aindong commented Sep 14, 2023

For expo users, new update on the expo plugin is out, it should fix your problems about the missing header https://github.com/OneSignal/onesignal-expo-plugin/releases/tag/2.0.0

@nachoviejo
Copy link

nachoviejo commented Sep 15, 2023

I have a Mac M1, react native 0.68.5 and OneSignal 4.5.0. For some reason cocoapods is not installing correctly pods so,
after weeks dealing with this issue, I've fixed it doing the following steps:

  1. Update cocoapods and ffi to last version.
  2. Delete from podfile everything related with OneSignal. And add this:
post_install do |installer|
     react_native_post_install(installer)
     __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
  1. On Xcode, open xcworkspace, go to OneSignalNotificationServiceExtension target > General > Frameworks and Libraries and add:
Screenshot 2023-09-15 at 11 01 20

I have only those, if you have another one that can cause and error you need to remove it.

  1. Do a full clean and run it again:
rm -rf node_modules && yarn install
cd ios && pod deintegrate
rm -rf podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
npx react-native run ios (or the command that you use to run it)

I hope this helps!

@matheusroomao
Copy link

olá consegui resolver alterando
#import <OneSignalFramework/OneSignalFramework.h>
para
#import <OneSignal/OneSignal.h>
Versão:
OneSignal 4.5.1, React-native 0.72.4, Xcode 15.0, macOS ventura 13.5.2,

@Diaa-Ghonim
Copy link

I tried all these solutions but didn't fix the issue.

any help please?

@sn-will
Copy link

sn-will commented Oct 5, 2023

I have a Mac M1, react native 0.68.5 and OneSignal 4.5.0. For some reason cocoapods is not installing correctly pods so, after weeks dealing with this issue, I've fixed it doing the following steps:

  1. Update cocoapods and ffi to last version.
  2. Delete from podfile everything related with OneSignal. And add this:
post_install do |installer|
     react_native_post_install(installer)
     __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
  1. On Xcode, open xcworkspace, go to OneSignalNotificationServiceExtension target > General > Frameworks and Libraries and add:
Screenshot 2023-09-15 at 11 01 20 I have only those, if you have another one that can cause and error you need to remove it.
  1. Do a full clean and run it again:
rm -rf node_modules && yarn install
cd ios && pod deintegrate
rm -rf podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
npx react-native run ios (or the command that you use to run it)

I hope this helps!

Adding the .xcframework files into the Frameworks and Libraries of OneSignalNotificationServiceExtension worked for me

@Diaa-Ghonim
Copy link

I have a Mac M1, react native 0.68.5 and OneSignal 4.5.0. For some reason cocoapods is not installing correctly pods so, after weeks dealing with this issue, I've fixed it doing the following steps:

  1. Update cocoapods and ffi to last version.
  2. Delete from podfile everything related with OneSignal. And add this:
post_install do |installer|
     react_native_post_install(installer)
     __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
  1. On Xcode, open xcworkspace, go to OneSignalNotificationServiceExtension target > General > Frameworks and Libraries and add:
Screenshot 2023-09-15 at 11 01 20 I have only those, if you have another one that can cause and error you need to remove it.
  1. Do a full clean and run it again:
rm -rf node_modules && yarn install
cd ios && pod deintegrate
rm -rf podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
npx react-native run ios (or the command that you use to run it)

I hope this helps!

Adding the .xcframework files into the Frameworks and Libraries of OneSignalNotificationServiceExtension worked for me

finally worked with me too

Thanks a lot ❤️ 🤙 ❤️

@nachoviejo @sn-will

@hungMta
Copy link

hungMta commented Oct 13, 2023

After adding OneSignal.xcframework ,.... I got another error:

Library not found for -lPods-OneSignalNotificationServiceExtension
Screenshot 2023-10-13 at 10 38 21

My environment:
react-native: 0.63
xcode 14.2
macbook: M2-pro

@TiagoAndreAlmeida
Copy link

Tried every sugestion here but none work....
Xcode Version 15.0
react-native: 0.72.6
macbook: intel

@Diaa-Ghonim
Copy link

Unfortunately, this issue has occurred again, and I attempted the same solution, but it did not work.

help again guys 😢 😞

@jmonloop
Copy link

jmonloop commented Nov 23, 2023

I got rid of this error by
1 pod deintegrate
2 pod update
3 Remove arm64 from excluded architecture at project and targets level

It's curious that I had to exclude the architecture and build to solve this problem

Then the import error appeared so I though by removing the excluded arch the linking error would show again but it didn't.

@KennyLibaro
Copy link

I'm not an expert on the topic but I think deintegrating and updating doesn't affect all files for some reason, I noticed the "OneSignal/OneSignal.h file not found" error I had was in the Development Pods folder I manually deleted everything in this folder and ran pod update again. this seemed to have resolved the problem for me.

@Akshjani
Copy link

Hello
i am getting this error while building ipa from unity

error : 'OneSignalNotifications/OneSignalNotifications.h' file not found

Screenshot 2024-02-21 at 2 19 32 PM

from past 2 days i am battling with this error please help guysss

@codeagus11
Copy link

Same issue here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests