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

[question]: Lexical or Preprocessor Issue (Xcode): 'OneSignal/OneSignal.h' file not found

Open rensamatar opened this issue 2 years ago • 17 comments
trafficstars

How can we help?

How do I solve the issue for missing file.

  • I can run the project via Xcode but can't run the project via VS code
  • Same code but using Mac intel chip works on VS code.
  • flutter clean doesn't help
  • deleted pub cache doesn't help
  • rm -rf Podfile.lock Pods && pod install --repo-update doesn't help

Env:

  • Xcode Version 14.2 (14C18)
  • Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision 5464c5bac7 (1 year ago) • 2022-04-18 09:55:37 -0700 Engine • revision 57d3bac3dd Tools • Dart 2.16.2 • DevTools 2.9.2
  • ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin21]
  • Macbook pro M1
  • Cocoapods 1.12.1
Screen Shot 2566-04-21 at 13 45 01

Code of Conduct

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

rensamatar avatar Apr 21 '23 06:04 rensamatar

@rensamatar Thank you for reaching out do you mind posting your podfile?

emawby avatar Apr 21 '23 19:04 emawby

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

$FirebaseAnalyticsWithoutAdIdSupport = true

# Ignore all warnings from all pods.
inhibit_all_warnings!

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :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!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  
  # Pods for Runner
  pod 'Lokalise', '~> 0.10.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # Add the following:
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
      build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      build_configuration.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 3.4.3', '< 4.0'
end

Here is my Podfile @emawby

rensamatar avatar Apr 24 '23 10:04 rensamatar

@rensamatar You mentioned it working in Xcode but not VSCode, I wonder if your xcodebuild tools version is different than your Xcode version? E.g. it is using Xcode 13 build tools for command line (vscode) builds. If you do flutter run via a CLI does it work?

emawby avatar Apr 24 '23 21:04 emawby

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

$FirebaseAnalyticsWithoutAdIdSupport = true

# Ignore all warnings from all pods.
inhibit_all_warnings!

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :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!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  
  # Pods for Runner
  pod 'Lokalise', '~> 0.10.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # Add the following:
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
      build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      build_configuration.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 3.4.3', '< 4.0'
end

Dodalun avatar Apr 25 '23 00:04 Dodalun

Lexical or Preprocessor Issue (Xcode): 'OneSignal/OneSignal.h' file not found
/Users/anmolgupta/StudioProjects/balizaprojects/secupark-mobile/ios/SecuparkMobile/NotificationService.m:0:8

Could not build the application for the simulator. Error launching application on iPhone 12 Pro.

same issue.. Any possible solution??

anmolgupta321 avatar Apr 25 '23 05:04 anmolgupta321

I'm having the same issue. Been stuck on this for days now. My Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :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!
  use_modular_headers!

  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', '>= 3.4.3', '< 4.0'
end

mrbrunoabreu avatar Aug 13 '23 20:08 mrbrunoabreu

I got the same error and when I checked out the documentation, it seems like there's a minor change to the NotificationService.m file (see 3.10).

image

The specific changes: image

After I amended the changes, it worked fine. Maybe OneSignal needs to update the migration guide.

akifarhan avatar Sep 05 '23 10:09 akifarhan

Hi @akifarhan I updated the pubspec.yaml to onesignal_flutter: ^5.0.3 and follow the migration guide by update the Podfile

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0'
end

and run $cd ios/ $rm -rf PodFile.lock Pods $pod install $pod update

Also update the NotificationService.m with #import <OneSignalFramework/OneSignalFramework.h>

but error still exist.

Screenshot 2566-11-02 at 12 49 54

rensamatar avatar Nov 02 '23 05:11 rensamatar

Hi @akifarhan I updated the pubspec.yaml to onesignal_flutter: ^5.0.3 and follow the migration guide by update the Podfile

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0'
end

and run $cd ios/ $rm -rf PodFile.lock Pods $pod install $pod update

Also update the NotificationService.m with #import <OneSignalFramework/OneSignalFramework.h>

but error still exist.

Screenshot 2566-11-02 at 12 49 54

i have the same issue any solution for this problem?

filippodicostanzo avatar Nov 18 '23 14:11 filippodicostanzo

Still facing the issue. Lexical or Preprocessor Issue (Xcode): 'OneSignal/OneSignal.h' file not found /Users/mrmacbook/.pub-cache/hosted/pub.dev/onesignal_flutter-3.5.1/ios/Classes/OSFlutterTagsController.m:28:8

What i have already tried:

  • re installing cocoapods
  • pod deintegrate
  • pod install Didnt help!

saadtanvir avatar Feb 27 '24 18:02 saadtanvir

I have the same problem and have not found a solution

abdullah017 avatar Jul 04 '24 09:07 abdullah017

yes from my side also am facing the same problem could it be solved ASAP it really urgent on my side?

image

esaiamuthan avatar Jul 30 '24 14:07 esaiamuthan

Hi @rensamatar @emawby @filippodicostanzo @abdullah017 @akifarhan

Guys its quite urgent for me to release my app can any one of you fix the issue and let us know it will help us to close this problem

Thanks in advance

really waiting for your reply ASAP

esaiamuthan avatar Jul 30 '24 20:07 esaiamuthan

@jennantilla

Can we have update on this issue pls

esaiamuthan avatar Jul 31 '24 10:07 esaiamuthan

Hello Is there any news on this issue, it quite urgent for me to manage in my project Kindly help me on this.

esaiamuthan avatar Aug 08 '24 09:08 esaiamuthan

Hi everyone, please try #import <OneSignalExtension/OneSignalExtension.h> in your Notification Service Extension.

If <OneSignal/OneSignal.h> and <OneSignalFramework/OneSignalFramework.h> do not work for you.

nan-li avatar Aug 08 '24 16:08 nan-li

Hi @nan-li

When we use 5.2.3 & #import <OneSignalExtension/OneSignalExtension.h> we face the below issue

Screenshot 2024-08-27 at 18 40 20

esaiamuthan avatar Aug 27 '24 13:08 esaiamuthan