facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.8k stars 3.56k forks source link

[!] The `FacebookSDK` Pod is not installed and cannot be updated #2207

Open Emaren opened 1 year ago

Emaren commented 1 year ago

Checklist before submitting a bug report

Xcode version

14.3

Facebook iOS SDK version

10.7.0

Dependency Manager

CocoaPods

SDK Framework

Login

Goals

Login to flutter app with Facebook login

Expected results

To login to my flutter app

Actual results

Invalid Scopes: email. This message is only shown to developers.

Steps to reproduce

Add Facebook as a sign in method to Firebase and add the code to the flutter app.

Code samples & details

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
pod 'FBAudienceNetwork'
pod 'FacebookSDK'
pod 'FacebookSDK/LoginKit'
pod 'FacebookSDK/ShareKit'
pod 'FacebookSDK/PlacesKit'
pod 'FBSDKMessengerShareKit'

# 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

- abseil/types/variant (1.20211102.0):
    - abseil/base/base_internal
    - abseil/base/config
    - abseil/base/core_headers
    - abseil/meta/type_traits
    - abseil/types/bad_variant_access
    - abseil/utility/utility
  - abseil/utility/utility (1.20211102.0):
    - abseil/base/base_internal
    - abseil/base/config
    - abseil/meta/type_traits
  - AppAuth (1.6.2):
    - AppAuth/Core (= 1.6.2)
    - AppAuth/ExternalUserAgent (= 1.6.2)
  - AppAuth/Core (1.6.2)
  - AppAuth/ExternalUserAgent (1.6.2):
    - AppAuth/Core
  - BoringSSL-GRPC (0.0.24):
    - BoringSSL-GRPC/Implementation (= 0.0.24)
    - BoringSSL-GRPC/Interface (= 0.0.24)
  - BoringSSL-GRPC/Implementation (0.0.24):
    - BoringSSL-GRPC/Interface (= 0.0.24)
  - BoringSSL-GRPC/Interface (0.0.24)
  - cloud_firestore (4.6.0):
    - Firebase/Firestore (= 10.7.0)
    - firebase_core
    - Flutter
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - FBAEMKit (16.0.1):
    - FBSDKCoreKit_Basics (= 16.0.1)
  - FBSDKCoreKit (16.0.1):
    - FBAEMKit (= 16.0.1)
    - FBSDKCoreKit_Basics (= 16.0.1)
  - FBSDKCoreKit_Basics (16.0.1)
  - FBSDKLoginKit (16.0.1):
    - FBSDKCoreKit (= 16.0.1)
  - Firebase/Auth (10.7.0):
    - Firebase/CoreOnly
    - FirebaseAuth (~> 10.7.0)
  - Firebase/CoreOnly (10.7.0):
    - FirebaseCore (= 10.7.0)
  - Firebase/Firestore (10.7.0):
    - Firebase/CoreOnly
    - FirebaseFirestore (~> 10.7.0)
  - Firebase/Messaging (10.7.0):
    - Firebase/CoreOnly
    - FirebaseMessaging (~> 10.7.0)
  - Firebase/Storage (10.7.0):
    - Firebase/CoreOnly
    - FirebaseStorage (~> 10.7.0)
  - firebase_auth (4.5.0):
    - Firebase/Auth (= 10.7.0)
    - firebase_core
    - Flutter
  - firebase_core (2.12.0):
    - Firebase/CoreOnly (= 10.7.0)
    - Flutter
  - firebase_messaging (14.5.0):
    - Firebase/Messaging (= 10.7.0)
    - firebase_core
    - Flutter
  - firebase_storage (11.1.2):
    - Firebase/Storage (= 10.7.0)
    - firebase_core
    - Flutter
  - FirebaseAppCheckInterop (10.9.0)
  - FirebaseAuth (10.7.0):
    - FirebaseCore (~> 10.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.8)
    - GoogleUtilities/Environment (~> 7.8)
    - GTMSessionFetcher/Core (< 4.0, >= 2.1)
  - FirebaseAuthInterop (10.9.0)
  - FirebaseCore (10.7.0):
    - FirebaseCoreInternal (~> 10.0)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/Logger (~> 7.8)
  - FirebaseCoreExtension (10.9.0):
    - FirebaseCore (~> 10.0)
  - FirebaseCoreInternal (10.9.0):
    - "GoogleUtilities/NSData+zlib (~> 7.8)"
  - FirebaseFirestore (10.7.0):
    - abseil/algorithm (~> 1.20211102.0)
    - abseil/base (~> 1.20211102.0)
    - abseil/container/flat_hash_map (~> 1.20211102.0)
    - abseil/memory (~> 1.20211102.0)
    - abseil/meta (~> 1.20211102.0)
    - abseil/strings/strings (~> 1.20211102.0)
    - abseil/time (~> 1.20211102.0)
    - abseil/types (~> 1.20211102.0)
    - FirebaseCore (~> 10.0)
    - "gRPC-C++ (~> 1.44.0)"
    - leveldb-library (~> 1.22)
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - FirebaseInstallations (10.9.0):
    - FirebaseCore (~> 10.0)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/UserDefaults (~> 7.8)
    - PromisesObjC (~> 2.1)
  - FirebaseMessaging (10.7.0):
    - FirebaseCore (~> 10.0)
    - FirebaseInstallations (~> 10.0)
    - GoogleDataTransport (~> 9.2)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.8)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/Reachability (~> 7.8)
    - GoogleUtilities/UserDefaults (~> 7.8)
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - FirebaseStorage (10.7.0):
    - FirebaseAppCheckInterop (~> 10.0)
    - FirebaseAuthInterop (~> 10.0)
    - FirebaseCore (~> 10.0)
    - FirebaseCoreExtension (~> 10.0)
    - GTMSessionFetcher/Core (< 4.0, >= 2.1)
  - Flutter (1.0.0)
  - flutter_facebook_auth (5.0.9):
    - FBSDKLoginKit (~> 16.0.1)
    - Flutter
  - flutter_local_notifications (0.0.1):
    - Flutter
  - flutter_secure_storage (6.0.0):
    - Flutter
  - google_sign_in_ios (0.0.1):
    - Flutter
    - GoogleSignIn (~> 6.2)
  - GoogleDataTransport (9.2.3):
    - GoogleUtilities/Environment (~> 7.7)
    - nanopb (< 2.30910.0, >= 2.30908.0)
    - PromisesObjC (< 3.0, >= 1.2)
  - GoogleSignIn (6.2.4):
    - AppAuth (~> 1.5)
    - GTMAppAuth (~> 1.3)
    - GTMSessionFetcher/Core (< 3.0, >= 1.1)
  - GoogleUtilities/AppDelegateSwizzler (7.11.1):
    - GoogleUtilities/Environment
    - GoogleUtilities/Logger
    - GoogleUtilities/Network
  - GoogleUtilities/Environment (7.11.1):
    - PromisesObjC (< 3.0, >= 1.2)
  - GoogleUtilities/Logger (7.11.1):
    - GoogleUtilities/Environment
  - GoogleUtilities/Network (7.11.1):
    - GoogleUtilities/Logger
    - "GoogleUtilities/NSData+zlib"
    - GoogleUtilities/Reachability
  - "GoogleUtilities/NSData+zlib (7.11.1)"
  - GoogleUtilities/Reachability (7.11.1):
    - GoogleUtilities/Logger
  - GoogleUtilities/UserDefaults (7.11.1):
    - GoogleUtilities/Logger
  - "gRPC-C++ (1.44.0)":
    - "gRPC-C++/Implementation (= 1.44.0)"
    - "gRPC-C++/Interface (= 1.44.0)"
  - "gRPC-C++/Implementation (1.44.0)":
    - abseil/base/base (= 1.20211102.0)
    - abseil/base/core_headers (= 1.20211102.0)
    - abseil/container/flat_hash_map (= 1.20211102.0)
    - abseil/container/inlined_vector (= 1.20211102.0)
    - abseil/functional/bind_front (= 1.20211102.0)
    - abseil/hash/hash (= 1.20211102.0)
    - abseil/memory/memory (= 1.20211102.0)
    - abseil/random/random (= 1.20211102.0)
    - abseil/status/status (= 1.20211102.0)
    - abseil/status/statusor (= 1.20211102.0)
    - abseil/strings/cord (= 1.20211102.0)
    - abseil/strings/str_format (= 1.20211102.0)
    - abseil/strings/strings (= 1.20211102.0)
    - abseil/synchronization/synchronization (= 1.20211102.0)
    - abseil/time/time (= 1.20211102.0)
    - abseil/types/optional (= 1.20211102.0)
    - abseil/types/variant (= 1.20211102.0)
    - abseil/utility/utility (= 1.20211102.0)
    - "gRPC-C++/Interface (= 1.44.0)"
    - gRPC-Core (= 1.44.0)
  - "gRPC-C++/Interface (1.44.0)"
  - gRPC-Core (1.44.0):
    - gRPC-Core/Implementation (= 1.44.0)
    - gRPC-Core/Interface (= 1.44.0)
  - gRPC-Core/Implementation (1.44.0):
    - abseil/base/base (= 1.20211102.0)
    - abseil/base/core_headers (= 1.20211102.0)
    - abseil/container/flat_hash_map (= 1.20211102.0)
    - abseil/container/inlined_vector (= 1.20211102.0)
    - abseil/functional/bind_front (= 1.20211102.0)
    - abseil/hash/hash (= 1.20211102.0)
    - abseil/memory/memory (= 1.20211102.0)
    - abseil/random/random (= 1.20211102.0)
    - abseil/status/status (= 1.20211102.0)
    - abseil/status/statusor (= 1.20211102.0)
    - abseil/strings/cord (= 1.20211102.0)
    - abseil/strings/str_format (= 1.20211102.0)
    - abseil/strings/strings (= 1.20211102.0)
    - abseil/synchronization/synchronization (= 1.20211102.0)
    - abseil/time/time (= 1.20211102.0)
    - abseil/types/optional (= 1.20211102.0)
    - abseil/types/variant (= 1.20211102.0)
    - abseil/utility/utility (= 1.20211102.0)
    - BoringSSL-GRPC (= 0.0.24)
    - gRPC-Core/Interface (= 1.44.0)
    - Libuv-gRPC (= 0.0.10)
  - gRPC-Core/Interface (1.44.0)
  - GTMAppAuth (1.3.1):
    - AppAuth/Core (~> 1.6)
    - GTMSessionFetcher/Core (< 3.0, >= 1.5)
  - GTMSessionFetcher/Core (2.3.0)
  - image_picker_ios (0.0.1):
    - Flutter
  - leveldb-library (1.22.2)
  - Libuv-gRPC (0.0.10):
    - Libuv-gRPC/Implementation (= 0.0.10)
    - Libuv-gRPC/Interface (= 0.0.10)
  - Libuv-gRPC/Implementation (0.0.10):
    - Libuv-gRPC/Interface (= 0.0.10)
  - Libuv-gRPC/Interface (0.0.10)
  - nanopb (2.30909.0):
    - nanopb/decode (= 2.30909.0)
    - nanopb/encode (= 2.30909.0)
  - nanopb/decode (2.30909.0)
  - nanopb/encode (2.30909.0)
  - path_provider_foundation (0.0.1):
    - Flutter
    - FlutterMacOS
  - PromisesObjC (2.2.0)
  - share_plus (0.0.1):
    - Flutter
  - sign_in_with_apple (0.0.1):
    - Flutter
  - video_player_avfoundation (0.0.1):
    - Flutter

DEPENDENCIES:
  - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
  - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
  - firebase_core (from `.symlinks/plugins/firebase_core/ios`)
  - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
  - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
  - Flutter (from `Flutter`)
  - flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`)
  - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
  - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
  - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/ios`)
  - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
  - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
  - share_plus (from `.symlinks/plugins/share_plus/ios`)
  - sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
  - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`)

SPEC REPOS:
  trunk:
    - abseil
    - AppAuth
    - BoringSSL-GRPC
    - FBAEMKit
    - FBSDKCoreKit
    - FBSDKCoreKit_Basics
    - FBSDKLoginKit
    - Firebase
    - FirebaseAppCheckInterop
    - FirebaseAuth
    - FirebaseAuthInterop
    - FirebaseCore
    - FirebaseCoreExtension
    - FirebaseCoreInternal
    - FirebaseFirestore
    - FirebaseInstallations
    - FirebaseMessaging
    - FirebaseStorage
    - GoogleDataTransport
    - GoogleSignIn
    - GoogleUtilities
    - "gRPC-C++"
    - gRPC-Core
    - GTMAppAuth
    - GTMSessionFetcher
    - leveldb-library
    - Libuv-gRPC
    - nanopb
    - PromisesObjC

EXTERNAL SOURCES:
  cloud_firestore:
    :path: ".symlinks/plugins/cloud_firestore/ios"
  firebase_auth:
    :path: ".symlinks/plugins/firebase_auth/ios"
  firebase_core:
    :path: ".symlinks/plugins/firebase_core/ios"
  firebase_messaging:
    :path: ".symlinks/plugins/firebase_messaging/ios"
  firebase_storage:
    :path: ".symlinks/plugins/firebase_storage/ios"
  Flutter:
    :path: Flutter
  flutter_facebook_auth:
    :path: ".symlinks/plugins/flutter_facebook_auth/ios"
  flutter_local_notifications:
    :path: ".symlinks/plugins/flutter_local_notifications/ios"
  flutter_secure_storage:
    :path: ".symlinks/plugins/flutter_secure_storage/ios"
  google_sign_in_ios:
    :path: ".symlinks/plugins/google_sign_in_ios/ios"
  image_picker_ios:
    :path: ".symlinks/plugins/image_picker_ios/ios"
  path_provider_foundation:
    :path: ".symlinks/plugins/path_provider_foundation/ios"
  share_plus:
    :path: ".symlinks/plugins/share_plus/ios"
  sign_in_with_apple:
    :path: ".symlinks/plugins/sign_in_with_apple/ios"
  video_player_avfoundation:
    :path: ".symlinks/plugins/video_player_avfoundation/ios"

SPEC CHECKSUMS:
  abseil: ebe5b5529fb05d93a8bdb7951607be08b7fa71bc
  AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
  BoringSSL-GRPC: 3175b25143e648463a56daeaaa499c6cb86dad33
  cloud_firestore: 3809dfc121ab99b81bba51eb84ac6ca3f9033325
  FBAEMKit: daac7466b918752f020345be5c7d9787f98cfc07
  FBSDKCoreKit: 2cb033464b2134af0138f87d20b859eb3f9be359
  FBSDKCoreKit_Basics: d37280da2e65872f0e931d15f45d97ea324fec37
  FBSDKLoginKit: c47a3b90920702487b10b647c63520dc2676dad9
  Firebase: 0219acf760880eeec8ce479895bd7767466d9f81
  firebase_auth: 1eb69de8f57040c5c78bb3267412e9cb395fd08c
  firebase_core: 312d0d81b346ec20540822c8498e626d6918ef48
  firebase_messaging: 67fbcdaf6a7c81849590e542eff2409dc49d9fa5
  firebase_storage: f6fb3e54e886182b5ab5cf514da1d9ceb196fa2f
  FirebaseAppCheckInterop: e69dde5cd51b88ee1b4339d6766b691272256f9b
  FirebaseAuth: dd64c01631df724b09f33e584625775c52f7d71f
  FirebaseAuthInterop: e53c08e60a02de17d1ab77c5032db8ae22d3a799
  FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7
  FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d
  FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e
  FirebaseFirestore: 3963a6edd1c84b4748dab3e2c62624a29d03eca1
  FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0
  FirebaseMessaging: ac9062bcc35ed56e15a0241d8fd317022499baf8
  FirebaseStorage: 4841efa304543e1f9e4ca116c559c7a1ea2a9d0f
  Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
  flutter_facebook_auth: 42016bec1574eabf69bc2fe4311e8cd55813d352
  flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
  flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
  google_sign_in_ios: 1256ff9d941db546373826966720b0c24804bcdd
  GoogleDataTransport: f0308f5905a745f94fb91fea9c6cbaf3831cb1bd
  GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
  GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
  "gRPC-C++": 9675f953ace2b3de7c506039d77be1f2e77a8db2
  gRPC-Core: 943e491cb0d45598b0b0eb9e910c88080369290b
  GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
  GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
  image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
  leveldb-library: f03246171cce0484482ec291f88b6d563699ee06
  Libuv-gRPC: 55e51798e14ef436ad9bc45d12d43b77b49df378
  nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
  path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
  PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
  share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
  sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
  video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126

PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.12.1
tonyblum@Tonys-MacBook-Pro ios % let facebookSDKVersion = FBSDKCoreKit.sdkVersion()

function> 
function> 
tonyblum@Tonys-MacBook-Pro ios % pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
Downloading dependencies
Installing Bolts (1.9.1)
Installing FBSDKMarketingKit (4.38.0)

[!] Error installing FBSDKMarketingKit
[!] /usr/bin/curl -f -L -o /var/folders/qd/6p_8ry0x3cxg29q5w49rdf_40000gn/T/d20230512-11895-z2x2bh/file.zip https://origincache.facebook.com/developers/resources/?id=FacebookSDKs-iOS-4.38.0.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.12.1 cocoapods-downloader/1.6.3'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com
Warning: Problem : timeout. Will retry in 1 seconds. 2 retries left.
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com
Warning: Problem : timeout. Will retry in 2 seconds. 1 retries left.
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com

tonyblum@Tonys-MacBook-Pro ios % pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '10.7.0' defined in 'firebase_core'
Downloading dependencies
Installing Bolts (1.9.1)
Installing FBAudienceNetwork (6.12.0)
Installing FBSDKMarketingKit (4.38.0)

[!] Error installing FBSDKMarketingKit
[!] /usr/bin/curl -f -L -o /var/folders/qd/6p_8ry0x3cxg29q5w49rdf_40000gn/T/d20230512-12169-1l9l0f7/file.zip https://origincache.facebook.com/developers/resources/?id=FacebookSDKs-iOS-4.38.0.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.12.1 cocoapods-downloader/1.6.3'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com
Warning: Problem : timeout. Will retry in 1 seconds. 2 retries left.
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com
Warning: Problem : timeout. Will retry in 2 seconds. 1 retries left.
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: origincache.facebook.com

tonyblum@Tonys-MacBook-Pro ios % flutter doctor -v
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E261 darwin-arm64, locale en-CA)
    • Flutter version 3.7.12 on channel stable at /Users/tonyblum/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (4 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/tonyblum/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = /Users/tonyblum/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/tonyblum/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode-14.3.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (3 available)
    • Tony’s iPhone (3) (mobile) • 00008120-0018242E229BC01E • ios            • iOS 16.3.1 20D67
    • macOS (desktop)            • macos                     • darwin-arm64   • macOS 13.3.1 22E261 darwin-arm64
    • Chrome (web)               • chrome                    • web-javascript • Google Chrome 113.0.5672.92

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
import 'app_user.dart';
import 'auth_service.dart';
import 'hidden_drawer.dart';
import 'home_pages/owner_home_page.dart';
import 'user_info_screen.dart';
import 'widgets/facebook_sign_in_button.dart';
import 'widgets/google_sign_in_button.dart';

class SignInScreen extends StatefulWidget {
  @override
  _SignInScreenState createState() => _SignInScreenState();
}

class _SignInScreenState extends State<SignInScreen> {
  final AuthService _authService = AuthService();
  String? _email;
  String? _password;
  String? _status;
  String? _name;
  // late String _role;
  ValueNotifier<bool> _signingInNotifier = ValueNotifier<bool>(false);

  late String _role = 'DefaultRole';

  void _signUp() async {
    print('SignUp: Starting sign up');

    if (_email == null ||
        _email!.isEmpty ||
        _password == null ||
        _password!.isEmpty) {
      if (mounted) setState(() => _status = 'Please enter email and password');
      return;
    }
    print('SignUp: User credential received');

    if (!isEmailValid(_email!)) {
      if (mounted) setState(() => _status = 'Invalid email format');
      return;
    }
    print('SignUp: User data saved in Firestore');

    try {
      UserCredential userCredential =
          await _authService.signUp(_email!, _password!);
      if (mounted) setState(() => _status = 'Signed up successfully');
      print('SignUp: Sign up completed successfully');

      // Send verification email
      await userCredential.user?.sendEmailVerification();
      if (mounted) setState(() => _status = 'Verification email sent');
    } on FirebaseAuthException catch (e) {
      if (mounted) setState(() => _status = 'Sign up error: ${e.message}');
    }
  }

  void _signIn() async {
    print('SignIn: Starting sign in');

    if (_email == null ||
        _email!.isEmpty ||
        _password == null ||
        _password!.isEmpty) {
      if (mounted) setState(() => _status = 'Please enter email and password');
      return;
    }
    print('SignIn: User credential received');

    try {
      print('SignIn: Attempting to sign in');
      UserCredential userCredential =
          await _authService.signIn(_email!, _password!);
      print(
          'SignIn: User signed in successfully with UID: ${userCredential.user?.uid}');

      if (mounted) setState(() => _status = 'Signed in successfully');

      // Fetch the user from Firestore
      print('SignIn: Fetching user from Firestore');
      AppUser? user =
          await _authService.getUserFromFirestore(userCredential.user!.uid);
      print('SignIn: Fetched user from Firestore with UID: ${user?.uid}');

      // Schedule a callback to run after the current frame has been rendered
      WidgetsBinding.instance.addPostFrameCallback((_) async {
        if (user == null) {
          // User doesn't exist in Firestore, navigate to UserInfoScreen
          print(
              'SignIn: User does not exist in Firestore, navigating to UserInfoScreen');
          Navigator.pushReplacement(
              context,
              MaterialPageRoute(
                  builder: (_) => UserInfoScreen(
                        authService: _authService,
                        uid: '',
                      )));
        } else {
          // User exists in Firestore, navigate to HiddenDrawer
          print('SignIn: User exists in Firestore, navigating to HiddenDrawer');
          Navigator.pushReplacement(
              context,
              MaterialPageRoute(
                  builder: (_) => HiddenDrawer(
                        authService: _authService,
                        onSignOut: () {},
                        uid: '',
                        children: [],
                      )));
        }
      });
    } on FirebaseAuthException catch (e) {
      if (mounted) setState(() => _status = 'Sign in error: ${e.message}');
    } catch (e) {
      if (mounted) setState(() => _status = e.toString());
    }
  }

  Widget _forgotPasswordButton() {
    return TextButton(
      onPressed: () async {
        if (_email != null && _email!.isNotEmpty) {
          try {
            await _authService.sendPasswordResetEmail(_email!);
            if (mounted) setState(() => _status = 'Password reset email sent');
          } catch (e) {
            if (mounted) setState(() => _status = e.toString());
          }
        } else {
          if (mounted)
            setState(() => _status = 'Please enter a valid email address');
        }
      },
      child: Text('Forgot Password?'),
    );
  }

  Future<void> _signInWithGoogle() async {
    print('Google Sign In button pressed');
    setState(() {
      _signingInNotifier.value = true;
    });
    try {
      final userCredential = await _authService.signInWithGoogle();
      print('Google Sign In complete');
      if (userCredential != null) {
        // Fetch the user from Firestore
        AppUser? user =
            await _authService.getUserFromFirestore(userCredential.user!.uid);
        if (user == null) {
          // User doesn't exist in Firestore, navigate to UserInfoScreen
          _navigateToUserInfoScreen();
        } else {
          // User exists in Firestore, navigate to HiddenDrawer
          _navigateToHiddenDrawer();
        }
      } else {
        if (mounted) {
          setState(() => _status = 'Google Sign In failed');
        }
      }
    } catch (e) {
      if (mounted) {
        setState(() => _status = e.toString());
      }
    } finally {
      if (mounted) {
        setState(() {
          _signingInNotifier.value = false;
        });
      }
    }
  }

  Future<void> _signInWithFacebook() async {
    _signingInNotifier.value = true;
    try {
      final userCredential = await _authService.signInWithFacebook();
      if (userCredential != null) {
        if (mounted) {
          _navigateToUserInfoScreen();
        }
      } else {
        setState(() => _status = 'Facebook Sign In failed');
      }
    } catch (e) {
      setState(() => _status = e.toString());
    }
    _signingInNotifier.value = false;
  }

  void _signInWithApple() async {
    _signingInNotifier.value = true;
    try {
      await _authService.signInWithApple();
      _navigateToUserInfoScreen();
    } catch (e) {
      if (mounted) setState(() => _status = e.toString());
    }
    _signingInNotifier.value = false;
  }

  void _navigateToOwnerHomePage() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      if (!mounted)
        return; // Add this line to check if the widget is still mounted

      final result = await Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => OwnerHomePage(
            authService: _authService,
            onSignOut: () => Navigator.pop(context, 'Signed out'),
          ),
        ),
      );

      if (result != null && result is String && mounted) {
        // Add mounted check here
        setState(() => _status = result);
      }
    });
  }

  void _navigateToHiddenDrawer() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      if (!mounted)
        return; // Add this line to check if the widget is still mounted

      final result = await Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => HiddenDrawer(
            authService: _authService,
            onSignOut: () {},
            uid: '',
            children: [],
          ),
        ),
      );

      if (mounted) {
        if (result != null && result is String) {
          setState(() => _status = result);
        }
      }
    });
  }

  _navigateToUserInfoScreen() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      if (!mounted) return;

      final result = await Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => UserInfoScreen(
            uid: _authService.currentUser!.uid,
            authService: _authService,
          ),
        ),
      );
    });
  }

  bool isEmailValid(String email) {
    final RegExp emailRegex =
        RegExp(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$");
    return emailRegex.hasMatch(email);
  }

  @override
  Widget build(BuildContext context) {
    return _buildSignInScreen();
  }

  Widget _buildSignInScreen() {
    return Scaffold(
      appBar: AppBar(
        title: Text(''),
        backgroundColor: Color.fromARGB(255, 3, 126, 18),
      ),
      body: Padding(
        padding: EdgeInsets.all(16),
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image(image: AssetImage('assets/blum.png')),
              TextField(
                onChanged: (value) => setState(() => _email = value),
                decoration: InputDecoration(labelText: 'Email'),
              ),
              TextField(
                onChanged: (value) => setState(() => _password = value),
                decoration: InputDecoration(labelText: 'Password'),
                obscureText: true,
              ),
              SizedBox(height: 10),
              ElevatedButton(
                onPressed: _signIn,
                child: ShaderMask(
                  shaderCallback: (bounds) => LinearGradient(
                    colors: [
                      Color.fromARGB(255, 207, 207, 207),
                      Color.fromARGB(255, 254, 254, 254)
                    ],
                    begin: Alignment.bottomLeft,
                    end: Alignment.topRight,
                  ).createShader(bounds),
                  child: Text(
                    'Sign in',
                    style: TextStyle(
                      // Use the same color for the text that you're using for the gradient start/end colors
                      // This will ensure the gradient is visible
                      color: Color.fromARGB(255, 238, 209, 124),
                    ),
                  ),
                ),
                style: ElevatedButton.styleFrom(
                  backgroundColor: Color.fromARGB(
                      255, 3, 126, 3), // Set the background color to grey
                ),
              ),
              _forgotPasswordButton(),
              ElevatedButton(
                onPressed: _signUp,
                child: ShaderMask(
                  shaderCallback: (bounds) => LinearGradient(
                    colors: [
                      Color.fromARGB(255, 207, 207, 207),
                      Color.fromARGB(255, 254, 254, 254)
                    ],
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                  ).createShader(bounds),
                  child: Text(
                    'Request Access',
                    style: TextStyle(
                      // Use the same color for the text that you're using for the gradient start/end colors
                      // This will ensure the gradient is visible
                      color: Color.fromARGB(255, 216, 190, 114),
                    ),
                  ),
                ),
                style: ElevatedButton.styleFrom(
                  backgroundColor: Color.fromARGB(
                      255, 3, 126, 3), // Set the background color to grey
                ),
              ),
              FacebookSignInButton(onPressed: _signInWithFacebook),
              GoogleSignInButton(
                onPressed: () => _signInWithGoogle(),
              ),
              SizedBox(height: 15),
              SignInWithAppleButton(
                onPressed: () => _signInWithApple(),
              ),
              ValueListenableBuilder<bool>(
                valueListenable: _signingInNotifier,
                builder: (context, isSigningIn, child) {
                  if (isSigningIn) {
                    return CircularProgressIndicator();
                  } else {
                    return SizedBox.shrink();
                  }
                },
              ),
              SizedBox(height: 5),
              Text(_status ?? ''),
            ],
          ),
        ),
      ),
    );
  }
}

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
import 'app_user.dart';

class AuthService {
  final FirebaseAuth _auth = FirebaseAuth.instance;
  final FirebaseFirestore _firestore = FirebaseFirestore.instance;
  final ValueNotifier<bool> signedInNotifier = ValueNotifier<bool>(false);
  final GoogleSignIn _googleSignIn = GoogleSignIn();
  User? get currentUser => _auth.currentUser;

  Future<UserCredential> signUp(
    String email,
    String password,
  ) async {
    try {
      UserCredential userCredential = await _auth
          .createUserWithEmailAndPassword(email: email, password: password);

      // Verify the user's email.
      await userCredential.user!.sendEmailVerification();

      // Create a document for the user with the 'creationTime' field and 'role' field
      await _firestore.collection('users').doc(userCredential.user!.uid).set({
        'emailVerified': userCredential.user!.emailVerified,
        'creationTime': FieldValue.serverTimestamp(),
        // 'role': role, // Store the role in Firestore
        // 'name': name, // Store the role in Firestore
        // Add other user data here...
      });

      return userCredential;
    } on FirebaseAuthException catch (e) {
      throw Exception('Check Email');
    }
  }

  Future<UserCredential> signIn(String email, String password) async {
    try {
      print('AuthService.signIn: Attempting to sign in');
      UserCredential userCredential = await _auth.signInWithEmailAndPassword(
          email: email, password: password);

      print(
          'AuthService.signIn: UserCredential obtained: ${userCredential.user?.uid}');

      print('AuthService.signIn: User signed in: ${userCredential.user?.uid}');

      return userCredential;
    } on FirebaseAuthException catch (e) {
      print('FirebaseAuthException caught in signIn: ${e.code}, ${e.message}');
      throw Exception('Sign in error: ${e.message}');
    } catch (e) {
      print('Error in signIn: $e');
      throw e;
    }
  }

  Future<bool> checkIfUserExists(String uid) async {
    DocumentSnapshot doc = await _firestore.collection('users').doc(uid).get();
    return doc.exists;
  }

  Future<AppUser?> getUserFromFirestore(String uid) async {
    DocumentSnapshot doc = await _firestore.collection('users').doc(uid).get();
    return doc.exists ? AppUser.fromDocument(doc) : null;
  }

  Future<void> signOut() async {
    print('AuthService.signOut called');
    await _auth.signOut();
  }

  Future<UserCredential?> signInWithGoogle() async {
    try {
      print('Starting Google Sign In');
      await Future.delayed(Duration(milliseconds: 100));

      final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
      if (googleUser == null) {
        print('Google Sign In was canceled by user');
        // Handle the cancel action here, e.g., return null or show a message to the user
        return null;
      }
      print('Google User: $googleUser');
      final GoogleSignInAuthentication googleAuth =
          await googleUser.authentication;
      final credential = GoogleAuthProvider.credential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );
      print('Signing in with Firebase using Google credentials');
      final userCredential = await _auth.signInWithCredential(credential);
      print('Successfully signed in with Google: ${userCredential.user}');

      // Update the ValueNotifier to trigger a rebuild
      signedInNotifier.value = true;

      return userCredential;
    } catch (e) {
      print('Error signing in with Google: $e');
      throw e;
    }
  }

  Future<UserCredential> signInWithFacebook() async {
    final LoginResult result = await FacebookAuth.instance.login();
    if (result.status != LoginStatus.success) {
      throw Exception('Facebook Sign In failed');
    }
    final OAuthCredential credential =
        FacebookAuthProvider.credential(result.accessToken!.token);
    return _auth.signInWithCredential(credential);
  }

  Future<UserCredential> signInWithApple() async {
    final credential = await SignInWithApple.getAppleIDCredential(
      scopes: [
        AppleIDAuthorizationScopes.email,
        AppleIDAuthorizationScopes.fullName,
      ],
    );

    return _auth.signInWithCredential(
      OAuthProvider('apple.com').credential(
        idToken: credential.identityToken,
        accessToken: credential.authorizationCode,
      ),
    );
  }

  Future<void> sendPasswordResetEmail(String email) async {
    return _auth.sendPasswordResetEmail(email: email);
  }

  Stream<User?> authStateChanges() {
    _auth.authStateChanges().listen((User? user) {
      if (user == null) {
        print('User is currently signed out!');
      } else {
        print('User is signed in! User id: ${user.uid}');
      }
    });
    return _auth.authStateChanges();
  }

  Future<AppUser?> get currentAppUser async {
    final user = _auth.currentUser;
    if (user == null) {
      return null;
    }

    // Fetch the user's name and role from Firestore
    DocumentSnapshot docSnapshot = await FirebaseFirestore.instance
        .collection('users')
        .doc(user.uid)
        .get();

    if (!docSnapshot.exists) {
      // Handle when document doesn't exist
      return null;
    }

    var docData = docSnapshot.data() as Map<String, dynamic>?;
    if (docData == null) {
      // Handle when there's no data
      throw Exception("No data found for the user");
    }

    final name = docData['name'] as String?;
    final role = docData['role'] as String?;
    return AppUser(uid: user.uid, name: name, role: role);
  }

  Future<String?> fetchUserRole(String uid) async {
    DocumentSnapshot userDoc =
        await _firestore.collection('users').doc(uid).get();
    Map<String, dynamic>? data = userDoc.data() as Map<String, dynamic>?;
    if (data != null) {
      return data['role'];
    } else {
      // Handle the situation when there's no data (the document doesn't exist or there's a different problem)
      throw Exception("No data found for the user");
    }
  }

  Future<void> deleteUser(String uid) async {
    try {
      // First delete the user from Firestore
      await _firestore.collection('users').doc(uid).delete();

      // Then delete the user from Firebase Authentication
      User? user = _auth.currentUser;
      if (user != null && user.uid == uid) {
        await user.delete();
      }
      print('User deleted: $uid'); // Add this line
    } catch (e) {
      print("Error deleting user: $e");
      throw e;
    }
  }

  Future<void> deleteAccount() async {
    User? user = _auth.currentUser;
    if (user != null) {
      await user.delete();
    } else {
      throw Exception('No user is signed in.');
    }
  }
}
MhizMartha commented 1 year ago

Weak

monochrome-yeh commented 1 year ago

same issue here, even use pod 'Facebook-iOS-SDK'