From 1c0f82541cd0e7153949f4e65759909d736d3802 Mon Sep 17 00:00:00 2001 From: dacaiguoguo Date: Sat, 30 Mar 2019 06:45:18 +0800 Subject: [PATCH] Set custom flutter_assets by add FLTAssetsPath to AppFrameworkInfo.plist (#29499) * Get FLTAssetsPath from AppFrameworkInfo.plist --- packages/flutter_tools/bin/xcode_backend.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh index 1bf2310435..f8f3a2fb89 100755 --- a/packages/flutter_tools/bin/xcode_backend.sh +++ b/packages/flutter_tools/bin/xcode_backend.sh @@ -46,6 +46,19 @@ BuildApp() { target_path="${FLUTTER_TARGET}" fi + local derived_dir="${SOURCE_ROOT}/Flutter" + if [[ -e "${project_path}/.ios" ]]; then + derived_dir="${project_path}/.ios/Flutter" + fi + + # Default value of assets_path is flutter_assets + local assets_path="flutter_assets" + # The value of assets_path can set by add FLTAssetsPath to AppFrameworkInfo.plist + FLTAssetsPath=$(/usr/libexec/PlistBuddy -c "Print :FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist" 2>/dev/null) + if [[ -n "$FLTAssetsPath" ]]; then + assets_path="${FLTAssetsPath}" + fi + # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release, # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build. @@ -87,10 +100,6 @@ BuildApp() { AssertExists "${framework_path}" AssertExists "${project_path}" - local derived_dir="${SOURCE_ROOT}/Flutter" - if [[ -e "${project_path}/.ios" ]]; then - derived_dir="${project_path}/.ios/Flutter" - fi RunCommand mkdir -p -- "$derived_dir" AssertExists "$derived_dir" @@ -248,7 +257,7 @@ BuildApp() { --target="${target_path}" \ --${build_mode} \ --depfile="${build_dir}/snapshot_blob.bin.d" \ - --asset-dir="${derived_dir}/App.framework/flutter_assets" \ + --asset-dir="${derived_dir}/App.framework/${assets_path}" \ ${precompilation_flag} \ ${flutter_engine_flag} \ ${local_engine_flag} \