From 1f79430e1c73a19adb9bab5e0a31c6da1b738221 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 26 Sep 2019 10:41:47 -0700 Subject: [PATCH 1/4] WIP [camera] Define clang modules in for iOS --- .cirrus.yml | 2 + packages/camera/CHANGELOG.md | 4 + packages/camera/ios/Tests/CameraPluginTests.m | 16 ++++ packages/camera/ios/camera.podspec | 9 +- packages/camera/pubspec.yaml | 2 +- script/lint_darwin_plugins.sh | 88 +++++++++++++++++++ 6 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 packages/camera/ios/Tests/CameraPluginTests.m create mode 100755 script/lint_darwin_plugins.sh diff --git a/.cirrus.yml b/.cirrus.yml index 02c7551b3500..0caa1a226807 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -64,6 +64,8 @@ task: matrix: - name: build_all_plugins_ipa script: ./script/build_all_plugins_app.sh ios --no-codesign + - name: lint_darwin_plugins + script: ./script/lint_darwin_plugins.sh - name: build-ipas+drive-examples env: PATH: $PATH:/usr/local/bin diff --git a/packages/camera/CHANGELOG.md b/packages/camera/CHANGELOG.md index b6c68aa7cf9f..c32ef103ae1c 100644 --- a/packages/camera/CHANGELOG.md +++ b/packages/camera/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.5 + +* Define clang modules for iOS. + ## 0.5.4+3 * Update and migrate iOS example project. diff --git a/packages/camera/ios/Tests/CameraPluginTests.m b/packages/camera/ios/Tests/CameraPluginTests.m new file mode 100644 index 000000000000..e5be3980bad0 --- /dev/null +++ b/packages/camera/ios/Tests/CameraPluginTests.m @@ -0,0 +1,16 @@ +@import camera; +@import XCTest; + +@interface CameraPluginTests : XCTestCase +@end + +@implementation CameraPluginTests + +- (void)testModuleImport { + // This test will fail to compile if the module cannot be imported. + // Make sure this plugin supports modules. See https://github.com/flutter/flutter/issues/41007. + // If not already present, add this line to the podspec: + // s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } +} + +@end diff --git a/packages/camera/ios/camera.podspec b/packages/camera/ios/camera.podspec index 0db7485005ed..dfe566ca79cc 100644 --- a/packages/camera/ios/camera.podspec +++ b/packages/camera/ios/camera.podspec @@ -15,7 +15,10 @@ A new flutter plugin project. s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - - s.ios.deployment_target = '8.0' -end + s.platform = :ios, '8.0' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'armv7 arm64 x86_64' } + s.test_spec 'Tests' do |test_spec| + test_spec.source_files = 'Tests/**/*' + end +end diff --git a/packages/camera/pubspec.yaml b/packages/camera/pubspec.yaml index 9640da5ff166..9ed9b55203f0 100644 --- a/packages/camera/pubspec.yaml +++ b/packages/camera/pubspec.yaml @@ -2,7 +2,7 @@ name: camera description: A Flutter plugin for getting information about and controlling the camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video, and streaming image buffers to dart. -version: 0.5.4+3 +version: 0.5.5 authors: - Flutter Team diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh new file mode 100755 index 000000000000..c9839e79cfbf --- /dev/null +++ b/script/lint_darwin_plugins.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +# This script lints and tests iOS and macOS platform code. + +# So that users can run this script from anywhere and it will work as expected. +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +REPO_DIR="$(dirname "$SCRIPT_DIR")" + +source "$SCRIPT_DIR/common.sh" + +function lint_package() { + local package_name=$1 + local platform=$2 + local podspec_dir="$REPO_DIR/packages/$package_name/$platform/$package_name.podspec" + local failure_count=0 + + if [[ -f "$podspec_dir" ]]; then + echo "Linting $platform $package_name.podspec" + + # Build as frameworks. + # This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0. + pod lib lint "$podspec_dir" --allow-warnings --fail-fast --silent + if [[ $? -ne 0 ]]; then + error "Package $package_name has framework issues. Run \"pod lib lint $podspec_dir\" to inspect." + failure_count+=1 + fi + + # Build as libraries. + pod lib lint "$podspec_dir" --allow-warnings --use-libraries --fail-fast --silent + if [[ $? -ne 0 ]]; then + error "Package $package_name has library issues. Run \"pod lib lint $podspec_dir --use-libraries\" to inspect." + failure_count+=1 + fi + fi + + return $failure_count +} + +function lint_packages() { + if [[ ! $(which pod) ]]; then + echo "pod not installed. Skipping." + return + fi + + # TODO: These packages have linter errors. Remove plugins from this list as linter issues are fixed. + local skipped_packages=( + android_alarm_manager + android_intent + battery + connectivity + device_info + google_maps_flutter + google_sign_in + image_picker + in_app_purchase + instrumentation_adapter + local_auth + package_info + path_provider + quick_actions + sensors + share + shared_preferences + url_launcher + video_player + webview_flutter + ) + + local failure_count=0 + for package_name in "$@"; do + if [[ ${skipped_packages[*]} =~ $package_name ]]; then + continue + fi + lint_package $package_name "ios" + failure_count+=$? + lint_package $package_name "macos" + failure_count+=$? + done + + return $failure_count +} + +# Sets CHANGED_PACKAGE_LIST +check_changed_packages + +if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then + lint_packages "${CHANGED_PACKAGE_LIST[@]}" +fi From f14c55194ec130c1d282b40d35f620418ca78b96 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 26 Sep 2019 20:32:54 -0700 Subject: [PATCH 2/4] readonly, rename podspec_dir, add flag TODOs --- script/build_all_plugins_app.sh | 4 ++-- script/check_publish.sh | 4 ++-- script/incremental_build.sh | 4 ++-- script/lint_darwin_plugins.sh | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/script/build_all_plugins_app.sh b/script/build_all_plugins_app.sh index dcf3bcdfd2a3..6b70ee00e9b1 100755 --- a/script/build_all_plugins_app.sh +++ b/script/build_all_plugins_app.sh @@ -4,8 +4,8 @@ # sure all first party plugins can be compiled together. # So that users can run this script from anywhere and it will work as expected. -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" -REPO_DIR="$(dirname "$SCRIPT_DIR")" +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" check_changed_packages > /dev/null diff --git a/script/check_publish.sh b/script/check_publish.sh index 39a6894cf5fa..05a237ee97ee 100755 --- a/script/check_publish.sh +++ b/script/check_publish.sh @@ -5,8 +5,8 @@ set -e # It doesn't actually publish anything. # So that users can run this script from anywhere and it will work as expected. -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -REPO_DIR="$(dirname "$SCRIPT_DIR")" +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" diff --git a/script/incremental_build.sh b/script/incremental_build.sh index adb0acc72b97..0e0fb051e70c 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -1,8 +1,8 @@ #!/bin/bash set -e -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -REPO_DIR="$(dirname "$SCRIPT_DIR")" +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh index c9839e79cfbf..07a23c89b7c6 100755 --- a/script/lint_darwin_plugins.sh +++ b/script/lint_darwin_plugins.sh @@ -3,32 +3,34 @@ # This script lints and tests iOS and macOS platform code. # So that users can run this script from anywhere and it will work as expected. -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -REPO_DIR="$(dirname "$SCRIPT_DIR")" +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" function lint_package() { local package_name=$1 local platform=$2 - local podspec_dir="$REPO_DIR/packages/$package_name/$platform/$package_name.podspec" + local podspec="$REPO_DIR/packages/$package_name/$platform/$package_name.podspec" local failure_count=0 - if [[ -f "$podspec_dir" ]]; then + if [[ -f "$podspec" ]]; then echo "Linting $platform $package_name.podspec" # Build as frameworks. # This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0. - pod lib lint "$podspec_dir" --allow-warnings --fail-fast --silent + # TODO: Add --analyze flag https://github.com/flutter/flutter/issues/41443 + # TODO: Remove --allow-warnings flag https://github.com/flutter/flutter/issues/41444 + pod lib lint "$podspec" --allow-warnings --fail-fast --silent if [[ $? -ne 0 ]]; then - error "Package $package_name has framework issues. Run \"pod lib lint $podspec_dir\" to inspect." + error "Package $package_name has framework issues. Run \"pod lib lint $podspec\" to inspect." failure_count+=1 fi # Build as libraries. - pod lib lint "$podspec_dir" --allow-warnings --use-libraries --fail-fast --silent + pod lib lint "$podspec" --allow-warnings --use-libraries --fail-fast --silent if [[ $? -ne 0 ]]; then - error "Package $package_name has library issues. Run \"pod lib lint $podspec_dir --use-libraries\" to inspect." + error "Package $package_name has library issues. Run \"pod lib lint $podspec --use-libraries\" to inspect." failure_count+=1 fi fi From a7369c884bd8b803be532b90aac5db4fa1bcaf5c Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 27 Sep 2019 14:08:42 -0700 Subject: [PATCH 3/4] Find podspecs instead of checking a particular path --- script/lint_darwin_plugins.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh index 07a23c89b7c6..97482bdaa37d 100755 --- a/script/lint_darwin_plugins.sh +++ b/script/lint_darwin_plugins.sh @@ -10,12 +10,11 @@ source "$SCRIPT_DIR/common.sh" function lint_package() { local package_name=$1 - local platform=$2 - local podspec="$REPO_DIR/packages/$package_name/$platform/$package_name.podspec" + local package_dir="$REPO_DIR/packages/$package_name/" local failure_count=0 - if [[ -f "$podspec" ]]; then - echo "Linting $platform $package_name.podspec" + for podspec in $(find "$package_dir" -name "*\.podspec"); do + echo "Linting $package_name.podspec" # Build as frameworks. # This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0. @@ -33,7 +32,7 @@ function lint_package() { error "Package $package_name has library issues. Run \"pod lib lint $podspec --use-libraries\" to inspect." failure_count+=1 fi - fi + done return $failure_count } @@ -73,9 +72,7 @@ function lint_packages() { if [[ ${skipped_packages[*]} =~ $package_name ]]; then continue fi - lint_package $package_name "ios" - failure_count+=$? - lint_package $package_name "macos" + lint_package $package_name failure_count+=$? done From 6dab76b18e3203cb18499321b2068ec1139d4b7d Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 27 Sep 2019 14:45:35 -0700 Subject: [PATCH 4/4] Quotes --- script/lint_darwin_plugins.sh | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh index 97482bdaa37d..5e5d018c391c 100755 --- a/script/lint_darwin_plugins.sh +++ b/script/lint_darwin_plugins.sh @@ -9,74 +9,74 @@ readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" function lint_package() { - local package_name=$1 - local package_dir="$REPO_DIR/packages/$package_name/" + local package_name="$1" + local package_dir="${REPO_DIR}/packages/$package_name/" local failure_count=0 - for podspec in $(find "$package_dir" -name "*\.podspec"); do + for podspec in "$(find "${package_dir}" -name '*\.podspec')"; do echo "Linting $package_name.podspec" # Build as frameworks. # This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0. # TODO: Add --analyze flag https://github.com/flutter/flutter/issues/41443 # TODO: Remove --allow-warnings flag https://github.com/flutter/flutter/issues/41444 - pod lib lint "$podspec" --allow-warnings --fail-fast --silent - if [[ $? -ne 0 ]]; then - error "Package $package_name has framework issues. Run \"pod lib lint $podspec\" to inspect." + pod lib lint "${podspec}" --allow-warnings --fail-fast --silent + if [[ "$?" -ne 0 ]]; then + error "Package ${package_name} has framework issues. Run \"pod lib lint $podspec\" to inspect." failure_count+=1 fi # Build as libraries. - pod lib lint "$podspec" --allow-warnings --use-libraries --fail-fast --silent - if [[ $? -ne 0 ]]; then - error "Package $package_name has library issues. Run \"pod lib lint $podspec --use-libraries\" to inspect." + pod lib lint "${podspec}" --allow-warnings --use-libraries --fail-fast --silent + if [[ "$?" -ne 0 ]]; then + error "Package ${package_name} has library issues. Run \"pod lib lint $podspec --use-libraries\" to inspect." failure_count+=1 fi done - return $failure_count + return "${failure_count}" } function lint_packages() { - if [[ ! $(which pod) ]]; then + if [[ ! "$(which pod)" ]]; then echo "pod not installed. Skipping." return fi # TODO: These packages have linter errors. Remove plugins from this list as linter issues are fixed. local skipped_packages=( - android_alarm_manager - android_intent - battery - connectivity - device_info - google_maps_flutter - google_sign_in - image_picker - in_app_purchase - instrumentation_adapter - local_auth - package_info - path_provider - quick_actions - sensors - share - shared_preferences - url_launcher - video_player - webview_flutter + 'android_alarm_manager' + 'android_intent' + 'battery' + 'connectivity' + 'device_info' + 'google_maps_flutter' + 'google_sign_in' + 'image_picker' + 'in_app_purchase' + 'instrumentation_adapter' + 'local_auth' + 'package_info' + 'path_provider' + 'quick_actions' + 'sensors' + 'share' + 'shared_preferences' + 'url_launcher' + 'video_player' + 'webview_flutter' ) local failure_count=0 for package_name in "$@"; do - if [[ ${skipped_packages[*]} =~ $package_name ]]; then + if [[ "${skipped_packages[*]}" =~ "${package_name}" ]]; then continue fi - lint_package $package_name - failure_count+=$? + lint_package "${package_name}" + failure_count+="$?" done - return $failure_count + return "${failure_count}" } # Sets CHANGED_PACKAGE_LIST