Skip to content

Upgrading Flutter added to existing iOS Xcode project

Jenn Magder edited this page Aug 6, 2019 · 3 revisions

(This wiki page applies to people who added Flutter to an existing iOS application before August 2019.)

Introduction

Prior to pull request flutter/flutter#36793 merged on July 30, 2019 (Flutter 1.8.4-pre.21), adding Flutter to an existing iOS application required changes to the Podfile and adding a Run Script build phase to the existing Xcode project. To update to Flutter past this pull request, you must alter your Podfile, delete the Run Script build phase, and regenerate the podhelper script.

The instructions have been updated on the Add Flutter to existing apps Wiki page. Ensure you are on the master channel and run flutter upgrade before following these instructions.

Podfile

Previously, the following lines needed to be added to the Podfile:

 flutter_application_path = 'path/to/my_flutter/'
 eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)

This should be updated to:

  flutter_application_path = 'path/to/my_flutter/'
  load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

  target 'MyApp' do
    install_all_flutter_pods(flutter_application_path)
  end
  target 'MyAppTests' do
    install_all_flutter_pods(flutter_application_path)
  end

Build phase for building the Dart code

Previously, a build phase needed to be added to the existing Xcode project:

"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

This build phase is no longer necessary and must be deleted.

Regenerate podhelper.rb

cd 'path/to/my_flutter/'
rm .ios/Flutter/podhelper.rb
flutter build ios

Flutter Wiki

Process

Framework repo

The Flutter CLI Tool

Engine repo

Packages repo

Engineering Productivity

User documentation

Clone this wiki locally