OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
[question]: Lexical or Preprocessor Issue (Xcode): 'OneSignal/OneSignal.h' file not found
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 cleandoesn't help- deleted pub cache doesn't help
rm -rf Podfile.lock Pods && pod install --repo-updatedoesn'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
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@rensamatar Thank you for reaching out do you mind posting your podfile?
# 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 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?
# 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
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??
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
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).
The specific changes:
After I amended the changes, it worked fine. Maybe OneSignal needs to update the migration guide.
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.
Hi @akifarhan I updated the pubspec.yaml to
onesignal_flutter: ^5.0.3and follow the migration guide by update the Podfiletarget 'OneSignalNotificationServiceExtension' do use_frameworks! pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0' endand 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.
![]()
i have the same issue any solution for this problem?
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!
I have the same problem and have not found a solution
yes from my side also am facing the same problem could it be solved ASAP it really urgent on my side?
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
@jennantilla
Can we have update on this issue pls
Hello Is there any news on this issue, it quite urgent for me to manage in my project Kindly help me on this.
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.
Hi @nan-li
When we use 5.2.3 & #import <OneSignalExtension/OneSignalExtension.h> we face the below issue