Reputation: 12514
I'm trying to install the flutter_blue dependency for bluetooth in flutter, and have realized that in my environment only version 0.6.2 works for android and version ^0.6.3+1 for ios.
Is there a way to declare a dependency or version that is platform-specific?
Upvotes: 6
Views: 2677
Reputation: 41
I'm facing the same issue, and ended up doing the following :
Creating a dedicated pubspec for iOS named pubspec.ios.yaml. You can then put anything specific to iOS here:
...
dependencies:
flutter:
sdk: flutter
flutter_blue: 0.6.3+1
...
Adding a small script in my build pipeline:
# We use a specific pubspec file for iOS
cp pubspec.ios.yaml pubspec.yaml
flutter pub get
Note that "flutter pub get" is required to re-generate pubspec.lock.
It is a bit dirty, but I did not come up with anything cleaner than that.
PS: I'm using Microsoft App Center for CI/CD, so the above was added to appcenter-post-clone.sh script just before the call to flutter build
# We use a specific pubspec file for iOS
cp pubspec.ios.yaml pubspec.yaml
flutter pub get
# The build !
flutter build ios --release --no-codesign -vvv
Upvotes: 4