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

Commit 0943693

Browse files
authored
Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (#114615)
This reverts commit e6300da.
1 parent e6300da commit 0943693

File tree

5 files changed

+10
-158
lines changed

5 files changed

+10
-158
lines changed

packages/flutter_tools/lib/src/commands/build_ios.dart

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import '../convert.dart';
1515
import '../globals.dart' as globals;
1616
import '../ios/application_package.dart';
1717
import '../ios/mac.dart';
18-
import '../ios/plist_parser.dart';
1918
import '../runner/flutter_command.dart';
2019
import 'build.dart';
2120

@@ -130,49 +129,12 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
130129
return super.validateCommand();
131130
}
132131

133-
Future<void> _validateXcodeBuildSettingsAfterArchive() async {
134-
final BuildableIOSApp app = await buildableIOSApp;
135-
136-
final String plistPath = app.builtInfoPlistPathAfterArchive;
137-
138-
if (!globals.fs.file(plistPath).existsSync()) {
139-
globals.printError('Invalid iOS archive. Does not contain Info.plist.');
140-
return;
141-
}
142-
143-
final Map<String, String?> xcodeProjectSettingsMap = <String, String?>{};
144-
145-
xcodeProjectSettingsMap['Version Number'] = globals.plistParser.getStringValueFromFile(plistPath, PlistParser.kCFBundleShortVersionStringKey);
146-
xcodeProjectSettingsMap['Build Number'] = globals.plistParser.getStringValueFromFile(plistPath, PlistParser.kCFBundleVersionKey);
147-
xcodeProjectSettingsMap['Display Name'] = globals.plistParser.getStringValueFromFile(plistPath, PlistParser.kCFBundleDisplayNameKey);
148-
xcodeProjectSettingsMap['Deployment Target'] = globals.plistParser.getStringValueFromFile(plistPath, PlistParser.kMinimumOSVersionKey);
149-
xcodeProjectSettingsMap['Bundle Identifier'] = globals.plistParser.getStringValueFromFile(plistPath, PlistParser.kCFBundleIdentifierKey);
150-
151-
final StringBuffer buffer = StringBuffer();
152-
xcodeProjectSettingsMap.forEach((String title, String? info) {
153-
buffer.writeln('$title: ${info ?? "Missing"}');
154-
});
155-
156-
final String message;
157-
if (xcodeProjectSettingsMap.values.any((String? element) => element == null)) {
158-
buffer.writeln('\nYou must set up the missing settings');
159-
buffer.write('Instructions: https://docs.flutter.dev/deployment/ios');
160-
message = buffer.toString();
161-
} else {
162-
// remove the new line
163-
message = buffer.toString().trim();
164-
}
165-
globals.printBox(message, title: 'App Settings');
166-
}
167-
168132
@override
169133
Future<FlutterCommandResult> runCommand() async {
170134
final BuildInfo buildInfo = await cachedBuildInfo;
171135
displayNullSafetyMode(buildInfo);
172136
final FlutterCommandResult xcarchiveResult = await super.runCommand();
173137

174-
await _validateXcodeBuildSettingsAfterArchive();
175-
176138
// xcarchive failed or not at expected location.
177139
if (xcarchiveResult.exitStatus != ExitStatus.success) {
178140
globals.printStatus('Skipping IPA.');
@@ -327,7 +289,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
327289
/// The result of the Xcode build command. Null until it finishes.
328290
@protected
329291
XcodeBuildResult? xcodeBuildResult;
330-
331292
EnvironmentType get environmentType;
332293
bool get configOnly;
333294

packages/flutter_tools/lib/src/ios/application_package.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ class BuildableIOSApp extends IOSApp {
145145
String get archiveBundleOutputPath =>
146146
globals.fs.path.setExtension(archiveBundlePath, '.xcarchive');
147147

148-
String get builtInfoPlistPathAfterArchive => globals.fs.path.join(archiveBundleOutputPath,
149-
'Products',
150-
'Applications',
151-
_hostAppBundleName == null ? 'Runner.app' : _hostAppBundleName!,
152-
'Info.plist');
153-
154148
String get ipaOutputPath =>
155149
globals.fs.path.join(getIosBuildDirectory(), 'ipa');
156150

packages/flutter_tools/lib/src/ios/plist_parser.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ class PlistParser {
2626

2727
static const String kCFBundleIdentifierKey = 'CFBundleIdentifier';
2828
static const String kCFBundleShortVersionStringKey = 'CFBundleShortVersionString';
29-
static const String kCFBundleExecutableKey = 'CFBundleExecutable';
30-
static const String kCFBundleVersionKey = 'CFBundleVersion';
31-
static const String kCFBundleDisplayNameKey = 'CFBundleDisplayName';
32-
static const String kMinimumOSVersionKey = 'MinimumOSVersion';
29+
static const String kCFBundleExecutable = 'CFBundleExecutable';
3330

3431
/// Returns the content, converted to XML, of the plist file located at
3532
/// [plistFilePath].

packages/flutter_tools/lib/src/macos/application_package.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ abstract class MacOSApp extends ApplicationPackage {
8787
}
8888
final Map<String, dynamic> propertyValues = globals.plistParser.parseFile(plistPath);
8989
final String? id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String?;
90-
final String? executableName = propertyValues[PlistParser.kCFBundleExecutableKey] as String?;
90+
final String? executableName = propertyValues[PlistParser.kCFBundleExecutable] as String?;
9191
if (id == null) {
9292
globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier');
9393
return null;

packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import 'package:flutter_tools/src/base/platform.dart';
99
import 'package:flutter_tools/src/cache.dart';
1010
import 'package:flutter_tools/src/commands/build.dart';
1111
import 'package:flutter_tools/src/commands/build_ios.dart';
12-
import 'package:flutter_tools/src/ios/plist_parser.dart';
1312
import 'package:flutter_tools/src/ios/xcodeproj.dart';
1413
import 'package:flutter_tools/src/reporting/reporting.dart';
15-
import 'package:test/fake.dart';
1614

1715
import '../../general.shard/ios/xcresult_test_data.dart';
1816
import '../../src/common.dart';
@@ -52,20 +50,10 @@ final Platform notMacosPlatform = FakePlatform(
5250
}
5351
);
5452

55-
class FakePlistUtils extends Fake implements PlistParser {
56-
final Map<String, Map<String, Object>> fileContents = <String, Map<String, Object>>{};
57-
58-
@override
59-
String? getStringValueFromFile(String plistFilePath, String key) {
60-
return fileContents[plistFilePath]![key] as String?;
61-
}
62-
}
63-
6453
void main() {
6554
late FileSystem fileSystem;
6655
late TestUsage usage;
6756
late FakeProcessManager fakeProcessManager;
68-
late FakePlistUtils plistUtils;
6957

7058
setUpAll(() {
7159
Cache.disableLocking();
@@ -75,7 +63,6 @@ void main() {
7563
fileSystem = MemoryFileSystem.test();
7664
usage = TestUsage();
7765
fakeProcessManager = FakeProcessManager.empty();
78-
plistUtils = FakePlistUtils();
7966
});
8067

8168
// Sets up the minimal mock project files necessary to look like a Flutter project.
@@ -259,7 +246,8 @@ void main() {
259246
FileSystem: () => fileSystem,
260247
ProcessManager: () => FakeProcessManager.any(),
261248
Platform: () => macosPlatform,
262-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
249+
XcodeProjectInterpreter: () =>
250+
FakeXcodeProjectInterpreterWithBuildSettings(),
263251
});
264252

265253
testUsingContext('ipa build fails when --export-options-plist and --export-method are used together', () async {
@@ -282,7 +270,8 @@ void main() {
282270
FileSystem: () => fileSystem,
283271
ProcessManager: () => FakeProcessManager.any(),
284272
Platform: () => macosPlatform,
285-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
273+
XcodeProjectInterpreter: () =>
274+
FakeXcodeProjectInterpreterWithBuildSettings(),
286275
});
287276

288277
testUsingContext('ipa build reports when IPA fails', () async {
@@ -532,7 +521,8 @@ void main() {
532521
FileSystem: () => fileSystem,
533522
ProcessManager: () => FakeProcessManager.any(),
534523
Platform: () => macosPlatform,
535-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
524+
XcodeProjectInterpreter: () =>
525+
FakeXcodeProjectInterpreterWithBuildSettings(),
536526
});
537527

538528
testUsingContext('Performs code size analysis and sends analytics', () async {
@@ -611,7 +601,8 @@ void main() {
611601
FileSystem: () => fileSystem,
612602
ProcessManager: () => fakeProcessManager,
613603
Platform: () => macosPlatform,
614-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
604+
XcodeProjectInterpreter: () =>
605+
FakeXcodeProjectInterpreterWithBuildSettings(),
615606
});
616607

617608
testUsingContext('Trace error if xcresult is empty.', () async {
@@ -744,97 +735,6 @@ void main() {
744735
Platform: () => macosPlatform,
745736
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
746737
});
747-
748-
testUsingContext(
749-
'Validate basic Xcode settings with missing settings', () async {
750-
751-
const String plistPath = 'build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist';
752-
fakeProcessManager.addCommands(<FakeCommand>[
753-
xattrCommand,
754-
setUpFakeXcodeBuildHandler(onRun: () {
755-
fileSystem.file(plistPath).createSync(recursive: true);
756-
}),
757-
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
758-
]);
759-
760-
createMinimalMockProjectFiles();
761-
762-
plistUtils.fileContents[plistPath] = <String,String>{
763-
'CFBundleIdentifier': 'io.flutter.someProject',
764-
};
765-
766-
final BuildCommand command = BuildCommand();
767-
await createTestCommandRunner(command).run(
768-
<String>['build', 'ipa', '--no-pub']);
769-
770-
expect(
771-
testLogger.statusText,
772-
contains(
773-
'┌─ App Settings ────────────────────────────────────────┐\n'
774-
'│ Version Number: Missing │\n'
775-
'│ Build Number: Missing │\n'
776-
'│ Display Name: Missing │\n'
777-
'│ Deployment Target: Missing │\n'
778-
'│ Bundle Identifier: io.flutter.someProject │\n'
779-
'│ │\n'
780-
'│ You must set up the missing settings │\n'
781-
'│ Instructions: https://docs.flutter.dev/deployment/ios │\n'
782-
'└───────────────────────────────────────────────────────┘'
783-
)
784-
);
785-
}, overrides: <Type, Generator>{
786-
FileSystem: () => fileSystem,
787-
ProcessManager: () => fakeProcessManager,
788-
Platform: () => macosPlatform,
789-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
790-
PlistParser: () => plistUtils,
791-
});
792-
793-
testUsingContext(
794-
'Validate basic Xcode settings with full settings', () async {
795-
const String plistPath = 'build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist';
796-
fakeProcessManager.addCommands(<FakeCommand>[
797-
xattrCommand,
798-
setUpFakeXcodeBuildHandler(onRun: () {
799-
fileSystem.file(plistPath).createSync(recursive: true);
800-
}),
801-
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
802-
]);
803-
804-
createMinimalMockProjectFiles();
805-
806-
plistUtils.fileContents[plistPath] = <String,String>{
807-
'CFBundleIdentifier': 'io.flutter.someProject',
808-
'CFBundleDisplayName': 'Awesome Gallery',
809-
'MinimumOSVersion': '11.0',
810-
'CFBundleVersion': '666',
811-
'CFBundleShortVersionString': '12.34.56',
812-
};
813-
814-
final BuildCommand command = BuildCommand();
815-
await createTestCommandRunner(command).run(
816-
<String>['build', 'ipa', '--no-pub']);
817-
818-
expect(
819-
testLogger.statusText,
820-
contains(
821-
'┌─ App Settings ────────────────────────────┐\n'
822-
'│ Version Number: 12.34.56 │\n'
823-
'│ Build Number: 666 │\n'
824-
'│ Display Name: Awesome Gallery │\n'
825-
'│ Deployment Target: 11.0 │\n'
826-
'│ Bundle Identifier: io.flutter.someProject │\n'
827-
'└───────────────────────────────────────────┘\n'
828-
)
829-
);
830-
}, overrides: <Type, Generator>{
831-
FileSystem: () => fileSystem,
832-
ProcessManager: () => fakeProcessManager,
833-
Platform: () => macosPlatform,
834-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
835-
PlistParser: () => plistUtils,
836-
});
837-
838738
}
839739

840740
const String _xcBundleFilePath = '/.tmp_rand0/flutter_ios_build_temp_dirrand0/temporary_xcresult_bundle';

0 commit comments

Comments
 (0)