Move iOS codesigning into assemble build target (#77664)
This commit is contained in:
@@ -95,6 +95,7 @@ void main() {
|
||||
);
|
||||
|
||||
await const DebugUniversalFramework().build(environment);
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
@@ -104,6 +105,7 @@ void main() {
|
||||
testUsingContext('DebugIosApplicationBundle', () async {
|
||||
environment.inputs[kBundleSkSLPath] = 'bundle.sksl';
|
||||
environment.defines[kBuildMode] = 'debug';
|
||||
environment.defines[kCodesignIdentity] = 'ABC123';
|
||||
// Precompiled dart data
|
||||
|
||||
fileSystem.file(artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug))
|
||||
@@ -120,7 +122,7 @@ void main() {
|
||||
environment.buildDir.childFile('app.dill').createSync(recursive: true);
|
||||
// Stub framework
|
||||
environment.buildDir
|
||||
.childDirectory('App.framework')
|
||||
.childDirectory('App.framework')
|
||||
.childFile('App')
|
||||
.createSync(recursive: true);
|
||||
// sksl bundle
|
||||
@@ -134,10 +136,23 @@ void main() {
|
||||
}
|
||||
));
|
||||
|
||||
await const DebugIosApplicationBundle().build(environment);
|
||||
|
||||
final Directory frameworkDirectory = environment.outputDir.childDirectory('App.framework');
|
||||
expect(frameworkDirectory.childFile('App'), exists);
|
||||
final File frameworkDirectoryBinary = frameworkDirectory.childFile('App');
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'codesign',
|
||||
'--force',
|
||||
'--sign',
|
||||
'ABC123',
|
||||
'--timestamp=none',
|
||||
frameworkDirectoryBinary.path,
|
||||
]),
|
||||
);
|
||||
|
||||
await const DebugIosApplicationBundle().build(environment);
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
|
||||
expect(frameworkDirectoryBinary, exists);
|
||||
expect(frameworkDirectory.childFile('Info.plist'), exists);
|
||||
|
||||
final Directory assetDirectory = frameworkDirectory.childDirectory('flutter_assets');
|
||||
@@ -151,6 +166,7 @@ void main() {
|
||||
|
||||
testUsingContext('ReleaseIosApplicationBundle', () async {
|
||||
environment.defines[kBuildMode] = 'release';
|
||||
environment.defines[kCodesignIdentity] = 'ABC123';
|
||||
|
||||
// Project info
|
||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello');
|
||||
@@ -165,10 +181,23 @@ void main() {
|
||||
.childFile('App')
|
||||
.createSync(recursive: true);
|
||||
|
||||
await const ReleaseIosApplicationBundle().build(environment);
|
||||
|
||||
final Directory frameworkDirectory = environment.outputDir.childDirectory('App.framework');
|
||||
expect(frameworkDirectory.childFile('App'), exists);
|
||||
final File frameworkDirectoryBinary = frameworkDirectory.childFile('App');
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'codesign',
|
||||
'--force',
|
||||
'--sign',
|
||||
'ABC123',
|
||||
frameworkDirectoryBinary.path,
|
||||
]),
|
||||
);
|
||||
|
||||
await const ReleaseIosApplicationBundle().build(environment);
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
|
||||
expect(frameworkDirectoryBinary, exists);
|
||||
expect(frameworkDirectory.childFile('Info.plist'), exists);
|
||||
|
||||
final Directory assetDirectory = frameworkDirectory.childDirectory('flutter_assets');
|
||||
@@ -205,6 +234,7 @@ void main() {
|
||||
contains('release/profile builds are only supported for physical devices.'),
|
||||
)
|
||||
));
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
@@ -233,19 +263,25 @@ void main() {
|
||||
contains('required define SdkRoot but it was not provided'),
|
||||
)
|
||||
));
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Platform: () => macPlatform,
|
||||
});
|
||||
|
||||
group('copy, thin, and bitcode strip engine Flutter.framework', () {
|
||||
group('copies Flutter.framework', () {
|
||||
Directory outputDir;
|
||||
File binary;
|
||||
FakeCommand copyPhysicalFrameworkCommand;
|
||||
FakeCommand lipoCommandNonFatResult;
|
||||
FakeCommand lipoVerifyArm64Command;
|
||||
FakeCommand bitcodeStripCommand;
|
||||
|
||||
setUp(() {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
outputDir = fileSystem.directory('output');
|
||||
binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter');
|
||||
copyPhysicalFrameworkCommand = FakeCommand(command: <String>[
|
||||
'rsync',
|
||||
'-av',
|
||||
@@ -255,10 +291,31 @@ void main() {
|
||||
'Artifact.flutterFramework.TargetPlatform.ios.debug.EnvironmentType.physical',
|
||||
outputDir.path,
|
||||
]);
|
||||
|
||||
lipoCommandNonFatResult = FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Non-fat file:');
|
||||
|
||||
lipoVerifyArm64Command = FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
'-verify_arch',
|
||||
'arm64',
|
||||
]);
|
||||
|
||||
bitcodeStripCommand = FakeCommand(command: <String>[
|
||||
'xcrun',
|
||||
'bitcode_strip',
|
||||
binary.path,
|
||||
'-m',
|
||||
'-o',
|
||||
binary.path,
|
||||
]);
|
||||
});
|
||||
|
||||
testWithoutContext('iphonesimulator', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter');
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
processManager: processManager,
|
||||
@@ -273,7 +330,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'rsync',
|
||||
'-av',
|
||||
@@ -285,24 +342,14 @@ void main() {
|
||||
],
|
||||
onRun: () => binary.createSync(recursive: true),
|
||||
),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Non-fat file:'),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
lipoCommandNonFatResult,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
'-verify_arch',
|
||||
'x86_64',
|
||||
]),
|
||||
);
|
||||
]);
|
||||
await const DebugUnpackIOS().build(environment);
|
||||
|
||||
expect(logger.traceText, contains('Skipping lipo for non-fat file output/Flutter.framework/Flutter'));
|
||||
@@ -334,7 +381,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('fails when requested archs missing from framework', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -350,16 +397,13 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommand(copyPhysicalFrameworkCommand);
|
||||
processManager.addCommand(
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Architectures in the fat file:'),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
@@ -367,7 +411,7 @@ void main() {
|
||||
'arm64',
|
||||
'armv7',
|
||||
], exitCode: 1),
|
||||
);
|
||||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
@@ -379,7 +423,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('fails when lipo extract fails', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -395,16 +439,13 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommand(copyPhysicalFrameworkCommand);
|
||||
processManager.addCommand(
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Architectures in the fat file:'),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
@@ -412,9 +453,6 @@ void main() {
|
||||
'arm64',
|
||||
'armv7',
|
||||
]),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-output',
|
||||
@@ -426,7 +464,7 @@ void main() {
|
||||
binary.path,
|
||||
], exitCode: 1,
|
||||
stderr: 'lipo error'),
|
||||
);
|
||||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
@@ -438,7 +476,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('skips thin framework', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -454,23 +492,11 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommand(copyPhysicalFrameworkCommand);
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Non-fat file:'),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
'-verify_arch',
|
||||
'arm64',
|
||||
]),
|
||||
);
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
]);
|
||||
await const DebugUnpackIOS().build(environment);
|
||||
|
||||
expect(logger.traceText, contains('Skipping lipo for non-fat file output/Flutter.framework/Flutter'));
|
||||
@@ -479,7 +505,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('thins fat framework', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -495,16 +521,13 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommand(copyPhysicalFrameworkCommand);
|
||||
processManager.addCommand(
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Architectures in the fat file:'),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
@@ -512,9 +535,6 @@ void main() {
|
||||
'arm64',
|
||||
'armv7',
|
||||
]),
|
||||
);
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-output',
|
||||
@@ -525,14 +545,14 @@ void main() {
|
||||
'armv7',
|
||||
binary.path,
|
||||
]),
|
||||
);
|
||||
]);
|
||||
|
||||
await const DebugUnpackIOS().build(environment);
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('fails when bitcode strip fails', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -550,17 +570,8 @@ void main() {
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
binary.path,
|
||||
], stdout: 'Non-fat file:'),
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
'-verify_arch',
|
||||
'arm64',
|
||||
]),
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
FakeCommand(command: <String>[
|
||||
'xcrun',
|
||||
'bitcode_strip',
|
||||
@@ -583,7 +594,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('strips framework', () async {
|
||||
final File binary = outputDir.childDirectory('Flutter.framework').childFile('Flutter')..createSync(recursive: true);
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -601,23 +612,88 @@ void main() {
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
bitcodeStripCommand,
|
||||
]);
|
||||
await const DebugUnpackIOS().build(environment);
|
||||
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('fails when codesign fails', () async {
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
outputDir: outputDir,
|
||||
defines: <String, String>{
|
||||
kIosArchs: 'arm64',
|
||||
kSdkRoot: 'path/to/iPhoneOS.sdk',
|
||||
kBitcodeFlag: '',
|
||||
kCodesignIdentity: 'ABC123',
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
bitcodeStripCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
'-info',
|
||||
'codesign',
|
||||
'--force',
|
||||
'--sign',
|
||||
'ABC123',
|
||||
'--timestamp=none',
|
||||
binary.path,
|
||||
], stdout: 'Non-fat file:'),
|
||||
], exitCode: 1, stderr: 'codesign error'),
|
||||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'),
|
||||
)));
|
||||
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('codesigns framework', () async {
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
outputDir: outputDir,
|
||||
defines: <String, String>{
|
||||
kIosArchs: 'arm64',
|
||||
kSdkRoot: 'path/to/iPhoneOS.sdk',
|
||||
kBitcodeFlag: '',
|
||||
kCodesignIdentity: 'ABC123',
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
copyPhysicalFrameworkCommand,
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
bitcodeStripCommand,
|
||||
FakeCommand(command: <String>[
|
||||
'lipo',
|
||||
binary.path,
|
||||
'-verify_arch',
|
||||
'arm64',
|
||||
]),
|
||||
FakeCommand(command: <String>[
|
||||
'xcrun',
|
||||
'bitcode_strip',
|
||||
binary.path,
|
||||
'-m',
|
||||
'-o',
|
||||
'codesign',
|
||||
'--force',
|
||||
'--sign',
|
||||
'ABC123',
|
||||
'--timestamp=none',
|
||||
binary.path,
|
||||
]),
|
||||
]);
|
||||
|
||||
@@ -119,9 +119,6 @@ void main() {
|
||||
|
||||
expect(vmSnapshot.existsSync(), buildMode == BuildMode.debug);
|
||||
|
||||
expect(outputFlutterFramework.childDirectory('Headers'), isNot(exists));
|
||||
expect(outputFlutterFramework.childDirectory('Modules'), isNot(exists));
|
||||
|
||||
// Archiving should contain a bitcode blob, but not building.
|
||||
// This mimics Xcode behavior and prevents a developer from having to install a
|
||||
// 300+MB app.
|
||||
|
||||
Reference in New Issue
Block a user