Skip to content

iOS Build Failure: 'Flutter/Flutter.h' file not found after OneSignal SDK integration #1042

@smolikja

Description

@smolikja

Environment

  • Flutter Version: 3.32.2 (Channel stable)
  • Dart Version: 3.8.1
  • Xcode Version: 16.4 (16F6)
  • CocoaPods Version: 1.16.2
  • macOS Version: 15.4.1 (24E263)
  • OneSignal Flutter SDK Version: 5.4.4
  • iOS Deployment Target: 15.6
  • Target Device: Both iOS Simulator (iPhone 16 Plus) and Physical Device (iPhone 13 Pro)

Description

After following the official OneSignal Flutter SDK setup documentation for iOS integration, the build fails with a 'Flutter/Flutter.h' file not found error. Android builds work correctly and push notifications are received successfully on Android devices.

Steps to Reproduce

  1. Created Flutter project with flavors using flutter_flavorizr
  2. Added OneSignal Flutter SDK 5.4.4 to pubspec.yaml
  3. Completed all 6 iOS setup steps from the official documentation:
    • Added Push Notifications capability
    • Added Background Modes capability with Remote notifications
    • Added App Target to App Group
    • Added Notification Service Extension
    • Added NSE Target to App Group
    • Updated NSE code and Podfile
  4. Run flutter run targeting iOS simulator or physical device
  5. Important: iOS build worked perfectly BEFORE OneSignal integration

Error Output

[ +13 ms] Failed to build iOS app
[ +1 ms] Could not build the precompiled application for the device.
[ +23 ms] 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.
[ +4 ms] "flutter run" took 42,212ms.

Current Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '15.6'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
  'Debug-dev' => :debug,
  'Profile-dev' => :release,
  'Release-dev' => :release,
  'Debug-prod' => :debug,
  'Profile-prod' => :release,
  'Release-prod' => :release,
}
def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end
  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
  use_frameworks!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
end

What I've Tried

  • Followed all steps in the official OneSignal Flutter SDK documentation
  • Verified all iOS capabilities are correctly configured
  • Confirmed Android implementation works correctly
  • No other errors from the "Common iOS build errors" section were encountered

Expected Behavior

iOS app should build successfully and be able to receive push notifications, similar to the working Android implementation.

Actual Behavior

Build fails with missing Flutter header file error, preventing iOS app from running.

Additional Context

  • This is a new iOS project created 2 days ago
  • Project uses multiple build configurations (dev/prod flavors) created with flutter_flavorizr
  • iOS build worked perfectly BEFORE OneSignal integration
  • Flutter doctor shows no issues
  • Android push notifications work perfectly
  • Error occurs on both iOS simulator and physical device

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.32.2, on macOS 15.4.1 24E263 darwin-arm64, locale en-CZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.1.1)
[✓] IntelliJ IDEA Community Edition (version 2024.3.2.2)
[✓] VS Code (version 1.100.3)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!

Possible Cause

This appears to be related to the compatibility between Flutter 3.32.2, Xcode 16.4, and OneSignal Flutter SDK 5.4.4 integration. The issue specifically seems to occur when the Notification Service Extension is added to the Podfile, as the iOS build worked perfectly before OneSignal integration. The error suggests that the Flutter framework headers are not being found during the compilation of the NSE target, potentially due to incorrect path resolution in projects using flutter_flavorizr.

Request

Could you please provide guidance on resolving this Flutter/Flutter.h header issue when integrating OneSignal with the latest Flutter and Xcode versions? This error is not mentioned in the current documentation's troubleshooting section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions