Can't build a flutter project with PathProvider dependency
Asked Answered
A

6

6

Disclaimer: First of all, this is my early attempt to play with Flutter. So forgive me if is a noob question.

I had been playing with an MVP-Clean architecture for Flutter apps in iOS, and when trying to build a data source where I can persist data easily I found PathProvider plugin.

After trying the next:

  • Add dependencies to the project

    dependencies: path_provider: "^0.4.0"

  • Provide dependencies

    flutter packages get

    pod install

I try to compile the project and the compiler shouts: ** BUILD FAILED **

Xcode's output: ↳ === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug === /proect_directory/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'path_provider/PathProviderPlugin.h' file not found #import <path_provider/PathProviderPlugin.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

I did a quick search and I did not find anything useful.

Could anyone illuminate my path?

EDIT:

Already tried with:

flutter update-packages --force-upgrade

And the doctor output does not show any errors:

flutter doctor
  • Doctor summary (to see all details, run flutter doctor -v):
  • [✓] Flutter (Channel beta, v0.1.5, on Mac OS X 10.13.3 17D102, locale en-ES)
  • [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
  • [✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
  • [✓] Android Studio (version 3.0)
  • [✓] IntelliJ IDEA Community Edition (version 2017.3.4)
  • [✓] Connected devices (1 available)
Angelikaangelina answered 13/3, 2018 at 9:3 Comment(6)
Can you please try flutter update-packages --force-upgrade and then flutter build apk again? Please also provide the output of flutter doctorNelia
@GünterZöchbauer thanks for the response, I updated the question with more info. the flutter build apk works well, but I am getting the error on the iOS side :/Angelikaangelina
Check also github.com/flutter/flutter/issues/10654 for things to try.Nelia
Switching to dev channel might be worth a try as well flutter channel dev, flutter doctor and try building again.Nelia
You shouldn't ever have to run "flutter update packages --force-upgrade", that's just a tool used by the team to update our internal dependencies. Using that on your own project will likely make it impossible to use "flutter upgrade" again. :-/Trifid
I have same error. In my case, I usually open ios project folder from VS Studio Code > ios > open in xCode open. This lead me [PathProviderPlugin.h] not found error. I solved it by running [open ios/Runner.xcworkspace] in a terminal window from Flutter project directory!Mesosphere
P
3

This issue should be fixed by https://github.com/flutter/flutter/pull/15437

To apply the fix to an existing project, add these lines to ios/Podfile.

Pivotal answered 15/3, 2018 at 21:16 Comment(1)
This is the proper way to achieve it. Thanks, Mikkel!Angelikaangelina
A
2

I finally find a workaround.

I went to the GitHub repo, found the PathProviderPlugin.h file, and put it inside the location:

build/ios/Debug-iphonesimulator/path_provider/path_provider.framework/Headers/

Sounds a little bit dirty, but was the only way to keep coding.

Hope helps someone. And thanks to @GünterZöchbauer to help me find a useful lead.

Angelikaangelina answered 13/3, 2018 at 23:8 Comment(0)
B
1
  1. Open the project in xcode. i.e On Android Studio, right click -> Flutter -> open in xcode.
  2. Find the PathProviderPlugin.h file. (Find -> Find in workspace -> 3. PathProviderPlugin.h)
  3. Click on the result. In case you cannot find the result, right click on the PathProviderPlugin.m file and choose 'Reveal In Project Navigator'
  4. There you will see PathProviderPlugin.h file.
  5. On right hand side, target membership, change the settings from project to public.
  6. Do this for any files for which compiler is complaining, till you are able to build your project.

    Check the image for reference. Use the highlighted button to open right hand panel (Added For Android devs who don't know much of xcode. :) )

Baikal answered 19/5, 2018 at 9:52 Comment(0)
G
1

i have just deleted the podfile.lock and podfile then i run the command flutter build ios ,it install podfile and podlock perfectly but build was failed because i didnt set the team for provision, so then i came to the terminal of android studio and run the command flutter run and it works!...

Grillwork answered 31/8, 2021 at 11:12 Comment(0)
Z
0

For me this was solved by editing podfile as mentioned by this https://github.com/flutter/flutter/issues/10654#issuecomment-389034245 and change the xcode's build system to legacy.

Zamia answered 23/12, 2019 at 13:19 Comment(0)
H
0

I encountered a similar issue and solved it with these simple steps:

  1. Delete the .pub-cache folder inside the Flutter SDK
  2. From the root directory of the flutter project, command flutter clean then flutter pub get
Hebdomadal answered 22/4, 2022 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.