Skip to content

Commit 2df97d9

Browse files
authored
Merge pull request #632 from Baseflow/ci/desktop
Add desktop platforms to CI
2 parents bcc1104 + 8345abe commit 2df97d9

File tree

3 files changed

+143
-74
lines changed

3 files changed

+143
-74
lines changed

.github/workflows/app_facing_package.yaml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,120 @@ jobs:
137137
run: flutter build ios --release --no-codesign
138138
working-directory: ${{env.example-directory}}
139139

140+
build_macOS:
141+
name: Build macOS App
142+
143+
# The type of runner that the job will run on
144+
runs-on: macos-latest
145+
146+
env:
147+
source-directory: ./cached_network_image
148+
example-directory: ./cached_network_image/example
149+
150+
# Steps represent a sequence of tasks that will be executed as part of the job
151+
steps:
152+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
153+
- uses: actions/checkout@v2
154+
155+
# Make sure the stable version of Flutter is available
156+
- uses: subosito/flutter-action@v1
157+
with:
158+
channel: 'stable'
159+
160+
# Enable platform support
161+
- name: Enable macOS
162+
run: flutter config --enable-macos-desktop
163+
working-directory: ${{env.source-directory}}
164+
165+
# Download all Flutter packages
166+
- name: Download dependencies
167+
run: flutter pub get
168+
working-directory: ${{env.source-directory}}
169+
170+
# Build macOS version of the example App
171+
- name: Run macOS build
172+
run: flutter build macos --release
173+
working-directory: ${{env.example-directory}}
174+
175+
build_windows:
176+
name: Build Windows App
177+
178+
# The type of runner that the job will run on
179+
runs-on: windows-latest
180+
181+
env:
182+
source-directory: ./cached_network_image
183+
example-directory: ./cached_network_image/example
184+
185+
# Steps represent a sequence of tasks that will be executed as part of the job
186+
steps:
187+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
188+
- uses: actions/checkout@v2
189+
190+
# Make sure the stable version of Flutter is available
191+
- uses: subosito/flutter-action@v1
192+
with:
193+
channel: 'stable'
194+
195+
# Enable platform support
196+
- name: Enable Windows
197+
run: flutter config --enable-windows-desktop
198+
working-directory: ${{env.source-directory}}
199+
200+
# Download all Flutter packages
201+
- name: Download dependencies
202+
run: flutter pub get
203+
working-directory: ${{env.source-directory}}
204+
205+
# Build iOS version of the example App
206+
- name: Run Windows build
207+
run: flutter build windows --release
208+
working-directory: ${{env.example-directory}}
209+
210+
build_linux:
211+
name: Build Linux App
212+
213+
# The type of runner that the job will run on
214+
runs-on: ubuntu-latest
215+
216+
env:
217+
source-directory: ./cached_network_image
218+
example-directory: ./cached_network_image/example
219+
220+
# Steps represent a sequence of tasks that will be executed as part of the job
221+
steps:
222+
# Install libraries for Linux
223+
- run: sudo apt-get update -y
224+
- run: sudo apt-get install -y ninja-build libgtk-3-dev libblkid-dev
225+
226+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
227+
- uses: actions/checkout@v2
228+
229+
# Make sure the stable version of Flutter is available
230+
- uses: subosito/flutter-action@v1
231+
with:
232+
channel: 'stable'
233+
234+
# Enable platform support
235+
- name: Enable Linux
236+
run: flutter config --enable-linux-desktop
237+
working-directory: ${{env.source-directory}}
238+
239+
# Enable platform support
240+
- name: Flutter Doctor
241+
run: flutter doctor
242+
working-directory: ${{env.source-directory}}
243+
244+
# Download all Flutter packages
245+
- name: Download dependencies
246+
run: flutter pub get
247+
working-directory: ${{env.source-directory}}
248+
249+
# Build iOS version of the example App
250+
- name: Run Linux build
251+
run: flutter build linux --release
252+
working-directory: ${{env.example-directory}}
253+
140254
build_web:
141255
name: Build Web App
142256

cached_network_image/example/macos/Podfile

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,32 @@ project 'Runner', {
99
'Release' => :release,
1010
}
1111

12-
def parse_KV_file(file, separator='=')
13-
file_abs_path = File.expand_path(file)
14-
if !File.exists? file_abs_path
15-
return [];
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"
1616
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
3317

34-
def pubspec_supports_macos(file)
35-
file_abs_path = File.expand_path(file)
36-
if !File.exists? file_abs_path
37-
return false;
18+
File.foreach(generated_xcode_build_settings_path) do |line|
19+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
20+
return matches[1].strip if matches
3821
end
39-
File.foreach(file_abs_path) { |line|
40-
return true if line =~ /^\s*macos:/
41-
}
42-
return false
22+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
4323
end
4424

25+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26+
27+
flutter_macos_podfile_setup
28+
4529
target 'Runner' do
4630
use_frameworks!
4731
use_modular_headers!
4832

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}")
33+
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34+
end
5635

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."
36+
post_install do |installer|
37+
installer.pods_project.targets.each do |target|
38+
flutter_additional_macos_build_settings(target)
6139
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-
}
7940
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

cached_network_image/example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
2727
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
2828
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
29-
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
30-
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
31-
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
32-
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3329
E2F74D8A72EDDA51E695C935 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFF7FDF53FF1147E5CEABAC /* Pods_Runner.framework */; };
3430
/* End PBXBuildFile section */
3531

@@ -50,8 +46,6 @@
5046
dstPath = "";
5147
dstSubfolderSpec = 10;
5248
files = (
53-
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
54-
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
5549
);
5650
name = "Bundle Framework";
5751
runOnlyForDeploymentPostprocessing = 0;
@@ -72,24 +66,20 @@
7266
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
7367
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
7468
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
75-
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
7669
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
7770
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
7871
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
7972
5AF2E0002DE8BBB12EFD7086 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
8073
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
8174
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
8275
A0182A60EEDD107D6E0FA1B6 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
83-
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
8476
/* End PBXFileReference section */
8577

8678
/* Begin PBXFrameworksBuildPhase section */
8779
33CC10EA2044A3C60003C045 /* Frameworks */ = {
8880
isa = PBXFrameworksBuildPhase;
8981
buildActionMask = 2147483647;
9082
files = (
91-
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
92-
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
9383
E2F74D8A72EDDA51E695C935 /* Pods_Runner.framework in Frameworks */,
9484
);
9585
runOnlyForDeploymentPostprocessing = 0;
@@ -156,8 +146,6 @@
156146
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
157147
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
158148
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
159-
D73912EF22F37F9E000D13A0 /* App.framework */,
160-
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
161149
);
162150
path = Flutter;
163151
sourceTree = "<group>";
@@ -281,7 +269,7 @@
281269
);
282270
runOnlyForDeploymentPostprocessing = 0;
283271
shellPath = /bin/sh;
284-
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
272+
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
285273
};
286274
33CC111E2044C6BF0003C045 /* ShellScript */ = {
287275
isa = PBXShellScriptBuildPhase;
@@ -330,10 +318,19 @@
330318
buildActionMask = 2147483647;
331319
files = (
332320
);
333-
inputFileListPaths = (
321+
inputPaths = (
322+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
323+
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
324+
"${BUILT_PRODUCTS_DIR}/path_provider_macos/path_provider_macos.framework",
325+
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
326+
"${BUILT_PRODUCTS_DIR}/url_launcher_macos/url_launcher_macos.framework",
334327
);
335328
name = "[CP] Embed Pods Frameworks";
336-
outputFileListPaths = (
329+
outputPaths = (
330+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
331+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_macos.framework",
332+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
333+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_macos.framework",
337334
);
338335
runOnlyForDeploymentPostprocessing = 0;
339336
shellPath = /bin/sh;

0 commit comments

Comments
 (0)