Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
rensamatar opened this issue Apr 21, 2023 · 19 comments
Closed
1 task done

Comments

@rensamatar
Copy link

rensamatar commented Apr 21, 2023

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

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Apr 21, 2023

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

@rensamatar
Copy link
Author

rensamatar commented Apr 24, 2023

# 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

@emawby
Copy link
Contributor

emawby commented Apr 24, 2023

@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?

@Dodalun
Copy link

Dodalun commented Apr 25, 2023

# 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

@anmolgupta321
Copy link

anmolgupta321 commented Apr 25, 2023

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??

@mrbrunoabreu
Copy link

mrbrunoabreu commented Aug 13, 2023

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

@akifarhan
Copy link

akifarhan commented Sep 5, 2023

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.

@rensamatar
Copy link
Author

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

@filippodicostanzo
Copy link

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?

@saadtanvir
Copy link

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!

@abdullah017
Copy link

I have the same problem and have not found a solution

@esaiamuthan
Copy link

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

image

@esaiamuthan
Copy link

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
Copy link

@jennantilla

Can we have update on this issue pls

@esaiamuthan
Copy link

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

@nan-li
Copy link
Contributor

nan-li commented Aug 8, 2024

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.

@esaiamuthan
Copy link

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

@lotus-core
Copy link

For anyone still having this issue, make sure to update the podfile as shown in the guide at this section https://documentation.onesignal.com/docs/flutter-sdk-setup#add-onesignal-sdk-to-the-onesignalnotificationserviceextension

platform :ios, '14.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__))
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

then do a pod install --repo-update in your ios folder and recompile your project.

@jennantilla
Copy link
Contributor

Appreciate the discussion here! It looks like the conversation has wound down so we'll close this issue. If there are still any additional concerns, please let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests