invertase / firestore-ios-sdk-frameworks

⚡ Precompiled Firestore iOS SDKs extracted from the Firebase iOS SDK repository release downloads for faster build times.
Apache License 2.0
427 stars 48 forks source link

[Solved] Compile issues using pod framework. #58

Closed cybex-dev closed 1 year ago

cybex-dev commented 1 year ago

As we know, Firestore takes a while to compile for XCode/iOS. For this reason, I attempted to solution: [Update] Cloud Firestore Xcode Build Times

TL;DR Add the pod... line to Runner Podfile

# ...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'

# ...
end

Note: I've had to change mine to 9.3.0 (see output below)

XCode: 13.3.1

Flutter Doctor ``` flutter doctor -v [✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-x64, locale en-ZA) • Flutter version 3.0.5 at /Applications/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (9 weeks ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2 Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/mac/Library/Android/sdk • Platform android-32, build-tools 30.0.3 • Java binary at: /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer ! CocoaPods 1.10.1 out of date (1.11.0 is recommended). CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions. [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526/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.12+0-b1504.28-7817840) [✓] Android Studio (version 2020.3) • Android Studio at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7935034/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.10+0-b96-7281165) [✓] IntelliJ IDEA Ultimate Edition (version 2021.3) • IntelliJ at /Users/mac/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app • 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 [✓] IntelliJ IDEA Ultimate Edition (version 2021.3) • IntelliJ at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app • 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 [✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2) • IntelliJ at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/203.7148.57/IntelliJ IDEA.app • 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 [✓] VS Code (version 1.64.2) • VS Code at /Users/mac/Downloads/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (4 available) • Charles’s iPhone (white) (mobile) • c264836ff1973fd348162a06320665d8ddc18709 • ios • iOS 15.5 19F77 • Charles’s iPhone (black) (mobile) • 49e43e75c23a6199ac3f463bdc14a07d154d4d5e • ios • iOS 15.5 19F77 • macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.125 ! Error: Charles’s iPhone (white) is busy: Fetching debug symbols for Charles’s iPhone (white). Xcode will continue when Charles’s iPhone (white) is finished. (code -10) ! Error: Charles’s iPhone (black) is busy: Fetching debug symbols for Charles’s iPhone (black). Xcode will continue when Charles’s iPhone (black) is finished. (code -10) [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
Project pubspec dependencies ``` flutter: sdk: flutter flutter_localizations: sdk: flutter ... # Core Firebase options firebase_core: ^1.19.2 # Used with firebase_core providing FirebaseOptions in initialization flutterfire_ui: ^0.4.2+3 ... # Provides storage interface for uploading resources firebase_storage: ^10.3.3 ... # Access Firestore Cloud functions cloud_functions: ^3.3.6 ... # Provides notification mechanism for FCM/APN messages firebase_messaging: ^13.0.1 ```

Steps: (intermediate integration during development)

  1. Add line above

Podfile content

...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'
  ...
...
  1. rm Podfile.lock

  2. pod install --repo-update

Success.


Time to run

XCode compile errors (see image):

image
Compile Errors ``` In file included from /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:11: /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:43:4: error: expected a type + (FIRFirestoreSource)FIRFirestoreSourceFromArguments:(NSDictionary *_Nonnull)arguments; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:45:4: error: expected a type + (FIRFirestore *_Nullable)getCachedFIRFirestoreInstanceForKey:(NSString *_Nonnull)key; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:46:40: error: expected a type + (void)setCachedFIRFirestoreInstance:(FIRFirestore *_Nonnull)firestore ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:15:30: error: unknown type name 'FIRLoadBundleTask' @property(readwrite, strong) FIRLoadBundleTask *task; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:15:1: error: property with 'retain (or strong)' attribute must be of object type @property(readwrite, strong) FIRLoadBundleTask *task; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:23:3: error: use of undeclared identifier 'FIRFirestore' FIRFirestore *firestore = arguments[@"firestore"]; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:23:17: error: use of undeclared identifier 'firestore' FIRFirestore *firestore = arguments[@"firestore"]; ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:26:16: error: use of undeclared identifier 'firestore' self.task = [firestore ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:48:28: error: type-id cannot have a name [self.task addObserver:^(FIRLoadBundleTaskProgress *_Nullable progress) { ^~~~~~~~~~~~~~~~~~~~~~~~~ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:48:54: error: expected ')' [self.task addObserver:^(FIRLoadBundleTaskProgress *_Nullable progress) { ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:48:27: note: to match this '(' [self.task addObserver:^(FIRLoadBundleTaskProgress *_Nullable progress) { ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:48:26: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] [self.task addObserver:^(FIRLoadBundleTaskProgress *_Nullable progress) { ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:50:11: error: use of undeclared identifier 'progress' if (progress.state != FIRLoadBundleTaskStateError) { ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:50:29: error: use of undeclared identifier 'FIRLoadBundleTaskStateError' if (progress.state != FIRLoadBundleTaskStateError) { ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:51:16: error: use of undeclared identifier 'progress' events(progress); ^ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:48:4: error: bad receiver type 'int *' [self.task addObserver:^(FIRLoadBundleTaskProgress *_Nullable progress) { ^~~~~~~~~ /Users/mac/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/ios/Classes/FLTLoadBundleStreamHandler.m:60:4: error: bad receiver type 'int *' [self.task removeAllObservers]; ^~~~~~~~~ 1 warning and 15 errors generated. ```

Changing to version (from Podfile) from 9.3.0 to .e.g 9.5.0 or 9.6.0 results in the errors below, confirming I have to use 9.3.0

Adding:

  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.5.0'  # or '9.6.0'

Results in:

pod install --repo-update
Ignoring ffi-1.14.2 because its extensions are not built. Try: gem pristine ffi --version 1.14.2
Updating local specs repositories

CocoaPods 1.11.3 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.11.3

Analyzing dependencies
Pre-downloading: `FirebaseFirestore` from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `9.5.0`
FirebaseFirestore/AutodetectLeveldb: Detected firebase_database module. Would not include leveldb.
cloud_firestore: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
cloud_functions: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_database: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "FirebaseFirestore":
  In Podfile:
    FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `9.5.0`)

    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 3.4.3, which depends on
      Firebase/Firestore (= 9.3.0) was resolved to 9.3.0, which depends on
        FirebaseFirestore (~> 9.3.0)

Changing to 9.3.0 results in the following output (apologies for the additional packages):

Adding

  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'

Results in:

pod install --repo-update
Ignoring ffi-1.14.2 because its extensions are not built. Try: gem pristine ffi --version 1.14.2
Updating local specs repositories

CocoaPods 1.11.3 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.11.3

Analyzing dependencies
Pre-downloading: `FirebaseFirestore` from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `9.3.0`
cloud_firestore: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
cloud_functions: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_database: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
Downloading dependencies
Installing AppAuth (1.6.0)
Installing FBAEMKit (14.0.0)
Installing FBSDKCoreKit (14.0.0)
Installing FBSDKCoreKit_Basics (14.0.0)
Installing FBSDKLoginKit (14.0.0)
Installing FMDB (2.7.5)
Installing Firebase (9.3.0)
Installing FirebaseAppCheckInterop (9.6.0)
Installing FirebaseAuth (9.3.0)
Installing FirebaseAuthInterop (9.6.0)
Installing FirebaseCore (9.3.0)
Installing FirebaseCoreDiagnostics (9.6.0)
Installing FirebaseCoreExtension (9.6.0)
Installing FirebaseCoreInternal (9.6.0)
Installing FirebaseDatabase (9.3.0)
Installing FirebaseDynamicLinks (9.3.0)
Installing FirebaseFirestore (9.3.0)
Installing FirebaseFunctions (9.3.0)
Installing FirebaseInstallations (9.6.0)
Installing FirebaseMessaging (9.3.0)
Installing FirebaseMessagingInterop (9.6.0)
Installing FirebaseSharedSwift (9.6.0)
Installing FirebaseStorage (9.3.0)
Installing FirebaseStorageInternal (9.6.0)
Installing Flutter (1.0.0)
Installing GTMAppAuth (1.3.1)
Installing GTMSessionFetcher (1.7.2)
Installing GoogleDataTransport (9.2.0)
Installing GoogleMaps (7.1.0)
Installing GoogleSignIn (6.2.3)
Installing GoogleUtilities (7.8.0)
Installing PhoneNumberKit (3.3.4)
Installing PromisesObjC (2.1.1)
Installing Stripe (22.5.1)
Installing StripeApplePay (22.5.1)
Installing StripeCore (22.5.1)
Installing StripeFinancialConnections (22.5.1)
Installing StripeUICore (22.5.1)
Installing TwilioVoice (6.3.1)
Installing cloud_firestore (3.4.3)
Installing cloud_functions (3.3.6)
Installing firebase_auth (3.6.2)
Installing firebase_core (1.20.0)
Installing firebase_database (9.1.0)
Installing firebase_dynamic_links (4.3.3)
Installing firebase_messaging (13.0.1)
Installing firebase_storage (10.3.4)
Installing flutter_facebook_auth (4.4.0)
Installing geocoding (1.0.5)
Installing geolocator_apple (1.2.0)
Installing google_maps_flutter (0.0.1)
Installing google_sign_in_ios (0.0.1)
Installing image_picker_ios (0.0.1)
Installing leveldb-library (1.22.1)
Installing nanopb (2.30909.0)
Installing path_provider_ios (0.0.1)
Installing phone_number (0.12.0)
Installing shared_preferences_ios (0.0.1)
Installing sign_in_with_apple (0.0.1)
Installing sms_autofill (0.0.1)
Installing sqflite (0.0.2)
Installing stripe_ios (0.0.1)
Installing twilio_voice (0.0.1)
Installing twitter_login (0.0.1)
Installing url_launcher_ios (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 26 dependencies from the Podfile and 65 total pods installed.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).

Is this an issue on my side?

Feel free to request additional information - I'd like to assist resolving this issue ASAP.

mikehardy commented 1 year ago

Just a hunch, I wonder if this is related to the zip distribution of firebase-ios-sdk (which this pre-compiled framework distribution is based on) having a minimum deployment target of iOS 11, vs the previous 10.

56

It looks pretty similar, and if it was working with Firestore integrated "normally" (that is, not with this repo integrated) then that's the only real difference right now

cybex-dev commented 1 year ago

Just a hunch, I wonder if this is related to the zip distribution of firebase-ios-sdk (which this pre-compiled framework distribution is based on) having a minimum deployment target of iOS 11, vs the previous 10.

56

It looks pretty similar, and if it was working with Firestore integrated "normally" (that is, not with this repo integrated) then that's the only real difference right now

Hmm, so this is my Podfile. Note the platform is set to '13.0'.

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'
  ...
cybex-dev commented 1 year ago

@mikehardy consider this issue resolved and a possible duplicate.

Resolved

TL;DR: Ensure Update firebase_core and either flutterfire_ui (provider of firestore, auth & database) OR cloud_firestore is up to date.

IDE

Build times

Reduced build times, from around +6min to ~3 min.

Current Configuration

Podfile

platform :ios, '13.0'
...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.5.0-1'
  ...

pubspec.yaml

...
  # Core Firebase options
  firebase_core: ^1.22.0

  # Used with firebase_core providing FirebaseOptions in initialization
  flutterfire_ui: ^0.4.3+8
...
mikehardy commented 1 year ago

Note that 9.6.0 is out as of yesterday, and fixes a firestore CPU consumption bug on 9.5.0. There were not other breaking changes or anything so it should be safe to substitute directly, and will make your users happy (by using less CPU on their devices...)

Glad your build is working either way though, good luck with your project!

cybex-dev commented 1 year ago

Hmm, check this out.

Just gave 9.6.0 a try, there might be a problem with firebase_core's Firebase SDK version i.e. outdated?

Latest firebase_core's

# https://firebase.google.com/support/release-notes/ios
def firebase_sdk_version!()
  '9.5.0'
end

See: feat: Bump Firebase iOS SDK to 9.5.0

Note the version, it will be referenced later (in error output)


Configuration

pubspec.yaml

...

  # Core Firebase options
  firebase_core: ^1.22.0

  cloud_firestore: ^3.4.7
  firebase_database: ^9.1.4
  firebase_auth: ^3.8.0
...

Podfile

platform :ios, '13.0'
...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.6.0'
  ...

Steps to reproduce

(from existing project)

  1. Update pod version to 9.6.0 (see above)
  2. Clean & refresh flutter packages
    flutter clean && flutter pub get
  3. update pod packages
    cd ios && pod install --repo-update

Output from steps above:

mac@Macs-MacBook-Pro ios % pod install
Analyzing dependencies
Pre-downloading: `FirebaseFirestore` from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `9.6.0`
cloud_firestore: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
cloud_functions: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
firebase_database: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '9.5.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "FirebaseFirestore":
  In Podfile:
    FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `9.6.0`)

    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 3.4.7, which depends on
      Firebase/Firestore (= 9.5.0) was resolved to 9.5.0, which depends on
        FirebaseFirestore (~> 9.5.0)
mac@Macs-MacBook-Pro ios % 

For now, I'll use 9.5.0-1 - last working version.

mikehardy commented 1 year ago

You need to override it I think https://firebase.flutter.dev/docs/manual-installation#iosmacos

cybex-dev commented 1 year ago

You need to override it I think https://firebase.flutter.dev/docs/manual-installation#iosmacos

Perfect, updated Podfile file with

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

# Override Firebase SDK Version
$FirebaseSDKVersion = '9.6.0'
...

Should this be considered a temporary fix until firebase_core is updated to reflect this new version?

mikehardy commented 1 year ago

Yep, an override is always just until core is updated. If you haven't logged an issue for them to update yet or there isn't one already, might be good to do so in order to subscribe to it so you know to unpin the version later as they resolve/ merge an update

mikehardy commented 1 year ago

PR in progress, I collaborated on it over there, nothing more actionable here and I know you're subscribed there so I think we're all good. Cheers!