Skip to content

[cloud_firestore] Add macOS support #1706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 19, 2020

Conversation

cbenhagen
Copy link
Contributor

@cbenhagen cbenhagen commented Dec 23, 2019

Description

Add macOS support.

Related Issues

#1653

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • If the pull request affects only one plugin, the PR title starts with the name of the plugin in brackets (e.g. [cloud_firestore])
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@ditman
Copy link
Contributor

ditman commented Dec 23, 2019

There's a big refactor of this package in here to add web support, where the core plugin is being federated (there's a new platform interface and a whatever changes were needed to the core).

Do you mind trying to integrate the PR above with your code and see if it's still working as expected?

Thanks!

@cbenhagen
Copy link
Contributor Author

I am aware of that PR but I don't expect it to break anything as this is just a copy of the ios implementation. I am happy to rebase and copy all changes once that PR is merged.

@ditman
Copy link
Contributor

ditman commented Dec 23, 2019

I am aware of that PR but I don't expect it to break anything as this is just a copy of the ios implementation. I am happy to rebase and copy all changes once that PR is merged.

@cbenhagen cool! I'm not setup to do macos PRs (can't run tests yet), but you tagged the right people here!

@edeuss
Copy link

edeuss commented Dec 24, 2019

@cbenhagen Yes! Thank you for working on this.

@franciscojma86 franciscojma86 added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jan 29, 2020
@phest
Copy link

phest commented Feb 4, 2020

I've attempted to add this to the example in the Firebase for Flutter codelab by adding this to the pubspec file:

dependency_overrides:
  cloud_firestore:
    git:
      url: https://github.com/cbenhagen/flutterfire
      ref: cloud_firestore_macos
      path: packages/cloud_firestore/cloud_firestore

It now seems to correctly grab the required pods when building for mac, but at runtime I'm getting this exception:

Launching lib/main.dart on macOS in debug mode...
2020-02-03 23:12:17.852 firebasetest[66424:623933] Configuring the default Firebase app...
2020-02-03 23:12:17.857 firebasetest[66424:623933] Configured the default Firebase app __FIRAPP_DEFAULT.
2020-02-03 23:12:19.063 firebasetest[66424:623933] Error: Message responses can be sent only once. Ignoring duplicate response on channel 'plugins.flutter.io/cloud_firestore'.
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(invalid_query, FIRInvalidArgumentException, FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd like to use the default FirebaseApp instance.)
#0      StandardMethodCodec.decodeEnvelope 
package:flutter/…/services/message_codecs.dart:569
#1      MethodChannel._invokeMethod 
package:flutter/…/services/platform_channel.dart:156
<asynchronous suspension>
#2      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:329
#3      Query.snapshots.<anonymous closure> 
package:cloud_firestore/src/query.dart:61
#4      _runGuarded  (dart:async/stream_controller.dart:814:24)
#5      _BroadcastStreamController._subscribe  (dart:async/broadcast_stream_controller.dart:215:7)
#6      _ControllerStream._createSubscription  (dart:async/stream_controller.dart:827:19)
#7      _StreamImpl.listen  (dart:async/stream_impl.dart:475:9)
#8      _StreamBuilderBaseState._subscribe 
package:flutter/…/widgets/async.dart:135
#9      _StreamBuilderBaseState.initState 
package:flutter/…/widgets/async.dart:1
...

I've added the same Googleservice-Info.plist used in the ios folder, as well as the same bundle ID.

Any idea what the issue may be? Does running firestore on mac require any other changes, perhaps platform specific dart code?

@cbenhagen
Copy link
Contributor Author

@phest You would also need to add overrides for firebase_core and maybe firebase_auth.

@cbenhagen cbenhagen force-pushed the cloud_firestore_macos branch from 26d2f4d to a4cf81b Compare February 12, 2020 18:04
Copy link
Contributor

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone with experience in Obj-C (@collinjackson? (ah, I see @franciscojma86 now!)) should review this! Very cool!

PS: would it make sense to split this into a cloud_firestore_darwin package that contains the ios and macos platforms, instead of adding more stuff to the "core" plugin?

Copy link
Contributor

@franciscojma86 franciscojma86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo @ditman comments

@phest
Copy link

phest commented Feb 12, 2020

dependency_overrides:
  firebase_core:
    git:
      url: https://github.com/cbenhagen/flutterfire
      ref: firebase_core_macos
      path: packages/firebase_core/firebase_core
  cloud_firestore:
    git:
      url: https://github.com/cbenhagen/flutterfire
      ref: cloud_firestore_macos
      path: packages/cloud_firestore/cloud_firestore

@cbenhagen thank you. Did you mean like so ☝️? I'm seeing the compiler error below. Tried re-creating the XCode project from scratch but no luck.

[   +4 ms] In file included from
(sdk path)/flutter/.pub-cache/git/flutterfire-4cd588bb535e2a2146c3c4d3290f1c297fd0c0ea/packages/firebase_core/firebase_core/darw
in/Classes/FLTFirebaseCorePlugin.m:5:
[        ]
(sdk path)/flutter/.pub-cache/git/flutterfire-4cd588bb535e2a2146c3c4d3290f1c297fd0c0ea/packages/firebase_core/firebase_core/darw
in/Classes/FLTFirebaseCorePlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
[        ] #import <Flutter/Flutter.h>
[        ]         ^~~~~~~~~~~~~~~~~~~
[        ] 1 error generated.
[   +5 ms] ** BUILD FAILED **
[   +1 ms] The following build commands failed:
[        ] 	CompileC
(project path)/build/macos/Build/Intermediates.noindex/Pods.build/Debug/firebase_core.build/Objects-normal/x
86_64/FLTFirebaseCorePlugin.o
[sdk path]/flutter/.pub-cache/git/flutterfire-4cd588bb535e2a2146c3c4d3290f1c297fd0c0ea/packages/firebase_core/firebase_core/darw
in/Classes/FLTFirebaseCorePlugin.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
[        ] (1 failure)
[  +37 ms] Building macOS application... (completed in 3.4s)
[   +4 ms] "flutter run" took 6,783ms.
Build process failed

@cbenhagen
Copy link
Contributor Author

@phest yes that was what I meant but it seems I messed something up.

@ditman there is no darwin entrypoint. We symlink files from that directory to share them between iOS and macOS.

@cbenhagen
Copy link
Contributor Author

@phest I removed that header file. Please update and retry.

@cbenhagen
Copy link
Contributor Author

cbenhagen commented Feb 12, 2020

@phest you don't have to try. It doesn't work currently. If you need a solution today, copy the files in darwin to the macos directory for both plugins instead of symlinking.

@collinjackson / @franciscojma86 the compiler does not like when I remove the header file from the darwin directory. It seems to look in that dir for the header instead of where the .m is linked to. Ideas?

@collinjackson
Copy link
Contributor

collinjackson commented Feb 12, 2020

@phest you don't have to try. It doesn't work currently. @collinjackson / @franciscojma86 the compiler does not like when I remove the header file from the darwin directory. It seems to look in that dir for the header instead of where the .m is linked to. Ideas?

I am investigating. (edit: waiting to see if the tests pass)

@franciscojma86
Copy link
Contributor

@cbenhagen I just noticed that you also need to add a macos directory to the example app to run the macos integration tests. I'm going to try and add that myself and send you a patch. Sorry about that

@cbenhagen
Copy link
Contributor Author

@franciscojma86 you can just commit to my branch as well.

@ditman
Copy link
Contributor

ditman commented Feb 13, 2020

(Restarted all failing checks)

@cbenhagen
Copy link
Contributor Author

@ditman please restart again. Looks like there was a network issue.

@ditman
Copy link
Contributor

ditman commented Feb 14, 2020

Yep, they all look like network connectivity issues, restarted.

@edeuss
Copy link

edeuss commented Feb 15, 2020

Looks like all checks have passed @ditman . Thanks for working on this @cbenhagen !

@collinjackson collinjackson self-requested a review February 17, 2020 01:30
@cbenhagen cbenhagen requested a review from ditman February 17, 2020 07:55
@cbenhagen
Copy link
Contributor Author

@franciscojma86 this one should be ready to merge and release as well :)

@franciscojma86
Copy link
Contributor

Sorry just saw this one :). I resolved the conflicts, once tests pass again I'll land it. Thanks!

@franciscojma86 franciscojma86 merged commit 0b13c92 into firebase:master Feb 19, 2020
@cbenhagen cbenhagen deleted the cloud_firestore_macos branch February 19, 2020 19:06
@firebase firebase locked and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants