Skip to content

[Bug]: Flutter iOS Build Fails with 'Flutter/Flutter.h' not found After OneSignal NSE Integration #1582

@smolikja

Description

@smolikja

What happened?

After following the official OneSignal Flutter SDK setup documentation for iOS integration, the iOS build fails with a 'Flutter/Flutter.h' file not found error when adding the Notification Service Extension (NSE) target. The issue specifically occurs when using flutter_flavorizr with multiple build configurations and affects both iOS simulator and physical device builds.

Key findings:

  • iOS build works perfectly BEFORE OneSignal integration
  • Android builds work correctly and push notifications are received successfully
  • Basic OneSignal integration (without NSE) works on both simulator and physical device
  • The build failure occurs specifically when adding the NSE target to Podfile
  • Light clean (flutter clean) allows successful builds, but full clean (including Pods and DerivedData) breaks the build
  • The issue appears to be related to Flutter framework headers not being accessible during NSE compilation

Steps to reproduce?

1. Create Flutter project with flavors using flutter_flavorizr:
   
   dev_dependencies:
     flutter_flavorizr: 2.4.1
   

2. Add OneSignal Flutter SDK to `pubspec.yaml`:
   
   dependencies:
     onesignal_flutter: 5.3.4
   

3. Follow official OneSignal iOS setup steps 1-6:
   - Add Push Notifications capability
   - Add Background Modes capability with Remote notifications
   - Add App Target to App Group (`group.your.bundle.id.onesignal`)
   - Add Notification Service Extension target (`OneSignalNotificationServiceExtension`)
   - Add NSE Target to App Group
   - Update NSE code and Podfile

4. Add NSE target to Podfile:
   
   target 'OneSignalNotificationServiceExtension' do
     use_frameworks!
     pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
   end
   

5. Run full clean and build:
   
   cd ios
   rm -rf Pods
   rm Podfile.lock
   pod install
   cd ..
   flutter clean
   flutter pub get
   flutter run --flavor dev
   

6. Build fails with Flutter header error

What did you expect to happen?

The iOS app should build successfully and be able to receive rich push notifications with images and confirmed delivery, similar to the working Android implementation. The integration should work seamlessly with flutter_flavorizr build configurations.

OneSignal iOS SDK version

Release 5.2.14

iOS version

18

Specific iOS version

iOS 18.5

Relevant log output

Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/jakubsmolik/Developer/gitreps/achilleus-app/ios/Runner/GeneratedPluginRegistrant.h:9:8
Error (Xcode): failed to emit precompiled header '/Users/jakubsmolik/Library/Developer/Xcode/DerivedData/Runner-azxhqyehtpfjfdebvbrgytcvngkj/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_34SWA3BTSC5ZE-clang_PR9P9IIEUPSF.pch' for bridging header '/Users/jakubsmolik/Developer/gitreps/achilleus-app/ios/Runner/Runner-Bridging-Header.h'
Error launching application on Jakub's iPhone.

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions