Skip to content
This repository was archived by the owner on Feb 11, 2024. It is now read-only.

flutter macos support #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.7

* Added support for Flutter Desktop - MacOS.

## 0.0.6

* Added data upload feature for `POST`, `PUT` and similar requests.
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Currently, Android and Desktop Platforms (Linux, Windows and MacOS) are supporte

We need to use `flutter pub` even if we want to use it with Dart CLI. See <https://github.com/dart-lang/pub/issues/2606> for further details.

***Note for Android:** Remember to Add the following permissions in `AndroidManifest.xml` file.
**Note for Android:** Remember to Add the following permissions in `AndroidManifest.xml` file.

```xml
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -37,6 +37,15 @@ Currently, Android and Desktop Platforms (Linux, Windows and MacOS) are supporte

Optionally, enable cleartext traffic by adding `android:usesCleartextTraffic="true"` to `AndroidManifest.xml` file.

***Note for MacOS (Flutter):** Remember to add the following lines to `macos/Runner/Release.entitlements` and `macos/Runner/DebugProfile.entitlements` to enable networking in MacOS (Flutter).
Copy link
Member

Choose a reason for hiding this comment

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

*** -> **


```xml
<key>com.apple.security.network.client</key>
<true/>
```

_There is no need to do these for creating a Dart CLI application._

3. Import

```dart
Expand Down
1 change: 1 addition & 0 deletions bin/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void buildWrapper() {
print(result.stderr);
} catch (error) {
Directory.current = pwd;
logger.stdout(error.toString());
logger.stdout("${ansi.red}Build failed.${ansi.none}");
if (Platform.isWindows) {
logger.stdout(
Expand Down
6 changes: 6 additions & 0 deletions example/flutter/macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/

# Xcode-related
**/xcuserdata/
2 changes: 2 additions & 0 deletions example/flutter/macos/Flutter/Flutter-Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
2 changes: 2 additions & 0 deletions example/flutter/macos/Flutter/Flutter-Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
12 changes: 12 additions & 0 deletions example/flutter/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Generated file. Do not edit.
//

import FlutterMacOS
import Foundation

import cronet

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
CronetPlugin.register(with: registry.registrar(forPlugin: "CronetPlugin"))
}
40 changes: 40 additions & 0 deletions example/flutter/macos/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
platform :osx, '10.11'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
22 changes: 22 additions & 0 deletions example/flutter/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PODS:
- cronet (0.0.6):
- FlutterMacOS
- FlutterMacOS (1.0.0)

DEPENDENCIES:
- cronet (from `Flutter/ephemeral/.symlinks/plugins/cronet/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)

EXTERNAL SOURCES:
cronet:
:path: Flutter/ephemeral/.symlinks/plugins/cronet/macos
FlutterMacOS:
:path: Flutter/ephemeral

SPEC CHECKSUMS:
cronet: 2c609b33a988deeb54c7c60aae3cd5e0087b95ae
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

COCOAPODS: 1.10.2
Loading