Skip to content

Commit 7289dd1

Browse files
sallabenLinusU
andauthored
💥 Add macOS support (#20)
Migration guide: This version drops support for Flutter 1.9 and older, please upgrade to Flutter 1.12 for continued support. Co-authored-by: Linus Unnebäck <[email protected]>
1 parent fb84352 commit 7289dd1

36 files changed

+1520
-7
lines changed

example/.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@
2222
**/doc/api/
2323
.dart_tool/
2424
.flutter-plugins
25+
.flutter-plugins-dependencies
2526
.packages
2627
.pub-cache/
2728
.pub/
28-
/build/
29+
build/
30+
flutter_*.png
31+
linked_*.ds
32+
unlinked.ds
33+
unlinked_spec.ds
2934

3035
# Android related
3136
**/android/**/gradle-wrapper.jar

example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- Flutter (1.0.0)
3-
- flutter_web_auth (0.1.2):
3+
- flutter_web_auth (0.1.3):
44
- Flutter
55

66
DEPENDENCIES:
@@ -15,8 +15,8 @@ EXTERNAL SOURCES:
1515

1616
SPEC CHECKSUMS:
1717
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
18-
flutter_web_auth: aa639d59f7a7b099f3e824f33fbd01ca23b86ea5
18+
flutter_web_auth: 852e01fc7fdac9bd99315745ebb9196b84cb8811
1919

2020
PODFILE CHECKSUM: 58760ca3c5878cb71ae11bd6eeff33fd4ce06e4f
2121

22-
COCOAPODS: 1.8.4
22+
COCOAPODS: 1.9.1

example/macos/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Flutter-related
2+
**/Flutter/ephemeral/
3+
**/Pods/
4+
5+
# Xcode-related
6+
**/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 flutter_web_auth
9+
10+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11+
FlutterWebAuthPlugin.register(with: registry.registrar(forPlugin: "FlutterWebAuthPlugin"))
12+
}

example/macos/Podfile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
platform :osx, '10.15'
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 parse_KV_file(file, separator='=')
13+
file_abs_path = File.expand_path(file)
14+
if !File.exists? file_abs_path
15+
return [];
16+
end
17+
pods_ary = []
18+
skip_line_start_symbols = ["#", "/"]
19+
File.foreach(file_abs_path) { |line|
20+
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
21+
plugin = line.split(pattern=separator)
22+
if plugin.length == 2
23+
podname = plugin[0].strip()
24+
path = plugin[1].strip()
25+
podpath = File.expand_path("#{path}", file_abs_path)
26+
pods_ary.push({:name => podname, :path => podpath});
27+
else
28+
puts "Invalid plugin specification: #{line}"
29+
end
30+
}
31+
return pods_ary
32+
end
33+
34+
def pubspec_supports_macos(file)
35+
file_abs_path = File.expand_path(file)
36+
if !File.exists? file_abs_path
37+
return false;
38+
end
39+
File.foreach(file_abs_path) { |line|
40+
return true if line =~ /^\s*macos:/
41+
}
42+
return false
43+
end
44+
45+
target 'Runner' do
46+
use_frameworks!
47+
use_modular_headers!
48+
49+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
50+
# referring to absolute paths on developers' machines.
51+
ephemeral_dir = File.join('Flutter', 'ephemeral')
52+
symlink_dir = File.join(ephemeral_dir, '.symlinks')
53+
symlink_plugins_dir = File.join(symlink_dir, 'plugins')
54+
system("rm -rf #{symlink_dir}")
55+
system("mkdir -p #{symlink_plugins_dir}")
56+
57+
# Flutter Pods
58+
generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
59+
if generated_xcconfig.empty?
60+
puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
61+
end
62+
generated_xcconfig.map { |p|
63+
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
64+
symlink = File.join(symlink_dir, 'flutter')
65+
File.symlink(File.dirname(p[:path]), symlink)
66+
pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
67+
end
68+
}
69+
70+
# Plugin Pods
71+
plugin_pods = parse_KV_file('../.flutter-plugins')
72+
plugin_pods.map { |p|
73+
symlink = File.join(symlink_plugins_dir, p[:name])
74+
File.symlink(p[:path], symlink)
75+
if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
76+
pod p[:name], :path => File.join(symlink, 'macos')
77+
end
78+
}
79+
end
80+
81+
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82+
install! 'cocoapods', :disable_input_output_paths => true

example/macos/Podfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- flutter_web_auth (0.1.3):
3+
- FlutterMacOS
4+
- FlutterMacOS (1.0.0)
5+
6+
DEPENDENCIES:
7+
- flutter_web_auth (from `Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos`)
8+
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
9+
10+
EXTERNAL SOURCES:
11+
flutter_web_auth:
12+
:path: Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos
13+
FlutterMacOS:
14+
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
15+
16+
SPEC CHECKSUMS:
17+
flutter_web_auth: ef70cda7897ae8d627194e9291f9d2888007dda9
18+
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
19+
20+
PODFILE CHECKSUM: 882fce9150893cd66c23bbd28a572b3439b8ac6d
21+
22+
COCOAPODS: 1.9.1

0 commit comments

Comments
 (0)