Skip to content

fix(macos)!: macOS build failures (fixes #4628) #4634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/firebase_messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ jobs:
run: ./.github/workflows/scripts/build-example.sh ios
- name: "Drive iOS Example"
run: ./.github/workflows/scripts/drive-example.sh ios
- name: "Build MacOS Example"
run: ./.github/workflows/scripts/build-example.sh macos
- name: "Drive MacOS Example"
run: ./.github/workflows/scripts/drive-example.sh macos
# TODO(Salakar): Messaging macOS currently requires signing to build.
#- name: "Build MacOS Example"
# run: ./.github/workflows/scripts/build-example.sh macos
#- name: "Drive MacOS Example"
# run: ./.github/workflows/scripts/drive-example.sh macos

web:
runs-on: ubuntu-latest
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/scripts/build-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ fi

if [ "$ACTION" == "macos" ]
then
# TODO Flutter dev branch is currently broken so we're unable to test MacOS.
echo "TODO: Skipping macOS testing due to Flutter dev branch issue."
exit
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
flutter build macos --debug --target="$TARGET_FILE" --dart-define=CI=true
flutter build macos --debug --target="$TARGET_FILE" --device-id=macos --dart-define=CI=true
exit
fi
3 changes: 0 additions & 3 deletions .github/workflows/scripts/drive-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ fi

if [ "$ACTION" == "macos" ]
then
# TODO Flutter dev branch is currently broken so we're unable to test MacOS.
echo "TODO: Skipping macOS testing due to Flutter dev branch issue."
exit
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
flutter drive -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
exit
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/scripts/install-flutter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,5 @@

BRANCH=$1

if [ "$BRANCH" == "dev" ]
then
# TODO Flutter dev branch is currently broken so we're unable to test MacOS.
echo "TODO: Skipping macOS testing due to Flutter dev branch issue. Switching branch to stable."
BRANCH=stable
fi

git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH _flutter
echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH
2 changes: 1 addition & 1 deletion docs/installation/ios.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Once complete follow the instructions on [Initializing FlutterFire](../overview.

## iOS Supported Versions

FlutterFire supports an iOS deployment target of 10 or higher, in line with the requirements of the underlyng [firebase-ios-sdk](https://firebase.google.com/docs/ios/setup)
FlutterFire supports an iOS deployment target of 10 or higher, in line with the requirements of the underlying [firebase-ios-sdk](https://firebase.google.com/docs/ios/setup).
4 changes: 4 additions & 0 deletions docs/installation/macos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ Select the `GoogleService-Info.plist` file you downloaded, and ensure the "Copy
## Initializing FlutterFire

Once complete follow the instructions on [Initializing FlutterFire](../overview.mdx#initializing-flutterfire).

## macOS Supported Versions

FlutterFire supports a macOS deployment target of 10.12 or higher, in line with the requirements of the underlying [firebase-ios-sdk](https://firebase.google.com/docs/ios/setup).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.11'
platform :osx, '10.12'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -501,7 +501,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -548,7 +548,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTDocumentSnapshotStreamHandler.m
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Firebase/Firebase.h>
#import <firebase_core/FLTFirebasePluginRegistry.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTQuerySnapshotStreamHandler.m
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Firebase/Firebase.h>
#import <firebase_core/FLTFirebasePluginRegistry.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTSnapshotsInSyncStreamHandler.m
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Firebase/Firebase.h>
#import <firebase_core/FLTFirebasePluginRegistry.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTTransactionStreamHandler.m
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Firebase/Firebase.h>
#import <firebase_core/FLTFirebasePluginRegistry.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTDocumentSnapshotStreamHandler.h
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTQuerySnapshotStreamHandler.h
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTSnapshotsInSyncStreamHandler.h
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// FLTTransactionStreamHandler.h
// cloud_firestore
//
// Created by Sebastian Roth on 24/11/2020.
//
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require 'yaml'
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))
library_version = pubspec['version'].gsub('+', '-')

firebase_sdk_version = '6.33.0'
if defined?($FirebaseSDKVersion)
Pod::UI.puts "#{pubspec['name']}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
firebase_sdk_version = $FirebaseSDKVersion
Expand All @@ -16,6 +15,24 @@ else
end
end

# TODO(Salakar): Remove deployment target check once default Flutter osx minimum updated to 10.12.
begin
current_target_definition = Pod::Config.instance.podfile.send(:current_target_definition)
user_osx_target = current_target_definition.to_hash["platform"]["osx"]
if user_osx_target == "10.11"
error_message = "The FlutterFire plugin #{pubspec['name']} for macOS requires a macOS deployment target of 10.12 or later."
Pod::UI.warn error_message, [
"Update the `platform :osx, '10.11'` line in your macOS/Podfile to version `10.12` and ensure you commit this file.",
"Open your `macos/Runner.xcodeproj` Xcode project and under the 'Runner' target General tab set your Deployment Target to 10.12 or later."
]
raise Pod::Informative, error_message
end
rescue Pod::Informative
raise
rescue
# Do nothing for all other errors and let `pod install` deal with any issues.
end

Pod::Spec.new do |s|
s.name = pubspec['name']
s.version = library_version
Expand All @@ -30,7 +47,7 @@ Pod::Spec.new do |s|
s.public_header_files = 'Classes/Public/*.h'
s.private_header_files = 'Classes/Private/*.h'

s.platform = :osx, '10.11'
s.platform = :osx, '10.12'

# Flutter dependencies
s.dependency 'FlutterMacOS'
Expand Down
82 changes: 82 additions & 0 deletions packages/cloud_functions/cloud_functions/example/macos/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
platform :osx, '10.12'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end

def pubspec_supports_macos(file)
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return false;
end
File.foreach(file_abs_path) { |line|
return true if line =~ /^\s*macos:/
}
return false
end

target 'Runner' do
use_frameworks!
use_modular_headers!

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
ephemeral_dir = File.join('Flutter', 'ephemeral')
symlink_dir = File.join(ephemeral_dir, '.symlinks')
symlink_plugins_dir = File.join(symlink_dir, 'plugins')
system("rm -rf #{symlink_dir}")
system("mkdir -p #{symlink_plugins_dir}")

# Flutter Pods
generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
if generated_xcconfig.empty?
puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcconfig.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join(symlink_dir, 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
end
}

# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join(symlink_plugins_dir, p[:name])
File.symlink(p[:path], symlink)
if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
pod p[:name], :path => File.join(symlink, 'macos')
end
}
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -502,7 +502,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -549,7 +549,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Loading