Document how to build hello_services for iOS (#4354)
This patch adds some sensible defaults to xcode_backend.sh and documents how to
build hello_services for iOS using Xcode.
diff --git a/examples/hello_services/README.md b/examples/hello_services/README.md
new file mode 100644
index 0000000..38e2a7b
--- /dev/null
+++ b/examples/hello_services/README.md
@@ -0,0 +1,25 @@
+# Example of using FlutterView in an iOS app.
+
+This project demonstrates how to embed Flutter within an iOS application
+and build the iOS and Flutter components with Xcode.
+
+## Configure
+
+Create an `ios/Flutter/Generated.xcconfig` file with this entry:
+
+ * `FLUTTER_ROOT=[absolute path to the Flutter SDK]`
+
+There are a number of other parameters you can control with this file:
+
+ * `FLUTTER_APPLICATION_PATH`: The path that contains your `pubspec.yaml` file
+ relative to your `xcodeproj` file.
+ * `FLUTTER_TARGET`: The path to your `main.dart` relative to your
+ `pubspec.yaml`. Defaults to `lib/main.dart`.
+ * `FLUTTER_FRAMEWORK_DIR`: The absolute path to the directory that contains
+ `Flutter.framework`. Defaults to the `ios-release` version of
+ `Flutter.framework` in the `bin/cache` directory of the Flutter SDK.
+
+## Build
+
+Once you've configured your project, you can open `ios/HelloServices.xcodeproj`
+in Xcode and build the project as usual.
diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh
index fae9033..7af41ce 100755
--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -23,7 +23,21 @@
}
BuildApp() {
- local project_path=${FLUTTER_APPLICATION_PATH}
+ local project_path="${SOURCE_ROOT}/.."
+ if [[ -n "$FLUTTER_APPLICATION_PATH" ]]; then
+ project_path=${FLUTTER_APPLICATION_PATH}
+ fi
+
+ local target_path="lib/main.dart"
+ if [[ -n "$FLUTTER_TARGET" ]]; then
+ target_path=${FLUTTER_TARGET}
+ fi
+
+ local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/ios-release"
+ if [[ -n "$FLUTTER_FRAMEWORK_DIR" ]]; then
+ framework_path="${FLUTTER_FRAMEWORK_DIR}"
+ fi
+
AssertExists ${project_path}
local derived_dir=${SOURCE_ROOT}/Flutter
@@ -33,9 +47,11 @@
RunCommand rm -f ${derived_dir}/Flutter.framework
RunCommand rm -f ${derived_dir}/app.so
RunCommand rm -f ${derived_dir}/app.flx
- RunCommand cp -r ${FLUTTER_FRAMEWORK_DIR}/Flutter.framework ${derived_dir}
+ RunCommand cp -r ${framework_path}/Flutter.framework ${derived_dir}
RunCommand pushd ${project_path}
+ AssertExists ${target_path}
+
local local_engine_flag=""
if [[ -n "$LOCAL_ENGINE" ]]; then
local_engine_flag="--local-engine=$LOCAL_ENGINE"
@@ -49,7 +65,7 @@
RunCommand ${FLUTTER_ROOT}/bin/flutter --suppress-analytics build aot \
--target-platform=ios \
- --target=${FLUTTER_TARGET} \
+ --target=${target_path} \
--release \
${interpreter_flag} \
${local_engine_flag}
@@ -70,7 +86,7 @@
fi
RunCommand ${FLUTTER_ROOT}/bin/flutter --suppress-analytics build flx \
- --target=${FLUTTER_TARGET} \
+ --target=${target_path} \
--output-file=${derived_dir}/app.flx \
${precompilation_flag} \
${local_engine_flag} \