Skip to content

Add-to-app Flutter build script fails when Podfile is in different directory from Xcode project #42513

@hllGitHub

Description

@hllGitHub

We found that there is Run Flutter Build Script in flutter 1.9.

flutter_export_environment_path = File.join('$SRCROOT', relative, 'flutter_export_environment.sh');
  script_phase :name => 'Run Flutter Build Script',
    :script => "set -e\nset -u\nsource \"#{flutter_export_environment_path}\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build",
    :input_files => [
      File.join('$SRCROOT', flutter_application_path, '.metadata'),
      File.join('$SRCROOT', relative, 'App.framework', 'App'),
      File.join('$SRCROOT', relative, 'engine', 'Flutter.framework', 'Flutter'),
      flutter_export_environment_path
    ],
    :execution_position => :before_compile

Under normal circumstances can meet our normal use. However, if our Podfile is not in the .xcodeproj directory, ie the Podfile is not in the $SRCROOT directory, then this place is faulty.

File.join('$SRCROOT', flutter_application_path, '.metadata'),
File.join('$SRCROOT', relative, 'App.framework', 'App')
File.join('$SRCROOT', relative, 'engine', 'Flutter.framework', 'Flutter')
File.join('$SRCROOT', relative, 'flutter_export_environment.sh') these paths are not exists.

Suggestion:

I suggest that we can add a parameter pod_path.

in Podfile:

pod_path = current_Podfile_path
install_all_flutter_pods(flutter_application_path, pod_path)

in podhelper.rb:

pod_path ||=flutter_application_path
flutter_export_environment_path = File.join(pod_path, relative, 'flutter_export_environment.sh');
  script_phase :name => 'Run Flutter Build Script',
    :script => "set -e\nset -u\nsource \"#{flutter_export_environment_path}\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build",
    :input_files => [
      File.join(pod_path, flutter_application_path, '.metadata'),
      File.join(pod_path, relative, 'App.framework', 'App'),
      File.join(pod_path, relative, 'engine', 'Flutter.framework', 'Flutter'),
      flutter_export_environment_path
    ],
    :execution_position => :before_compile

podhelper.rb.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions