Skip to content

Commit 1ebefca

Browse files
Implement macos using shared darwin source (#889)
* Implement MacOS support using sharedDarwinSource * Update protobuf docs * Fix compilation and warnings --------- Co-authored-by: Rohit Sangwan <[email protected]>
1 parent a6dd926 commit 1ebefca

File tree

83 files changed

+1663
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1663
-73
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ In case you are using ProGuard add the following snippet to your `proguard-rules
6767

6868
This will prevent issues like [#131](https://github.com/PhilipsHue/flutter_reactive_ble/issues/131).
6969

70-
### iOS
70+
### iOS / MacOS
7171

72-
For iOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
72+
For iOS/MacOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
7373

7474
iOS13 and higher
7575
* NSBluetoothAlwaysUsageDescription
7676

7777
iOS12 and lower
7878
* NSBluetoothPeripheralUsageDescription
7979

80+
For MacOS, make sure to enable Bluetooth from Capabilities
81+
8082
## Usage
8183
### Initialization
8284

example/lib/src/ui/device_detail/characteristic_interaction_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class _CharacteristicInteractionDialogState extends State<_CharacteristicInterac
3535
late String writeOutput;
3636
late String subscribeOutput;
3737
late TextEditingController textEditingController;
38-
late StreamSubscription<List<int>>? subscribeStream;
38+
StreamSubscription<List<int>>? subscribeStream;
3939

4040
@override
4141
void initState() {

example/lib/src/ui/device_detail/device_interaction_tab.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ class _DeviceInteractionTabState extends State<_DeviceInteractionTab> {
155155
child: const Text("Discover Services"),
156156
),
157157
ElevatedButton(
158-
onPressed: widget.viewModel.deviceConnected
159-
? readRssi
160-
: null,
158+
onPressed: widget.viewModel.deviceConnected ? readRssi : null,
161159
child: const Text("Get RSSI"),
162160
),
163161
],
@@ -285,7 +283,7 @@ class _ServiceDiscoveryListState extends State<_ServiceDiscoveryList> {
285283
child: ExpansionPanelList(
286284
expansionCallback: (int index, bool isExpanded) {
287285
setState(() {
288-
if (isExpanded) {
286+
if (!isExpanded) {
289287
_expandedItems.remove(index);
290288
} else {
291289
_expandedItems.add(index);

example/macos/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Flutter-related
2+
**/Flutter/ephemeral/
3+
**/Pods/
4+
5+
# Xcode-related
6+
**/dgph
7+
**/xcuserdata/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2+
#include "ephemeral/Flutter-Generated.xcconfig"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2+
#include "ephemeral/Flutter-Generated.xcconfig"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
import FlutterMacOS
6+
import Foundation
7+
8+
import reactive_ble_mobile
9+
10+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11+
ReactiveBlePlugin.register(with: registry.registrar(forPlugin: "ReactiveBlePlugin"))
12+
}

example/macos/Podfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
platform :osx, '10.14'
2+
3+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5+
6+
project 'Runner', {
7+
'Debug' => :debug,
8+
'Profile' => :release,
9+
'Release' => :release,
10+
}
11+
12+
def flutter_root
13+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14+
unless File.exist?(generated_xcode_build_settings_path)
15+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16+
end
17+
18+
File.foreach(generated_xcode_build_settings_path) do |line|
19+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
20+
return matches[1].strip if matches
21+
end
22+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23+
end
24+
25+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26+
27+
flutter_macos_podfile_setup
28+
29+
target 'Runner' do
30+
use_frameworks!
31+
use_modular_headers!
32+
33+
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34+
target 'RunnerTests' do
35+
inherit! :search_paths
36+
end
37+
end
38+
39+
post_install do |installer|
40+
installer.pods_project.targets.each do |target|
41+
flutter_additional_macos_build_settings(target)
42+
end
43+
end

example/macos/Podfile.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
PODS:
2+
- FlutterMacOS (1.0.0)
3+
- Protobuf (3.24.3)
4+
- reactive_ble_mobile (0.0.1):
5+
- Flutter
6+
- FlutterMacOS
7+
- Protobuf (~> 3.5)
8+
- SwiftProtobuf (~> 1.0)
9+
- SwiftProtobuf (1.23.0)
10+
11+
DEPENDENCIES:
12+
- FlutterMacOS (from `Flutter/ephemeral`)
13+
- reactive_ble_mobile (from `Flutter/ephemeral/.symlinks/plugins/reactive_ble_mobile/darwin`)
14+
15+
SPEC REPOS:
16+
trunk:
17+
- Protobuf
18+
- SwiftProtobuf
19+
20+
EXTERNAL SOURCES:
21+
FlutterMacOS:
22+
:path: Flutter/ephemeral
23+
reactive_ble_mobile:
24+
:path: Flutter/ephemeral/.symlinks/plugins/reactive_ble_mobile/darwin
25+
26+
SPEC CHECKSUMS:
27+
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
28+
Protobuf: 970f7ee93a3a08e3cf64859b8efd95ee32b4f87f
29+
reactive_ble_mobile: 856183aeda09f2a676bbaecbea8915c3cb1d33df
30+
SwiftProtobuf: b70d65f419fbfe61a2d58003456ca5da58e337d6
31+
32+
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
33+
34+
COCOAPODS: 1.15.2

0 commit comments

Comments
 (0)