OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
606 stars 205 forks source link

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

Open rensamatar opened 1 year ago

rensamatar commented 1 year ago

How can we help?

How do I solve the issue for missing file.

Env:

Screen Shot 2566-04-21 at 13 45 01

Code of Conduct

emawby commented 1 year ago

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

rensamatar commented 1 year ago
# 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 commented 1 year ago

@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 commented 1 year ago
# 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 commented 1 year ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 8 months ago

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 commented 7 months ago

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 commented 4 months ago

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:

abdullah017 commented 1 day ago

I have the same problem and have not found a solution