Do not codesign transitive dependency iOS pod resource bundles (#111714)
This commit is contained in:
parent
c36f1f9842
commit
7714a8d034
@ -18,6 +18,15 @@ import 'package:path/path.dart' as path;
|
|||||||
/// adding Flutter to an existing iOS app.
|
/// adding Flutter to an existing iOS app.
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
await task(() async {
|
await task(() async {
|
||||||
|
// Update pod repo.
|
||||||
|
await eval(
|
||||||
|
'pod',
|
||||||
|
<String>['repo', 'update'],
|
||||||
|
environment: <String, String>{
|
||||||
|
'LANG': 'en_US.UTF-8',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// this variable cannot be `late`, as we reference it in the `finally` block
|
// this variable cannot be `late`, as we reference it in the `finally` block
|
||||||
// which may execute before this field has been initialized
|
// which may execute before this field has been initialized
|
||||||
String? simulatorDeviceId;
|
String? simulatorDeviceId;
|
||||||
@ -157,11 +166,12 @@ Future<void> main() async {
|
|||||||
String content = await pubspec.readAsString();
|
String content = await pubspec.readAsString();
|
||||||
content = content.replaceFirst(
|
content = content.replaceFirst(
|
||||||
'\ndependencies:\n',
|
'\ndependencies:\n',
|
||||||
// One framework, one Dart-only, and one that does not support iOS.
|
// One framework, one Dart-only, one that does not support iOS, and one with a resource bundle.
|
||||||
'''
|
'''
|
||||||
dependencies:
|
dependencies:
|
||||||
url_launcher: 6.0.20
|
url_launcher: 6.0.20
|
||||||
android_alarm_manager: 0.4.5+11
|
android_alarm_manager: 0.4.5+11
|
||||||
|
google_sign_in_ios: 5.5.0
|
||||||
$dartPluginName:
|
$dartPluginName:
|
||||||
path: ../$dartPluginName
|
path: ../$dartPluginName
|
||||||
''',
|
''',
|
||||||
@ -201,6 +211,8 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'url_launcher_ios.framework', 'url_launcher_ios'));
|
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'url_launcher_ios.framework', 'url_launcher_ios'));
|
||||||
|
// Resources should be embedded.
|
||||||
|
checkDirectoryExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'GoogleSignIn.framework', 'GoogleSignIn.bundle'));
|
||||||
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
checkFileExists(path.join(ephemeralIOSHostApp.path, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
||||||
|
|
||||||
// Android-only, no embedded framework.
|
// Android-only, no embedded framework.
|
||||||
@ -297,7 +309,7 @@ end
|
|||||||
'CODE_SIGNING_REQUIRED=NO',
|
'CODE_SIGNING_REQUIRED=NO',
|
||||||
'CODE_SIGN_IDENTITY=-',
|
'CODE_SIGN_IDENTITY=-',
|
||||||
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
||||||
'CONFIGURATION_BUILD_DIR=${objectiveCBuildDirectory.path}',
|
'BUILD_DIR=${objectiveCBuildDirectory.path}',
|
||||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||||
],
|
],
|
||||||
environment: <String, String> {
|
environment: <String, String> {
|
||||||
@ -306,27 +318,33 @@ end
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool existingAppBuilt = exists(File(path.join(
|
final String hostAppDirectory = path.join(
|
||||||
objectiveCBuildDirectory.path,
|
objectiveCBuildDirectory.path,
|
||||||
|
'Debug-iphoneos',
|
||||||
'Host.app',
|
'Host.app',
|
||||||
|
);
|
||||||
|
|
||||||
|
final bool existingAppBuilt = exists(File(path.join(
|
||||||
|
hostAppDirectory,
|
||||||
'Host',
|
'Host',
|
||||||
)));
|
)));
|
||||||
if (!existingAppBuilt) {
|
if (!existingAppBuilt) {
|
||||||
return TaskResult.failure('Failed to build existing Objective-C app .app');
|
return TaskResult.failure('Failed to build existing Objective-C app .app');
|
||||||
}
|
}
|
||||||
|
|
||||||
checkFileExists(path.join(
|
final String hostFrameworksDirectory = path.join(
|
||||||
objectiveCBuildDirectory.path,
|
hostAppDirectory,
|
||||||
'Host.app',
|
|
||||||
'Frameworks',
|
'Frameworks',
|
||||||
|
);
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
hostFrameworksDirectory,
|
||||||
'Flutter.framework',
|
'Flutter.framework',
|
||||||
'Flutter',
|
'Flutter',
|
||||||
));
|
));
|
||||||
|
|
||||||
checkFileExists(path.join(
|
checkFileExists(path.join(
|
||||||
objectiveCBuildDirectory.path,
|
hostFrameworksDirectory,
|
||||||
'Host.app',
|
|
||||||
'Frameworks',
|
|
||||||
'App.framework',
|
'App.framework',
|
||||||
'flutter_assets',
|
'flutter_assets',
|
||||||
'isolate_snapshot_data',
|
'isolate_snapshot_data',
|
||||||
@ -335,9 +353,7 @@ end
|
|||||||
section('Check the NOTICE file is correct');
|
section('Check the NOTICE file is correct');
|
||||||
|
|
||||||
final String licenseFilePath = path.join(
|
final String licenseFilePath = path.join(
|
||||||
objectiveCBuildDirectory.path,
|
hostFrameworksDirectory,
|
||||||
'Host.app',
|
|
||||||
'Frameworks',
|
|
||||||
'App.framework',
|
'App.framework',
|
||||||
'flutter_assets',
|
'flutter_assets',
|
||||||
'NOTICES.Z',
|
'NOTICES.Z',
|
||||||
@ -524,7 +540,7 @@ end
|
|||||||
'CODE_SIGNING_REQUIRED=NO',
|
'CODE_SIGNING_REQUIRED=NO',
|
||||||
'CODE_SIGN_IDENTITY=-',
|
'CODE_SIGN_IDENTITY=-',
|
||||||
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
||||||
'CONFIGURATION_BUILD_DIR=${objectiveCBuildDirectory.path}',
|
'BUILD_DIR=${objectiveCBuildDirectory.path}',
|
||||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||||
],
|
],
|
||||||
canFail: true,
|
canFail: true,
|
||||||
@ -570,7 +586,7 @@ end
|
|||||||
'CODE_SIGNING_REQUIRED=NO',
|
'CODE_SIGNING_REQUIRED=NO',
|
||||||
'CODE_SIGN_IDENTITY=-',
|
'CODE_SIGN_IDENTITY=-',
|
||||||
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
'EXPANDED_CODE_SIGN_IDENTITY=-',
|
||||||
'CONFIGURATION_BUILD_DIR=${swiftBuildDirectory.path}',
|
'BUILD_DIR=${swiftBuildDirectory.path}',
|
||||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||||
],
|
],
|
||||||
environment: <String, String> {
|
environment: <String, String> {
|
||||||
@ -581,6 +597,7 @@ end
|
|||||||
|
|
||||||
final bool existingSwiftAppBuilt = exists(File(path.join(
|
final bool existingSwiftAppBuilt = exists(File(path.join(
|
||||||
swiftBuildDirectory.path,
|
swiftBuildDirectory.path,
|
||||||
|
'Debug-iphoneos',
|
||||||
'Host.app',
|
'Host.app',
|
||||||
'Host',
|
'Host',
|
||||||
)));
|
)));
|
||||||
|
@ -45,6 +45,8 @@ def flutter_additional_ios_build_settings(target)
|
|||||||
end
|
end
|
||||||
|
|
||||||
release_framework_dir = File.expand_path(File.join(artifacts_dir, 'ios-release', 'Flutter.xcframework'), __FILE__)
|
release_framework_dir = File.expand_path(File.join(artifacts_dir, 'ios-release', 'Flutter.xcframework'), __FILE__)
|
||||||
|
# Bundles are com.apple.product-type.bundle, frameworks are com.apple.product-type.framework.
|
||||||
|
target_is_resource_bundle = target.respond_to?(:product_type) && target.product_type == 'com.apple.product-type.bundle'
|
||||||
|
|
||||||
target.build_configurations.each do |build_configuration|
|
target.build_configurations.each do |build_configuration|
|
||||||
# Build both x86_64 and arm64 simulator archs for all dependencies. If a single plugin does not support arm64 simulators,
|
# Build both x86_64 and arm64 simulator archs for all dependencies. If a single plugin does not support arm64 simulators,
|
||||||
@ -52,6 +54,14 @@ def flutter_additional_ios_build_settings(target)
|
|||||||
# Therefore all pods must have a x86_64 slice available, or linking a x86_64 app will fail.
|
# Therefore all pods must have a x86_64 slice available, or linking a x86_64 app will fail.
|
||||||
build_configuration.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' if build_configuration.type == :debug
|
build_configuration.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' if build_configuration.type == :debug
|
||||||
|
|
||||||
|
# Workaround https://github.com/CocoaPods/CocoaPods/issues/11402, do not sign resource bundles.
|
||||||
|
if target_is_resource_bundle
|
||||||
|
build_configuration.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
|
||||||
|
build_configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
|
||||||
|
build_configuration.build_settings['CODE_SIGNING_IDENTITY'] = '-'
|
||||||
|
build_configuration.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = '-'
|
||||||
|
end
|
||||||
|
|
||||||
# Skip other updates if it's not a Flutter plugin (transitive dependency).
|
# Skip other updates if it's not a Flutter plugin (transitive dependency).
|
||||||
next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' }
|
next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user