Quantcast
Channel: Active questions tagged cocoapods - Stack Overflow
Viewing all articles
Browse latest Browse all 1029

React Native iOS build fails: no such module 'OneSignalExtension' in OneSignalNotificationServiceExtension

$
0
0

I'm working on a React Native app with an iOS target, and I'm getting a build error related to a OneSignal Notification Service Extension. The build fails with the following error:

SwiftEmitModule normal x86_64 Emitting\ module\ for\ ShareExtension (in target 'ShareExtension' from project 'veerahealthpcos')SwiftCompile normal x86_64 /Users/rac/Desktop/working/rn-veera-health-pcos/ios/ShareExtension/ShareViewController.swift (in target 'ShareExtension' from project 'veerahealthpcos')    cd /Users/rac/Desktop/working/rn-veera-health-pcos/iosSwiftEmitModule normal x86_64 Emitting\ module\ for\ OneSignalNotificationServiceExtension (in target 'OneSignalNotificationServiceExtension' from project 'veerahealthpcos')Failed frontend command:
/Users/rac/Desktop/working/rn-veera-health-pcos/ios/OneSignalNotificationServiceExtension/NotificationService.swift:2:8: error: no such module 'OneSignalExtension'import OneSignalExtension       ^

Additional Build Output:

SwiftEmitModule normal x86_64 Emitting module for OneSignalNotificationServiceExtension (in target 'OneSignalNotificationServiceExtension' from project 'veerahealthpcos')

...

** BUILD FAILED **

The following build commands failed:

SwiftEmitModule normal x86_64 Emitting module for OneSignalNotificationServiceExtension

SwiftCompile normal x86_64 NotificationService.swift

I’ve already tried cleaning and reinstalling pods using the following commands:

rm -rf ios/Podsrm -rf ios/DerivedDatarm -rf ~/Library/Developer/Xcode/DerivedDatacd ios && pod deintegrate && pod install --repo-update && cd ..

My package versions:

"react-native-onesignal": "^5.2.9","react-native": "0.69.12"
  • Node.js: 16.20.1

  • macOS: m1 Pro

  • Xcode 16.3

  • Using CocoaPods

ios/OneSignalNotificationServiceExtension/NotificationService.swift

import UserNotificationsimport OneSignalExtensionclass NotificationService: UNNotificationServiceExtension {    var contentHandler: ((UNNotificationContent) -> Void)?    var receivedRequest: UNNotificationRequest!    var bestAttemptContent: UNMutableNotificationContent?    // Note this extension only runs when `mutable_content` is set    // Setting an attachment or action buttons automatically sets the property to true    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {        self.receivedRequest = request        self.contentHandler = contentHandler        self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)        if let bestAttemptContent = bestAttemptContent {            // DEBUGGING: Uncomment the 2 lines below to check this extension is executing//            print("Running NotificationServiceExtension")//            bestAttemptContent.body = "[Modified] " + bestAttemptContent.body            OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)        }    }    override func serviceExtensionTimeWillExpire() {        // 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 {            OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)            contentHandler(bestAttemptContent)        }    }}

ios/Podfile

target 'OneSignalNotificationServiceExtension' do  pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'end

How do I fix this error when building the OneSignal Notification Service Extension on iOS with React Native?

Any help would be appreciated!


Viewing all articles
Browse latest Browse all 1029

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>