Skip to content

Commit

Permalink
Improve support for running xaif on macOS (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0nac0 authored Dec 30, 2021
1 parent 45e9a6a commit ce1f822
Show file tree
Hide file tree
Showing 31 changed files with 1,300 additions and 13 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down Expand Up @@ -68,10 +67,25 @@ jobs:
with:
name: linux_build
path: build/linux/x64/release/bundle


build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/[email protected]
- run: flutter config --enable-macos-desktop
# - run: flutter create . --project-name=xaif --platforms=macos
- name: flutter build macos --release
run: flutter build macos --release
- run: cp LICENSE build/macos/Build/Products/Release
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: macos_build
path: build/macos/Build/Products/Release

build-web:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: subosito/[email protected]
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,24 @@ on macOS, but this hasn't been tested, yet.
1. **Run the source code directly:**
1. Either clone this repository with git or download it as a zip-file from GitHub (green button titled "Code")
and unzip it to any location.<br>
2. Then open a shell in the location where you cloned/unzipped the repository and run `flutter run -d windows` (if
your computer is running Windows) or `flutter run -d linux` (if your computer is running Linux).<br>
(This first approach will require you to have followed the *additional* setup steps for your computer's operating
system in the Flutter installation guide. So if you want to run xaif on Windows with this approach, you need to
*also* follow the ["Windows setup" step](https://docs.flutter.dev/get-started/install/windows#windows-setup) in
the Flutter Windows installation guide, or
2. Then open a shell in the location where you cloned/unzipped the repository and run <br>`flutter run -d windows` (if
your computer is running Windows) <br>or `flutter run -d linux` (if your computer is running Linux)<br> or
`flutter run -d macos` (if your computer is running macOS).<br>
(This first approach will require you to have followed not only the "Basic Flutter setup", but also the *additional* setup steps for your computer's operating
system in the Flutter installation guide. So if you want to run xaif with this approach, you need to
*also* follow the <br>["Windows setup" step](https://docs.flutter.dev/get-started/install/windows#windows-setup) in
the Flutter Windows installation guide if your computer is running Windows,<br> or
the ["Linux setup" step](https://docs.flutter.dev/get-started/install/linux#linux-setup) in the Flutter Linux
installation guide if you want to run xaif on Linux with this approach.)
<br><br>
installation guide if your computer is running Linux, <br>
or the ["macOS setup" step](https://docs.flutter.dev/get-started/install/macos#macos-setup) in the Flutter Linux
installation guide if your computer is running macOS.)
<br><br>
2. **Run prebuilt executables:** <br>
Alternatively, you can download and run prebuilt binaries of xaif from the CI. They are available from
the [releases page](https://github.com/m0nac0/xaif/releases) (as Assets) or
from [any successful CI Workflow run](https://github.com/m0nac0/xaif/actions/workflows/main.yml?query=branch%3Amain)
(as artifacts). <br>
You can use these prebuilt executables to run xaif without completing the "Windows setup" or "Linux setup" step in
the Flutter setup, but you still have to complete the basic Flutter setup!
For this approach you only need to complete the basic Flutter installation!
<br><br>
3. **Very limited: run xaif as web app from source:** <br>
*This approach has serious limitations, and it is recommended that you use one of first other two approaches, if
Expand Down
12 changes: 12 additions & 0 deletions lib/gui/aia_compiler_widget_desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class _AIAAccepterState extends State<AIAAccepter> {
BuildTarget.web,
if (Platform.isWindows) BuildTarget.windows,
if (Platform.isLinux) BuildTarget.linux,
if (Platform.isMacOS) BuildTarget.macos,
if (Platform.isMacOS) BuildTarget.iosSimulator,
];

// The directory selected by the user to create the project directory in
Expand Down Expand Up @@ -679,4 +681,14 @@ class BuildTarget {
"linux",
"build/linux/x64/release/bundle",
);
static const macos = BuildTarget._(
"macos",
"macos",
"build/macos/Build/Products/Release",
);
static const iosSimulator = BuildTarget._(
"ios --simulator",
"ios --simulator",
"build/ios/iphonesimulator",
);
}
7 changes: 7 additions & 0 deletions macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/

# Xcode-related
**/dgph
**/xcuserdata/
2 changes: 2 additions & 0 deletions 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 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 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 url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
40 changes: 40 additions & 0 deletions 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
Loading

0 comments on commit ce1f822

Please sign in to comment.