Skip to content

Commit 2f6920e

Browse files
jmagmanPark Sung Min
authored andcommitted
[camera] Define clang modules in for iOS (flutter#2115)
- Limit the supported podspec platform to iOS so tests don't run (and fail) for macOS. - Define the module by setting `DEFINES_MODULE` in the podspec. See [CocoaPod modular headers docs](http://blog.cocoapods.org/CocoaPods-1.5.0/). - Explicitly set `VALID_ARCHS` to architectures included in the Flutter universal binary. This is the CocoaPods-suggested workaround to prevent tests from running on the i386 simulator. See CocoaPods/CocoaPods#8159.
1 parent 8adc653 commit 2f6920e

9 files changed

Lines changed: 122 additions & 10 deletions

File tree

.cirrus.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ task:
6464
matrix:
6565
- name: build_all_plugins_ipa
6666
script: ./script/build_all_plugins_app.sh ios --no-codesign
67+
- name: lint_darwin_plugins
68+
script: ./script/lint_darwin_plugins.sh
6769
- name: build-ipas+drive-examples
6870
env:
6971
PATH: $PATH:/usr/local/bin

packages/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.5
2+
3+
* Define clang modules for iOS.
4+
15
## 0.5.4+3
26

37
* Update and migrate iOS example project.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import camera;
2+
@import XCTest;
3+
4+
@interface CameraPluginTests : XCTestCase
5+
@end
6+
7+
@implementation CameraPluginTests
8+
9+
- (void)testModuleImport {
10+
// This test will fail to compile if the module cannot be imported.
11+
// Make sure this plugin supports modules. See https://github.com/flutter/flutter/issues/41007.
12+
// If not already present, add this line to the podspec:
13+
// s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
14+
}
15+
16+
@end

packages/camera/ios/camera.podspec

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ A new flutter plugin project.
1515
s.source_files = 'Classes/**/*'
1616
s.public_header_files = 'Classes/**/*.h'
1717
s.dependency 'Flutter'
18-
19-
s.ios.deployment_target = '8.0'
20-
end
18+
s.platform = :ios, '8.0'
19+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'armv7 arm64 x86_64' }
2120

21+
s.test_spec 'Tests' do |test_spec|
22+
test_spec.source_files = 'Tests/**/*'
23+
end
24+
end

packages/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5-
version: 0.5.4+3
5+
version: 0.5.5
66

77
authors:
88
- Flutter Team <flutter-dev@googlegroups.com>

script/build_all_plugins_app.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# sure all first party plugins can be compiled together.
55

66
# So that users can run this script from anywhere and it will work as expected.
7-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
8-
REPO_DIR="$(dirname "$SCRIPT_DIR")"
7+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
8+
readonly REPO_DIR="$(dirname "$SCRIPT_DIR")"
99

1010
source "$SCRIPT_DIR/common.sh"
1111
check_changed_packages > /dev/null

script/check_publish.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -e
55
# It doesn't actually publish anything.
66

77
# So that users can run this script from anywhere and it will work as expected.
8-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
9-
REPO_DIR="$(dirname "$SCRIPT_DIR")"
8+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
9+
readonly REPO_DIR="$(dirname "$SCRIPT_DIR")"
1010

1111
source "$SCRIPT_DIR/common.sh"
1212

script/incremental_build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22
set -e
33

4-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
5-
REPO_DIR="$(dirname "$SCRIPT_DIR")"
4+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
5+
readonly REPO_DIR="$(dirname "$SCRIPT_DIR")"
66

77
source "$SCRIPT_DIR/common.sh"
88

script/lint_darwin_plugins.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# This script lints and tests iOS and macOS platform code.
4+
5+
# So that users can run this script from anywhere and it will work as expected.
6+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
7+
readonly REPO_DIR="$(dirname "$SCRIPT_DIR")"
8+
9+
source "$SCRIPT_DIR/common.sh"
10+
11+
function lint_package() {
12+
local package_name="$1"
13+
local package_dir="${REPO_DIR}/packages/$package_name/"
14+
local failure_count=0
15+
16+
for podspec in "$(find "${package_dir}" -name '*\.podspec')"; do
17+
echo "Linting $package_name.podspec"
18+
19+
# Build as frameworks.
20+
# This will also run any tests set up as a test_spec. See https://blog.cocoapods.org/CocoaPods-1.3.0.
21+
# TODO: Add --analyze flag https://github.com/flutter/flutter/issues/41443
22+
# TODO: Remove --allow-warnings flag https://github.com/flutter/flutter/issues/41444
23+
pod lib lint "${podspec}" --allow-warnings --fail-fast --silent
24+
if [[ "$?" -ne 0 ]]; then
25+
error "Package ${package_name} has framework issues. Run \"pod lib lint $podspec\" to inspect."
26+
failure_count+=1
27+
fi
28+
29+
# Build as libraries.
30+
pod lib lint "${podspec}" --allow-warnings --use-libraries --fail-fast --silent
31+
if [[ "$?" -ne 0 ]]; then
32+
error "Package ${package_name} has library issues. Run \"pod lib lint $podspec --use-libraries\" to inspect."
33+
failure_count+=1
34+
fi
35+
done
36+
37+
return "${failure_count}"
38+
}
39+
40+
function lint_packages() {
41+
if [[ ! "$(which pod)" ]]; then
42+
echo "pod not installed. Skipping."
43+
return
44+
fi
45+
46+
# TODO: These packages have linter errors. Remove plugins from this list as linter issues are fixed.
47+
local skipped_packages=(
48+
'android_alarm_manager'
49+
'android_intent'
50+
'battery'
51+
'connectivity'
52+
'device_info'
53+
'google_maps_flutter'
54+
'google_sign_in'
55+
'image_picker'
56+
'in_app_purchase'
57+
'instrumentation_adapter'
58+
'local_auth'
59+
'package_info'
60+
'path_provider'
61+
'quick_actions'
62+
'sensors'
63+
'share'
64+
'shared_preferences'
65+
'url_launcher'
66+
'video_player'
67+
'webview_flutter'
68+
)
69+
70+
local failure_count=0
71+
for package_name in "$@"; do
72+
if [[ "${skipped_packages[*]}" =~ "${package_name}" ]]; then
73+
continue
74+
fi
75+
lint_package "${package_name}"
76+
failure_count+="$?"
77+
done
78+
79+
return "${failure_count}"
80+
}
81+
82+
# Sets CHANGED_PACKAGE_LIST
83+
check_changed_packages
84+
85+
if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then
86+
lint_packages "${CHANGED_PACKAGE_LIST[@]}"
87+
fi

0 commit comments

Comments
 (0)