Add flutter build ipa --no-codesign flag (#101766)

This commit is contained in:
Jenn Magder
2022-04-12 14:49:09 -07:00
committed by GitHub
parent d4bfb01336
commit 6ccd993976
2 changed files with 57 additions and 14 deletions

View File

@@ -31,10 +31,6 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
..addFlag('simulator',
help: 'Build for the iOS simulator instead of the device. This changes '
'the default build mode to debug if otherwise unspecified.',
)
..addFlag('codesign',
defaultsTo: true,
help: 'Codesign the application bundle (only available on device builds).',
);
}
@@ -53,9 +49,6 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
@override
bool get configOnly => boolArg('config-only');
@override
bool get shouldCodesign => boolArg('codesign');
@override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent;
}
@@ -105,9 +98,6 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override
final bool configOnly = false;
@override
final bool shouldCodesign = true;
String? get exportOptionsPlist => stringArg('export-options-plist');
@override
@@ -141,13 +131,18 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final FlutterCommandResult xcarchiveResult = await super.runCommand();
final BuildInfo buildInfo = await getBuildInfo();
final BuildInfo buildInfo = await cachedBuildInfo;
displayNullSafetyMode(buildInfo);
final FlutterCommandResult xcarchiveResult = await super.runCommand();
// xcarchive failed or not at expected location.
if (xcarchiveResult.exitStatus != ExitStatus.success) {
globals.printStatus('Skipping IPA');
globals.printStatus('Skipping IPA.');
return xcarchiveResult;
}
if (!shouldCodesign) {
globals.printStatus('Codesigning disabled with --no-codesign, skipping IPA.');
return xcarchiveResult;
}
@@ -291,6 +286,10 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
argParser.addFlag('codesign',
defaultsTo: true,
help: 'Codesign the application bundle (only available on device builds).',
);
}
@override
@@ -305,7 +304,8 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
XcodeBuildResult? xcodeBuildResult;
EnvironmentType get environmentType;
bool get configOnly;
bool get shouldCodesign;
bool get shouldCodesign => boolArg('codesign');
late final Future<BuildInfo> cachedBuildInfo = getBuildInfo();

View File

@@ -501,6 +501,49 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('ipa build --no-codesign skips codesigning and IPA creation', () async {
final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand,
const FakeCommand(
command: <String>[
'xcrun',
'xcodebuild',
'-configuration', 'Release',
'-quiet',
'-workspace', 'Runner.xcworkspace',
'-scheme', 'Runner',
'-sdk', 'iphoneos',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGNING_IDENTITY=""',
'-resultBundlePath',
'/.tmp_rand0/flutter_ios_build_temp_dirrand0/temporary_xcresult_bundle',
'-resultBundleVersion', '3',
'FLUTTER_SUPPRESS_ANALYTICS=true',
'COMPILER_INDEX_STORE_ENABLE=NO',
'-archivePath',
'/build/ios/archive/Runner',
'archive',
],
),
]);
_createMinimalMockProjectFiles();
await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '--no-codesign']
);
expect(fakeProcessManager, hasNoRemainingExpectations);
expect(testLogger.statusText, contains('Codesigning disabled with --no-codesign, skipping IPA'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => fakeProcessManager,
Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('code size analysis fails when app not found', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();