Repository navigation
Add-to-app Flutter build script fails when Podfile is in different directory from Xcode project #42513
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
jmagman commentedon Oct 11, 2019
You set :project in your host Podfile to a xcproject in some other directory?
jmagman commentedon Oct 11, 2019
In your setup is there a case where the Podfile directory isn't Dir.pwd (the current working directory?). Can you describe your directory structure?
[-]Some ideas about `podhelper.rb`[/-][+]Add-to-app Flutter build script fails when Podfile is in different directory from Xcode project[/+]hllGitHub commentedon Oct 12, 2019
My Podfile:
My directory:
The
$SRCROOTis './Source', butPodfileis in '.' .File.join('$SRCROOT', relative, 'App.framework', 'App')is wrong. Hope can provide custom pod path.Mentina commentedon Oct 17, 2019
hello, hllGitHub.I have the same problem as yours. Could you give me some tips to solve this problem?
hllGitHub commentedon Oct 17, 2019
@Mentina I have some ways.
PodfilePodfileis in the${SRCROOT}directoryMentina commentedon Oct 17, 2019
Thanks a lot, I'm trying your advice above. Lcoal debugging is exactly what I want.
hllGitHub commentedon Oct 17, 2019
The above four methods can solve this problem. Of course, it is best to make adjustments by the official flutter.
jmagman commentedon Oct 17, 2019
I think we can leverage
@current_target_definition.user_project_pathand@defined_in_fileinstead of requiring the user to pass in anything extra to install_all_flutter_pods.Mentina commentedon Oct 18, 2019
@hllGitHub Thanks a lot. I have solved this problem by following your suggestions.It works well.
tanqisen commentedon Nov 19, 2019
I hook the
install_all_flutter_podsfunction in podhelper.rb.in Podfile:
jmagman commentedon Nov 19, 2019
We should fix install_flutter_engine_pod by creating the relative path between
@current_target_definition.user_project_pathand@defined_in_file. I haven't gotten around to this yet.