flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_auth:] FIRAuthDefaultUIDelegate.h:18:24: error: 'TARGET_OS_WATCHOS' is not defined on Xcode 12.5

Open gauravdangi opened this issue 5 years ago • 16 comments

I am trying to achieve Google sign-in in my application for which I included the below packages: firebase_core: ^0.7.0 firebase_auth: ^0.20.0+1 google_sign_in: ^4.5.9

Then flutter pub get. flutter run Simulator: IPhone 12 Pro Max

Click to expand!
Running Xcode build...                                                  
Xcode build done.                                            4.5s
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
Failed to build iOS app
Error output from Xcode build:
↳
    objc[70629]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x205394188) and
    ?? (0x1229fc2b8). One of the two will be used. Which one is undefined.
    objc[70629]: Class AMSupportURLSession is implemented in both ?? (0x2053941d8) and ??
    (0x1229fc308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/FirebaseCore/FirebaseCore/Source
    s/FIRLogger.m:58:28: warning: this old-style function definition is not preceded by a
    prototype [-Wstrict-prototypes]
    void FIRLoggerInitializeASL() {
                               ^
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/FirebaseCore/FirebaseCore/Source
    s/FIRLogger.m:101:20: warning: this old-style function definition is not preceded by a
    prototype [-Wstrict-prototypes]
    void FIRResetLogger() {
                       ^
    2 warnings generated.
    In file included from
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/FirebaseAuth/FirebaseAuth/Source
    s/Utilities/FIRAuthURLPresenter.m:24:
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/FirebaseAuth/FirebaseAuth/Source
    s/Utilities/FIRAuthDefaultUIDelegate.h:18:24: error: 'TARGET_OS_WATCHOS' is not defined,
    evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    #if !TARGET_OS_OSX && !TARGET_OS_WATCHOS
                           ^
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS
    Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of
    supported deployment target versions is 9.0 to 14.5.99. (in target 'image_picker' from project
    'Pods')
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS
    Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of
    supported deployment target versions is 9.0 to 14.5.99. (in target 'shared_preferences' from
    project 'Pods')
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS
    Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of
    supported deployment target versions is 9.0 to 14.5.99. (in target 'path_provider' from
    project 'Pods')
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS
    Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of
    supported deployment target versions is 9.0 to 14.5.99. (in target 'FMDB' from project 'Pods')
    /Users/gauravdangi/Development/work/examples/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS
    Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of
    supported deployment target versions is 9.0 to 14.5.99. (in target 'Flutter' from project
    'Pods')

Expected behavior

To be able to build an ios app successfully.


Additional context

I have tried all the solutions I could find on the internet like flutter clean deleting pod folder, Podfile.lock, and Podfile. and then flutter pub get, pod init inside ios directory, pod install and then flutter run but still no success.


Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-arm, locale
    en-IN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.5)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.53.2)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

I also encountered the error below:

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "firebase_auth":
      In Podfile:
        firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)

    Specs satisfying the `firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)` dependency were found, but they required a higher minimum deployment
    target.

After uncommenting and adding platform :ios, '11.0' in my Podfile, I got this error('TARGET_OS_WATCHOS' is not defined).


Flutter dependencies

flutter pub deps -- --style=compact output:

Click to expand!
Dart SDK 2.10.5
Flutter SDK 1.22.6
mytales 1.0.0+1

dependencies:
- cached_network_image 2.5.0 [flutter flutter_cache_manager octo_image]
- carousel_slider 3.0.0 [flutter]
- cupertino_icons 1.0.0
- dio 3.0.10 [http_parser path]
- firebase_auth 0.20.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_slidable 0.5.7 [flutter]
- image_picker 0.6.7+22 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- intl 0.16.1 [path]
- path 1.8.0-nullsafety.1
- path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- photo_view 0.10.3 [flutter]
- provider 4.3.3 [collection flutter nested]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sqflite 1.3.2+3 [flutter sqflite_common path]

dev dependencies:
- flutter_native_splash 0.2.11 [yaml image xml]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase_auth_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.2+6 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js]
- firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 2.1.1 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.19 [archive xml meta]
- image_picker_platform_interface 1.1.6 [flutter meta http plugin_platform_interface]
- js 0.6.2
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- nested 0.0.4 [flutter]
- octo_image 0.3.0 [flutter flutter_blurhash]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+8 [flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- process 3.0.13 [file intl meta path platform]
- quiver 2.1.5 [matcher meta]
- rxdart 0.25.0
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.2+3 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite_common 1.0.3+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- win32 1.7.4+1 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]

When I navigated to the file causing issue FIRAuthDefaultUIDelegate.h, On hovering on #import <TargetConditionals.h>, I got unrecognized preprocessing directive C/C++(11)

Screenshot 2021-02-14 at 9 57 39 PM

AppDelegate.swift

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

gauravdangi avatar Feb 14 '21 16:02 gauravdangi

Hi @gauravdangi Based on

    Specs satisfying the `firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)` dependency were found, but they required a higher minimum deployment
    target.

It seems like your iOS deployment target is too low. You need to update it to at least 10.0 Thank you

markusaksli-nc avatar Feb 15 '21 12:02 markusaksli-nc

Hi @markusaksli-nc Thanks for responding. I did update platform :ios, '9.0' to platform :ios, '11.0'. After that I encountered 'TARGET_OS_WATCHOS' is not defined error. Below is my pod file:-

Click to expand!
platform :ios, '11.0'

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
Screenshot of xcode project Screenshot 2021-02-15 at 10 05 28 PM

gauravdangi avatar Feb 15 '21 16:02 gauravdangi

Could you try pod cache clean --all and rm -rf ~/.pub-cache/hosted/pub.dartlang.org/?

markusaksli-nc avatar Feb 16 '21 09:02 markusaksli-nc

Hi @markusaksli-nc , I erased all content and settings from ios Simulator. Then I ran the commands you mentioned:- pod cache clean --all rm -rf ~/.pub-cache/hosted/pub.dartlang.org/ And then flutter run But no luck. Still getting the same error.

I think I should also mention that I'm using macOS Big Sur 11.2.1 with the new M1 chip.

Below is the o/p for the commands:-

Click to expand!
gauravdangi@Gauravs-MacBook-Air mytales % pod cache clean --all
gauravdangi@Gauravs-MacBook-Air mytales % rm -rf ~/.pub-cache/hosted/pub.dartlang.org/
gauravdangi@Gauravs-MacBook-Air mytales % flutter run
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...                                                  
Xcode build done.                                            1.8s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[2478]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1fddb8188) and ?? (0x117d602b8). One of the two will be used. Which one is
    undefined.
    objc[2478]: Class AMSupportURLSession is implemented in both ?? (0x1fddb81d8) and ?? (0x117d60308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    In file included from
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/FirebaseAuth/FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.m:24:
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/FirebaseAuth/FirebaseAuth/Sources/Utilities/FIRAuthDefaultUIDelegate.h:18:24: error:
    'TARGET_OS_WATCHOS' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    #if !TARGET_OS_OSX && !TARGET_OS_WATCHOS
                           ^
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET'
    is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'shared_preferences' from project 'Pods')
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET'
    is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'FMDB' from project 'Pods')
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET'
    is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'path_provider' from project 'Pods')
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET'
    is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'image_picker' from project 'Pods')
    /Users/gauravdangi/Development/work/projects/mytales/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET'
    is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Flutter' from project 'Pods')

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

gauravdangi avatar Feb 16 '21 13:02 gauravdangi

Do you also run into this in a new flutter create project if you add the dependency?

markusaksli-nc avatar Feb 17 '21 07:02 markusaksli-nc

Yes. I created this new project after encountering the same error in my last project. So creating a new project and adding the dependency didn't help.

gauravdangi avatar Feb 17 '21 09:02 gauravdangi

Well I'm not seeing this when running the official example and I'm not even seeing any reference to this anywhere online so I'm out of ideas here.

Labelling this for now.

markusaksli-nc avatar Feb 17 '21 09:02 markusaksli-nc

Could you share the link to the official example you're using? I'll try again.

gauravdangi avatar Feb 17 '21 09:02 gauravdangi

The code for the example is here https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth/example/lib but since the package is not compiling I'd like to imagine it isn't causing the issue

Keep in mind that the pubspec.yaml in https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth/example uses paths to the plugins in this repository instead of the typical pubspec versioning so running the entire example project isn't reasonable.

markusaksli-nc avatar Feb 17 '21 11:02 markusaksli-nc

@gauravdangi Are you using Xcode 12.5? The 'TARGET_OS_WATCHOS' is not defined was fixed in the official Firebase iOS SDK. It should be TARGET_OS_WATCH instead of TARGET_OS_WATCHOS.

ahmadtawakol avatar Feb 17 '21 18:02 ahmadtawakol

I'm also having this issue. Not sure if coincidence, but it started with an xcode update to 12.5 beta.

stephen-pace avatar Feb 22 '21 19:02 stephen-pace

Yeah it looks like that is what causes the issue, not seeing this on 12.4.

markusaksli-nc avatar Feb 23 '21 10:02 markusaksli-nc

Hi @ahmadtawakol, Changing TARGET_OS_WATCHOS to TARGET_OS_WATCH solved the problem. Thanks!!

gauravdangi avatar Feb 25 '21 03:02 gauravdangi

Have this same problem, annoying to run this every time...

sed -i -e 's/WATCHOS/WATCH/g' ./ios/Pods/FirebaseAuth/FirebaseAuth/Sources/Utilities/FIRAuthDefaultUIDelegate.h 

terrancesnyder avatar Apr 11 '21 09:04 terrancesnyder

@gauravdangi Are you using Xcode 12.5? The 'TARGET_OS_WATCHOS' is not defined was fixed in the official Firebase iOS SDK. It should be TARGET_OS_WATCH instead of TARGET_OS_WATCHOS.

Any idea, when this will be merged to flutter fire? Because, I still face this issue

saigkl avatar Apr 14 '21 12:04 saigkl

This should be fixed with the iOS SDK upgrade

markusaksli-nc avatar Apr 28 '21 13:04 markusaksli-nc