Unverified Commit 6ccd9939 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

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

parent d4bfb013
...@@ -31,10 +31,6 @@ class BuildIOSCommand extends _BuildIOSSubCommand { ...@@ -31,10 +31,6 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
..addFlag('simulator', ..addFlag('simulator',
help: 'Build for the iOS simulator instead of the device. This changes ' help: 'Build for the iOS simulator instead of the device. This changes '
'the default build mode to debug if otherwise unspecified.', '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 { ...@@ -53,9 +49,6 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
@override @override
bool get configOnly => boolArg('config-only'); bool get configOnly => boolArg('config-only');
@override
bool get shouldCodesign => boolArg('codesign');
@override @override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent; Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent;
} }
...@@ -105,9 +98,6 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { ...@@ -105,9 +98,6 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override @override
final bool configOnly = false; final bool configOnly = false;
@override
final bool shouldCodesign = true;
String? get exportOptionsPlist => stringArg('export-options-plist'); String? get exportOptionsPlist => stringArg('export-options-plist');
@override @override
...@@ -141,13 +131,18 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { ...@@ -141,13 +131,18 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final FlutterCommandResult xcarchiveResult = await super.runCommand(); final BuildInfo buildInfo = await cachedBuildInfo;
final BuildInfo buildInfo = await getBuildInfo();
displayNullSafetyMode(buildInfo); displayNullSafetyMode(buildInfo);
final FlutterCommandResult xcarchiveResult = await super.runCommand();
// xcarchive failed or not at expected location. // xcarchive failed or not at expected location.
if (xcarchiveResult.exitStatus != ExitStatus.success) { 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; return xcarchiveResult;
} }
...@@ -291,6 +286,10 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -291,6 +286,10 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
addBundleSkSLPathOption(hide: !verboseHelp); addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp); addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag(); usesAnalyzeSizeFlag();
argParser.addFlag('codesign',
defaultsTo: true,
help: 'Codesign the application bundle (only available on device builds).',
);
} }
@override @override
...@@ -305,7 +304,8 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -305,7 +304,8 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
XcodeBuildResult? xcodeBuildResult; XcodeBuildResult? xcodeBuildResult;
EnvironmentType get environmentType; EnvironmentType get environmentType;
bool get configOnly; bool get configOnly;
bool get shouldCodesign;
bool get shouldCodesign => boolArg('codesign');
late final Future<BuildInfo> cachedBuildInfo = getBuildInfo(); late final Future<BuildInfo> cachedBuildInfo = getBuildInfo();
......
...@@ -501,6 +501,49 @@ void main() { ...@@ -501,6 +501,49 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), 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 { testUsingContext('code size analysis fails when app not found', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); _createMinimalMockProjectFiles();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment