OneSignal-iOS-SDK icon indicating copy to clipboard operation
OneSignal-iOS-SDK copied to clipboard

[Bug]: Importing `OneSignalFramework.h` in bridging header results in error `No type or protocol named 'OSUser'` / `'OSLiveActivities'`

Open ndemie opened this issue 1 year ago • 17 comments

What happened?

I upgraded our OneSignal SDK from 5.0.2 to 5.2.6 using CocoaPods.

After upgrading, I'm unable to compile our project due to errors in OneSignalFrame due to error No type or protocol named 'OSUser' / 'OSLiveActivities'

It seems to be related to using a Bridging Header, as the error seems to originate there. I've tried adding OneSignalLiveActivities and OneSignalOSCore to the Bridging Header as these files seem to live there; but to no avail.

Screenshot 2024-11-05 at 13 57 37

Steps to reproduce?

1. Use version 5.2.6
2. Add `#import <OneSignalFramework/OneSignalFramework.h>` to your `SWIFT_OBJC_BRIDGING_HEADER`
3. Try to run project
3. Get errors

What did you expect to happen?

I do not expect these errors to happen, as they did with the 5.0.2

OneSignal iOS SDK version

5.2.6

iOS version

15

Specific iOS version

Our project targets iOS 15

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

ndemie avatar Nov 05 '24 13:11 ndemie

Similar, unsolved, issue in the react-native-onesignal repo; https://github.com/OneSignal/react-native-onesignal/issues/1717

ndemie avatar Nov 05 '24 13:11 ndemie

Any update on this issue?

ManjunathaReddyNS avatar Nov 13 '24 12:11 ManjunathaReddyNS

This issue only occurs for cross-platform projects, such as those containing .mm For OneSignal team @nan-li Could guys please consider addressing this issue in the next release? Currently, we’re unable to integrate the latest version of OneSignal in cross-platform projects, except for iOS native projects

ManjunathaReddyNS avatar Nov 14 '24 05:11 ManjunathaReddyNS

Able to resolve this issue by adding OneSignal code in Swift file instead of Objective C.

ManjunathaReddyNS avatar Nov 20 '24 06:11 ManjunathaReddyNS

Able to resolve this issue by adding OneSignal code in Swift file instead of Objective C.

i'm using the 5.1.3/5.1.6 workaround since 5.2.6/5.2.7 still has the No type or protocol named 'OSUser' / 'OSLiveActivities' error.

my appdelegate.mm didn't play nice when I tried to convert it to swift. is there any eta on when this will be fixed for objective c without having to downgrade?

MrSco avatar Nov 21 '24 02:11 MrSco

I haven't been able to resolve this issue myself. I've resorted to downgrading to 5.1.6 - which is the latest version which works without this issue.

This issue will become a big problem for us soon as our app is a whitelabel app and is launched continuously as new apps. From February 12th 2025 (postponed from November 12th 2024) ITMS-91061 (privacy manifest) will be enforced which means we cannot release new apps with this version of the OneSignal SDK. From the plethora of third party libraries we use, OneSignal is the only one causing issues.

ndemie avatar Nov 28 '24 10:11 ndemie

Hi everyone, thank you for reporting, I apologize for the delay in investigating this issue.

I will be taking a look into this issue and follow up as soon as I can.

nan-li avatar Dec 05 '24 18:12 nan-li

Hi everyone, thank you for reporting, I apologize for the delay in investigating this issue.

I will be taking a look into this issue and follow up as soon as I can.

Hi nan-li. Any update on this?

ndemie avatar Dec 23 '24 13:12 ndemie

截屏2025-01-06 16 10 09

Put the header file reference into the AppDelegate.m file, there won't be any errors

chenhongchen avatar Jan 06 '25 08:01 chenhongchen

截屏2025-01-06 16 10 09 Put the header file reference into the AppDelegate.m file, there won't be any errors

What header file did you place into the appdelegate.m file? Can you give me more example

nejato avatar Jan 25 '25 15:01 nejato

~~#import <OneSignal/OneSignal.h> ?~~

Replace AppDelegate.mm with AppDelegate.swift and it works.

lfalcao avatar Jan 27 '25 13:01 lfalcao

~#import <OneSignal/OneSignal.h> ?~

Replace AppDelegate.mm with AppDelegate.swift and it works.

my project is object-C, with many relate library, it is problem if change *.mm to *.swift, do you have any solution if we dont change the file extension.

nejato avatar Jan 28 '25 18:01 nejato

hi @nan-li, is there any update for this problem? I hope it so much :(

nejato avatar Jan 28 '25 18:01 nejato

@nan-li any update? The 12/02/2025 deadline imposed by Apple is getting very close now, causing issues for anybody dealing with whitelabel apps.

ndemie avatar Feb 03 '25 10:02 ndemie

@nan-li our binaries are now being denied due to being forced to use an older version (5.1.6) which does not have the right privacy manifests.

Please assist us. This is blocking. If anything provide a fork of 5.1.6 with the privacy manifest supplied please.

ndemie avatar Mar 10 '25 15:03 ndemie

Hi everyone, please try the following:

  1. Remove OneSignal from your project
  2. Test your project to make sure it works
  3. Follow this doc to add OneSignal back using the latest version of our SDK: https://documentation.onesignal.com/docs/ios-sdk-setup
  4. Contact [email protected] with any issues you are experiencing and reference this github url

Thank you!

jfishman1 avatar Apr 02 '25 00:04 jfishman1

Since this issue doesn't appear to be fixed as of version 5.2.10 of the iOS SDK, here's a tip for people like me who have to maintain old projects with Objective-C++ files (.mm extension) and cannot migrate to Swift at this time: You can work around the No type or protocol named 'OSUser' / 'OSLiveActivities' error by manually declaring OSUser and OSLiveActivities as protocols before importing the OneSignal framework. I have this in my Prefix file:

@protocol OSUser;
@protocol OSLiveActivities;
#import <OneSignalFramework/OneSignalFramework.h>
#undef var
#undef let

This appears to cure the problem for me.

(BTW, the #undef directives are there because the OneSignal SDK is unnecessarily polluting the C preprocessor namespace with var and let, causing issues with C/C++ code that attempts to use those names in other contexts. Bad idea.)

ortekka avatar May 15 '25 14:05 ortekka