Commit 8171aa86 authored by Adam Barth's avatar Adam Barth

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.
parent 0b7e975e
# 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.
......@@ -23,7 +23,21 @@ AssertExists() {
}
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 @@ BuildApp() {
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 @@ BuildApp() {
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 @@ BuildApp() {
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} \
......
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