firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

🐛 [cloud_firestore] iOS, Takes too long to build on m1 ship #9393

Closed bilalsammour closed 2 years ago

bilalsammour commented 2 years ago

Bug report

When building the iOS version, it takes > 30 minutes to build on my laptop that has m1 ship with 64GB RAM.

Steps to reproduce

  1. Create a Flutter project.
  2. Add cloud_firestore: ^3.4.5 to the dependencies.
  3. Run the iOS project on an m1 ship MAC.
  4. You have to wait > 20 minutes to see the output!

Expected behavior

It should take a reasonable time to build.

Sample project

https://github.com/bilalsammour/cloud_firestore_issue



Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-arm, locale en-JO) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.70.2) [✓] Connected device (4 available) [✓] HTTP Host Availability • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.17.6 Flutter SDK 3.0.5 cloud_firestore_issue 1.0.0+1 dependencies: - cloud_firestore 3.4.5 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.5 - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] dev dependencies: - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] transitive dependencies: - async 2.8.2 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.2.0 - charcode 1.3.1 - clock 1.1.0 - cloud_firestore_platform_interface 5.7.2 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.8.5 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.16.0 - fake_async 1.3.0 [clock collection] - firebase_core 1.21.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 4.5.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 1.7.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - js 0.6.4 - lints 2.0.0 - matcher 0.12.11 [stack_trace] - material_color_utilities 0.1.4 - meta 1.7.0 - path 1.8.1 - plugin_platform_interface 2.1.2 [meta] - sky_engine 0.0.99 - source_span 1.8.2 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - term_glyph 1.2.0 - test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - vector_math 2.1.2 ```

darshankawar commented 2 years ago

@bilalsammour This issue was initially raised few years back: https://github.com/firebase/flutterfire/issues/2751 and the solution (optional) is to add below line in your ios/podfile:

https://github.com/firebase/flutterfire/blob/5b5f477d6e633a38bea561cee35db3f628719666/packages/cloud_firestore/cloud_firestore/example/ios/Podfile#L54

Wherein #{firebase_sdk_version} represents latest release version, ie, 9.4.0. The same has been mentioned in the documentation as well.

You can read more in detail about this change in the linked issue for your reference. Using this change, you should see shorter build time for ios. If not, please write in comments and I'll reopen it.

Closing for now, based on above comments.

bilalsammour commented 2 years ago

It reduces the time but it causes an error when doing archive for the iOS project, here is a screenshot:

https://www.awesomescreenshot.com/image/31604975?key=0f61d39ac10161cc32da70e8f91740ef

darshankawar commented 2 years ago

Its not clear what exactly is the error from your screenshot. Please provide properly formatted complete error log in text format.

bilalsammour commented 2 years ago

Here is the log: Local.txt

Also, here is another log for a different project using Codemagic: codemagic.log

darshankawar commented 2 years ago

Below are the errors from your log file:


In file included from /opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:8:
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:43:4: error: expected a type
+ (FIRFirestoreSource)FIRFirestoreSourceFromArguments:(NSDictionary *_Nonnull)arguments;
   ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:45:4: error: expected a type
+ (FIRFirestore *_Nullable)getCachedFIRFirestoreInstanceForKey:(NSString *_Nonnull)key;
   ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/Private/FLTFirebaseFirestoreUtils.h:46:40: error: expected a type
+ (void)setCachedFIRFirestoreInstance:(FIRFirestore *_Nonnull)firestore
                                       ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:83:40: error: expected a type
- (NSDictionary *)FIRSnapshotMetadata:(FIRSnapshotMetadata *)snapshotMetadata {
                                       ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:90:38: error: expected a type
- (NSDictionary *)FIRDocumentChange:(FIRDocumentChange *)documentChange {
                                     ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:136:40: error: expected a type
- (NSDictionary *)FIRDocumentSnapshot:(FIRDocumentSnapshot *)documentSnapshot {
                                       ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:144:46: error: expected a type
- (NSDictionary *)FIRLoadBundleTaskProgress:(FIRLoadBundleTaskProgress *)progress {
                                             ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:167:37: error: expected a type
- (NSDictionary *)FIRQuerySnapshot:(FIRQuerySnapshot *)querySnapshot {
                                    ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:19:36: error: use of undeclared identifier 'FIRTimestamp'
  } else if ([value isKindOfClass:[FIRTimestamp class]]) {
                                   ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:20:5: error: unknown type name 'FIRTimestamp'; did you mean 'CVTimeStamp'?
    FIRTimestamp *timestamp = value;
    ^~~~~~~~~~~~
    CVTimeStamp
In module 'UIKit' imported from /Users/bilalsammour/Professional/Development/Projects/Flutter/cloud_firestore_issue/ios/Pods/Target Support Files/cloud_firestore/cloud_firestore-prefix.pch:2:
In module 'CoreImage' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIColor.h:13:
In module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CIImage.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVBase.h:334:3: note: 'CVTimeStamp' declared here
} CVTimeStamp; 
  ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:20:31: error: implicit conversion of Objective-C pointer type 'id' to C pointer type 'CVTimeStamp *' requires a bridged cast
    FIRTimestamp *timestamp = value;
                              ^~~~~
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:20:31: note: use __bridge to convert directly (no change in ownership)
    FIRTimestamp *timestamp = value;
                              ^
                              (__bridge CVTimeStamp *)( )
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:20:31: note: use CFBridgingRetain call to make an ARC object available as a +1 'CVTimeStamp *'
    FIRTimestamp *timestamp = value;
                              ^
                              CFBridgingRetain( )
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:20:19: warning: incompatible pointer types initializing 'CVTimeStamp *' with an expression of type '__strong id' [-Wincompatible-pointer-types]
    FIRTimestamp *timestamp = value;
                  ^           ~~~~~
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:21:31: error: member reference type 'CVTimeStamp *' is a pointer; did you mean to use '->'?
    SInt64 seconds = timestamp.seconds;
                     ~~~~~~~~~^
                              ->
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:21:32: error: no member named 'seconds' in 'CVTimeStamp'
    SInt64 seconds = timestamp.seconds;
                     ~~~~~~~~~ ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:22:32: error: member reference type 'CVTimeStamp *' is a pointer; did you mean to use '->'?
    int nanoseconds = timestamp.nanoseconds;
                      ~~~~~~~~~^
                               ->
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:22:33: error: no member named 'nanoseconds' in 'CVTimeStamp'
    int nanoseconds = timestamp.nanoseconds;
                      ~~~~~~~~~ ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:26:36: error: use of undeclared identifier 'FIRGeoPoint'
  } else if ([value isKindOfClass:[FIRGeoPoint class]]) {
                                   ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:27:5: error: use of undeclared identifier 'FIRGeoPoint'
    FIRGeoPoint *geoPoint = value;
    ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:27:18: error: use of undeclared identifier 'geoPoint'
    FIRGeoPoint *geoPoint = value;
                 ^
/opt/homebrew/Caskroom/flutter/3.0.5/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.5/ios/Classes/FLTFirebaseFirestoreWriter.m:28:24: error: use of undeclared identifier 'geoPoint'
    Float64 latitude = geoPoint.latitude;
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.

Pointing to latest version of cloud_firestore. Can you try clearing pub cache and then flutter clean and see if it helps ?

bilalsammour commented 2 years ago

@darshankawar Done, same thing!

darshankawar commented 2 years ago

Is it only started to occur after you added this change ? If you remove / comment above change and archive the project, does it throw same error ?

bilalsammour commented 2 years ago

@darshankawar Yes, when removing it, I can do the archiving.

darshankawar commented 2 years ago

I believe you are hitting https://github.com/firebase/flutterfire/issues/9015, so please follow-up in it. You can check if this solution works for you.

bilalsammour commented 2 years ago

@darshankawar It is working after adding:

    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end

But now it takes more time on codemagic , ~5mins extra