Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1e979a9

Browse files
committed
Set MinimumOSVersion in iOS Info.plist based on buildroot setting
1 parent 233a6e0 commit 1e979a9

File tree

6 files changed

+52
-15
lines changed

6 files changed

+52
-15
lines changed

build/copy_info_plist.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
1111
Precondition: $CWD/../../flutter is the path to the flutter engine repo.
1212
13-
usage: copy_info_plist.py <src_path> <dest_path> --bitcode=<enable_bitcode>
13+
usage: copy_info_plist.py --source <src_path> --destination <dest_path> --bitcode --minversion=<deployment_target>
1414
"""
1515

16-
17-
18-
1916
import subprocess
2017

18+
import argparse
2119
import sys
2220
import git_revision
2321
import os
@@ -30,13 +28,25 @@ def GetClangVersion(bitcode) :
3028
return version.splitlines()[0]
3129

3230
def main():
33-
text = open(sys.argv[1]).read()
31+
32+
parser = argparse.ArgumentParser(
33+
description='Copies the Info.plist and adds extra fields to it like the git hash of the engine')
34+
35+
parser.add_argument('--source', help='Path to Info.plist source template', type=str, required=True)
36+
parser.add_argument('--destination', help='Path to destination Info.plist', type=str, required=True)
37+
parser.add_argument('--bitcode', help='Built with bitcode', action='store_true')
38+
parser.add_argument('--minversion', help='Minimum device OS version like "9.0"', type=str)
39+
40+
args = parser.parse_args()
41+
42+
text = open(args.source).read()
3443
engine_path = os.path.join(os.getcwd(), "..", "..", "flutter")
3544
revision = git_revision.GetRepositoryVersion(engine_path)
36-
clang_version = GetClangVersion(sys.argv[3] == "--bitcode=true")
37-
text = text.format(revision, clang_version)
45+
bitcode = args.bitcode is not None;
46+
clang_version = GetClangVersion(bitcode)
47+
text = text.format(revision = revision, clang_version = clang_version, min_version = args.minversion)
3848

39-
with open(sys.argv[2], "w") as outfile:
49+
with open(args.destination, "w") as outfile:
4050
outfile.write(text)
4151

4252
if __name__ == "__main__":

shell/platform/darwin/ios/BUILD.gn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ shared_library("ios_test_flutter") {
259259
":flutter_framework_source",
260260
":ios_gpu_configuration",
261261
":ios_test_flutter_mrc",
262+
":universal_flutter_framework",
262263
"//flutter/common:common",
263264
"//flutter/lib/ui:ui",
264265
"//flutter/shell/platform/darwin/common:framework_shared",
@@ -323,10 +324,16 @@ action("copy_framework_info_plist") {
323324
sources = [ "framework/Info.plist" ]
324325
outputs = [ "$_flutter_framework_dir/Info.plist" ]
325326
args = [
327+
"--source",
326328
rebase_path(sources[0]),
329+
"--destination",
327330
rebase_path(outputs[0]),
328-
"--bitcode=$enable_bitcode",
331+
"--minversion",
332+
ios_deployment_target,
329333
]
334+
if (enable_bitcode) {
335+
args += [ "--bitcode" ]
336+
}
330337
}
331338

332339
copy("copy_framework_module_map") {

shell/platform/darwin/ios/framework/Info.plist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>8.0</string>
24+
<string>{min_version}</string>
2525
<key>FlutterEngine</key>
26-
<string>{0}</string>
26+
<string>{revision}</string>
2727
<key>ClangVersion</key>
28-
<string>{1}</string>
28+
<string>{clang_version}</string>
2929
</dict>
3030
</plist>

shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#import <Foundation/Foundation.h>
56
#import <OCMock/OCMock.h>
67
#import <XCTest/XCTest.h>
78

@@ -30,6 +31,21 @@ - (void)testCreate {
3031
XCTAssertNotNil(engine);
3132
}
3233

34+
- (void)testInfoPlist {
35+
NSBundle* flutterBundle = [NSBundle bundleForClass:[FlutterEngine class]];
36+
XCTAssertEqualObjects(flutterBundle.bundleIdentifier, @"io.flutter.flutter");
37+
NSDictionary<NSString*, id>* infoDictionary = flutterBundle.infoDictionary;
38+
XCTAssertEqualObjects(infoDictionary[@"MinimumOSVersion"], @"9.0");
39+
40+
// SHA length is 40.
41+
XCTAssertEqual(((NSString*)infoDictionary[@"FlutterEngine"]).length, 40);
42+
43+
// {clang_version} placeholder is 15 characters. The clang string version
44+
// is longer than that, so check if the placeholder has been replaced, without
45+
// actually checking a literal string, which could be different on various machines.
46+
XCTAssertTrue(((NSString*)infoDictionary[@"ClangVersion"]).length > 15);
47+
}
48+
3349
- (void)testDeallocated {
3450
__weak FlutterEngine* weakEngine = nil;
3551
{

shell/platform/embedder/BUILD.gn

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,14 @@ if (is_mac && !embedder_for_target) {
320320
outputs =
321321
[ "$_flutter_embedder_framework_dir/Versions/A/Resources/Info.plist" ]
322322
args = [
323+
"--source",
323324
rebase_path(sources[0]),
325+
"--destination",
324326
rebase_path(outputs[0]),
325-
"--bitcode=$enable_bitcode",
326327
]
328+
if (enable_bitcode) {
329+
args += [ "--bitcode" ]
330+
}
327331
}
328332

329333
copy("copy_module_map") {

shell/platform/embedder/assets/EmbedderInfo.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
<key>NSHumanReadableCopyright</key>
2626
<string>Copyright 2013 The Flutter Authors. All rights reserved.</string>
2727
<key>FlutterEngine</key>
28-
<string>{0}</string>
28+
<string>{revision}</string>
2929
<key>ClangVersion</key>
30-
<string>{1}</string>
30+
<string>{clang_version}</string>
3131
</dict>
3232
</plist>

0 commit comments

Comments
 (0)