Skip to content

Commit 765a794

Browse files
Add macos implementation
1 parent 5d17faf commit 765a794

34 files changed

+1499
-75
lines changed

.metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 63062a64432cce03315d6b5196fda7912866eb37
8+
channel: dev
9+
10+
project_type: plugin

example/macos/.gitignore

+6
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/
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"
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"
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_native_timezone
9+
10+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11+
FlutterNativeTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterNativeTimezonePlugin"))
12+
}

example/macos/Podfile

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
platform :osx, '10.11'
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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- flutter_native_timezone (0.0.1):
3+
- FlutterMacOS
4+
- FlutterMacOS (1.0.0)
5+
6+
DEPENDENCIES:
7+
- flutter_native_timezone (from `Flutter/ephemeral/.symlinks/plugins/flutter_native_timezone/macos`)
8+
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
9+
10+
EXTERNAL SOURCES:
11+
flutter_native_timezone:
12+
:path: Flutter/ephemeral/.symlinks/plugins/flutter_native_timezone/macos
13+
FlutterMacOS:
14+
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
15+
16+
SPEC CHECKSUMS:
17+
flutter_native_timezone: 3a4724189c47dea215bb3e168e555e18308d312c
18+
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
19+
20+
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
21+
22+
COCOAPODS: 1.9.3

0 commit comments

Comments
 (0)