Skip to content

Commit 5277d37

Browse files
committed
add support 'MacOS'
1 parent d47ec41 commit 5277d37

33 files changed

+1450
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ If you like the design of flutter_app_sample, feel flutter_app_sample to help yo
4343
### Render
4444

4545

46+
#### MacOs
47+
48+
|![Login](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_mac_login.gif?raw=true)|![Toolbar...](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_toolbar_page_mac.gif?raw=true)|
49+
|:-|:-|
50+
51+
|![Anim](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_anim_mac.gif?raw=true)|![Drawer](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_drawer_mac.gif?raw=true)|
52+
|:-|:-|
53+
54+
|![Drag](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_drager_mac.gif?raw=true)|![Bottom Navigation](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_navigation_bar_mac.gif?raw=true)|
55+
|:-|:-|
56+
57+
58+
-----
59+
60+
4661
#### Web
4762

4863
|![Login](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_login_web.gif?raw=true)|![Toolbar...](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_toolbar_page_web.gif?raw=true)|

README_CH.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ Flutter项目示例
4141

4242
### 效果图
4343

44+
#### MacOs
45+
46+
|![Login](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_mac_login.gif?raw=true)|![Toolbar...](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_toolbar_page_mac.gif?raw=true)|
47+
|:-|:-|
48+
49+
|![Anim](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_anim_mac.gif?raw=true)|![Drawer](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_drawer_mac.gif?raw=true)|
50+
|:-|:-|
51+
52+
|![Drag](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_drager_mac.gif?raw=true)|![Bottom Navigation](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_navigation_bar_mac.gif?raw=true)|
53+
|:-|:-|
54+
55+
56+
-----
57+
4458
#### Web
4559

4660
|![Login](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_login_web.gif?raw=true)|![Toolbar...](https://github.com/pdliuw/pdliuw.github.io/blob/master/images/flutter_app_sample/flutter_app_sample_toolbar_page_web.gif?raw=true)|

ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ SPEC CHECKSUMS:
1919

2020
PODFILE CHECKSUM: b6a0a141693093b304368d08511b46cf3d1d0ac5
2121

22-
COCOAPODS: 1.7.4
22+
COCOAPODS: 1.8.4

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
import FlutterMacOS
6+
import Foundation
7+
8+
9+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10+
}

macos/Podfile

Lines changed: 82 additions & 0 deletions
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

macos/Podfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- FlutterMacOS (1.0.0)
3+
4+
DEPENDENCIES:
5+
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64-release`)
6+
7+
EXTERNAL SOURCES:
8+
FlutterMacOS:
9+
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64-release
10+
11+
SPEC CHECKSUMS:
12+
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
13+
14+
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
15+
16+
COCOAPODS: 1.8.4

0 commit comments

Comments
 (0)