plugin dependency only for specific platform?

47 views
Skip to first unread message

Thomas Verbeek

unread,
Oct 15, 2019, 6:22:00 AM10/15/19
to Flutter Development (flutter-dev)
Hey,

is it possible to include a dependency only for a sepcific platform?

I am developing a cross-plattform app fro macOS and iOS and are using the shared_preferences plugin. in pubspec.yaml I added this:

  shared_preferences: ^0.5.3+4
  shared_preferences_fde:
    path: ../../flutter-desktop-embedding/plugins/flutter_plugins/shared_preferences_fde


Building for macOS works, but I have to comment out the line starting with shared_preferences_fde for iOS builds - otherwise it fails.

Thx,

Tom.


Stuart Morgan

unread,
Oct 15, 2019, 2:56:21 PM10/15/19
to Thomas Verbeek, Flutter Development (flutter-dev)
There isn't a way to make a plugin a dependency only on one platform. The issue you are hitting is https://github.com/flutter/flutter/issues/39659, and the solution will be to make dependencies on non-iOS plugin a no-op on iOS rather than failing to build.

In the meantime, feel free to submit a PR to flutter-desktop-embedding to add a dummy iOS podspec to that plugin, which is the current workaround; see https://github.com/google/flutter-desktop-embedding/tree/master/plugins/flutter_plugins/url_launcher_fde/ios for an example.

-Stuart

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/7B96BB4F-8A6A-4CD3-BBDE-5A26A506AEA5%40skalio.com.
Reply all
Reply to author
Forward
0 new messages