Unverified Commit d9adfe3f authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Allow FLUTTER_APPLICATION_PATH to be null for misconfigured Xcode projects (#57701)

parent 03d22501
...@@ -24,19 +24,32 @@ Future<void> main() async { ...@@ -24,19 +24,32 @@ Future<void> main() async {
'--release', '--release',
'--obfuscate', '--obfuscate',
'--split-debug-info=foo/', '--split-debug-info=foo/',
'--no-codesign',
]); ]);
}); });
final String outputAppPath = path.join( final String buildPath = path.join(
flutterProject.rootPath, flutterProject.rootPath,
'build/ios/iphoneos/Runner.app', 'build',
'ios',
'iphoneos',
); );
final String outputAppFramework = path.join( final String outputAppPath = path.join(
flutterProject.rootPath, buildPath,
outputAppPath, 'Runner.app',
'Frameworks/App.framework/App',
); );
if (!File(outputAppFramework).existsSync()) { final Directory outputAppFramework = Directory(path.join(
fail('Failed to produce expected output at $outputAppFramework'); outputAppPath,
'Frameworks',
'App.framework',
));
final File outputAppFrameworkBinary = File(path.join(
outputAppFramework.path,
'App',
));
if (!outputAppFrameworkBinary.existsSync()) {
fail('Failed to produce expected output at ${outputAppFrameworkBinary.path}');
} }
section('Validate obfuscation'); section('Validate obfuscation');
...@@ -46,7 +59,7 @@ Future<void> main() async { ...@@ -46,7 +59,7 @@ Future<void> main() async {
await inDirectory(flutterProject.rootPath, () async { await inDirectory(flutterProject.rootPath, () async {
final String response = await eval( final String response = await eval(
'grep', 'grep',
<String>[flutterProject.name, outputAppFramework], <String>[flutterProject.name, outputAppFrameworkBinary.path],
canFail: true, canFail: true,
); );
if (response.trim().contains('matches')) { if (response.trim().contains('matches')) {
...@@ -56,16 +69,63 @@ Future<void> main() async { ...@@ -56,16 +69,63 @@ Future<void> main() async {
section('Validate bitcode'); section('Validate bitcode');
final String outputFlutterFramework = path.join( final Directory outputFlutterFramework = Directory(path.join(
flutterProject.rootPath, flutterProject.rootPath,
outputAppPath, outputAppPath,
'Frameworks/Flutter.framework/Flutter', 'Frameworks',
'Flutter.framework',
));
final File outputFlutterFrameworkBinary = File(path.join(
outputFlutterFramework.path,
'Flutter',
));
if (!outputFlutterFrameworkBinary.existsSync()) {
fail('Failed to produce expected output at ${outputFlutterFrameworkBinary.path}');
}
bitcode = await containsBitcode(outputFlutterFrameworkBinary.path);
section('Xcode backend script');
outputFlutterFramework.deleteSync(recursive: true);
outputAppFramework.deleteSync(recursive: true);
if (outputFlutterFramework.existsSync() || outputAppFramework.existsSync()) {
fail('Failed to delete embedded frameworks');
}
final String xcodeBackendPath = path.join(
flutterDirectory.path,
'packages',
'flutter_tools',
'bin',
'xcode_backend.sh'
);
// Simulate a commonly Xcode build setting misconfiguration
// where FLUTTER_APPLICATION_PATH is missing
final int result = await exec(
xcodeBackendPath,
<String>['embed_and_thin'],
environment: <String, String>{
'SOURCE_ROOT': flutterProject.iosPath,
'TARGET_BUILD_DIR': buildPath,
'FRAMEWORKS_FOLDER_PATH': 'Runner.app/Frameworks',
'VERBOSE_SCRIPT_LOGGING': '1',
'ACTION': 'install', // Skip bitcode stripping since we just checked that above.
},
); );
if (!File(outputFlutterFramework).existsSync()) { if (result != 0) {
fail('Failed to produce expected output at $outputFlutterFramework'); fail('xcode_backend embed_and_thin failed');
}
if (!outputFlutterFrameworkBinary.existsSync()) {
fail('Failed to re-embed ${outputFlutterFrameworkBinary.path}');
}
if (!outputAppFrameworkBinary.existsSync()) {
fail('Failed to re-embed ${outputAppFrameworkBinary.path}');
} }
bitcode = await containsBitcode(outputFlutterFramework);
}); });
if (foundProjectName) { if (foundProjectName) {
......
...@@ -226,6 +226,7 @@ class FlutterProject { ...@@ -226,6 +226,7 @@ class FlutterProject {
String get rootPath => path.join(parent.path, name); String get rootPath => path.join(parent.path, name);
String get androidPath => path.join(rootPath, 'android'); String get androidPath => path.join(rootPath, 'android');
String get iosPath => path.join(rootPath, 'ios');
Future<void> addCustomBuildType(String name, {String initWith}) async { Future<void> addCustomBuildType(String name, {String initWith}) async {
final File buildScript = File( final File buildScript = File(
......
...@@ -264,15 +264,18 @@ ThinAppFrameworks() { ...@@ -264,15 +264,18 @@ ThinAppFrameworks() {
# Adds the App.framework as an embedded binary and the flutter_assets as # Adds the App.framework as an embedded binary and the flutter_assets as
# resources. # resources.
EmbedFlutterFrameworks() { EmbedFlutterFrameworks() {
AssertExists "${FLUTTER_APPLICATION_PATH}" local project_path="${SOURCE_ROOT}/.."
if [[ -n "$FLUTTER_APPLICATION_PATH" ]]; then
project_path="${FLUTTER_APPLICATION_PATH}"
fi
# Prefer the hidden .ios folder, but fallback to a visible ios folder if .ios # Prefer the hidden .ios folder, but fallback to a visible ios folder if .ios
# doesn't exist. # doesn't exist.
local flutter_ios_out_folder="${FLUTTER_APPLICATION_PATH}/.ios/Flutter" local flutter_ios_out_folder="${project_path}/.ios/Flutter"
local flutter_ios_engine_folder="${FLUTTER_APPLICATION_PATH}/.ios/Flutter/engine" local flutter_ios_engine_folder="${project_path}/.ios/Flutter/engine"
if [[ ! -d ${flutter_ios_out_folder} ]]; then if [[ ! -d ${flutter_ios_out_folder} ]]; then
flutter_ios_out_folder="${FLUTTER_APPLICATION_PATH}/ios/Flutter" flutter_ios_out_folder="${project_path}/ios/Flutter"
flutter_ios_engine_folder="${FLUTTER_APPLICATION_PATH}/ios/Flutter" flutter_ios_engine_folder="${project_path}/ios/Flutter"
fi fi
AssertExists "${flutter_ios_out_folder}" AssertExists "${flutter_ios_out_folder}"
......
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