I'm VERY new to the Mac OS (I'm running macOS Monterey v12.4) on an M1 Macbook Pro.
I have Flutter installed and have built a few sandbox apps with this framework.
I'm trying to build a web application with Flutter and Cloud Firestore and thought it best to use the flutterfire_cli to do some of the configurations but I'm stuck trying to run a specific setup command.
The command that I'm trying to run is "dart pub global activate flutterfire_cli" from a terminal. The output that I get is the following when I run this (the error is at the bottom):
ansi_styles 0.3.2+1s...
args 2.3.1
async 2.9.0
ci 0.1.0
cli_util 0.3.5
collection 1.16.0
dart_console 1.0.0
deep_pick 0.10.0
ffi 1.2.1 (2.0.0 available)
file 6.1.2
flutterfire_cli 0.2.2+2
http 0.13.4
http_parser 4.0.1
interact 2.1.1
json_annotation 4.5.0
matcher 0.12.11
meta 1.8.0
path 1.8.2
petitparser 5.0.0
platform 3.1.0
process 4.2.4
pub_semver 2.1.1
pub_updater 0.2.2
pubspec 2.2.0
quiver 3.1.0
source_span 1.9.0
stack_trace 1.10.0
string_scanner 1.1.1
term_glyph 1.2.0
tint 2.0.0
typed_data 1.3.1
uri 1.0.0
win32 2.6.1 (2.7.0 available)
xml 5.4.1 (6.1.0 available)
yaml 3.1.1
Could not find a file named "pubspec.yaml" in "/Users/myusername/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.2+2".
When I try to run the next command according to the documentation here: https://firebase.google.com/docs/flutter/setup?platform=web
That command is "flutterfire configure" from within Android studio
I get the following error: "zsh: command not found: flutterfire"
I'm running node version "v16.15.1" and nvm version "0.39.1" with npm version "8.12.1"
Has anyone run into this?
Thanks!
In your termianl run:
export PATH="$PATH":"$HOME/.pub-cache/bin"
Then try to use flutterfire command in your project directory.
Thanks for that response shuster.
I'm afraid that my environment needed abit more help as there were errors when running several commands. I'll outline the steps I used below to finally get this working.
Steps to resolve the issue
Delete Node and NPM (aka - fresh start)
This post here outlined a straightforward way to do this: https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Reinstall node WITHOUT using the 'sudo' command using NVM
Verify that all versions are in place and working for NVM, NODE and NPM - all good
Was still getting issues with the command from Dart to activate the flutterfire_cli "dart pub global activate flutterfire_cli"
I didn't capture the exact error, but there was a complaint about a PUBSPEC.YAML missing
I suspected that something was wrong with my Dart installation or cache, so I decided to try clearing the cache
Repairing the cache using this command "dart pub cache repair" produced a "permissions denied" error on the .pub-cache folder
Cleaning the DART cache using this command "dart pub cache clean" produced the same "permissions denied" error on the same folder
So, I went in and deleted everything in that .pub-cache folder manually
I then went back to the terminal and ran the command "dart pub global activate flutterfire_cli" to try and get Dart into a better place
This worked but I got an error message (basically) stating that the path was wrong for a global command and I needed to run "export PATH="$PATH":"$HOME/.pub-cache/bin"
If I ran that PATH command from the terminal, then the Flutterfire CLI would work for that session only but not work in my IDE (Android Studio) unless I ran that same command again inside the IDE
At this point I knew I was very close and needed to figure out how to get this Mac to keep that setting all the time
After some digging into what this "zsh" thing was, I found a post that explained it very well and was able to make the change permanent https://wpbeaches.com/how-to-add-to-the-shell-path-in-macos-using-terminal/
Hope this helps someone - happy coding!
I'm working on an app idea and ran into an issue with shared_preferences. After trying out a couple of things I stumbled on a post on stackoverflow to delete the app and reinstalling it again. After uninstalling the app I tried to run
$ flutter run
again but it doesn't build.
Launching lib/main.dart on iPhone 13 mini in debug mode...
Running pod install... 937ms
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `shared_preferences_ios` from `.symlinks/plugins/shared_preferences_ios/ios`
Resolving dependencies of `Podfile`
I tried to clean the installation:
rm ios/Podfile
flutter pub upgrade
flutter pub run
cd ios
pod init
pod update
flutter clean && flutter run
on flutter pub run the script runs to another error: pub finished with exit code 64
On the app I have custom fonts, and images from the assets folder enabled. The only dependency I'm using is shared_preferences: ^2.0.12
I pasted the full log here: https://pastebin.com/5XyDT0PT
edit:
I tried to reinstall cocoapods but still get the same error message:
$ brew upgrade ruby
$ gem uninstall cocoapods
$ gem install cocoapods
anyone having simular issues?
I've had this error too. Learn to look at the error log outputs. I believe you need this command
gem install ffi
see here for more details:
How to resolve LoadError: cannot load such file -- ffi_c
I have a problem that I'm trying to solve since last week, I've been searching about this issue and nothing works. I tried to reinstall the flutter and didn't work aswell. The image below is the first issue I have.
Then I went to "Tools -> Flutter -> Flutter Upgrade" and it shows me this message:
C:\src\flutter\bin\flutter.bat --no-color upgrade
fatal: unterminated line in .git/packed-refs: ...
Building flutter tool...
Running pub upgrade...
ProcessException: Process exited abnormally:
fatal: unterminated line in .git/packed-refs: ...
Command: git fetch --tags
Process finished with exit code 1
And when I tap to "Run 'main.dart'", it shows me this message:
fatal: unterminated line in .git/packed-refs: ...
Building flutter tool...
Running pub upgrade...
Running "flutter pub get" in olx...
The current Flutter SDK version is 0.0.0-unknown.
Because carousel_pro 1.0.0 requires Flutter SDK version >=1.2.0 <2.0.0 and no versions of carousel_pro match >1.0.0 <2.0.0, carousel_pro ^1.0.0 is forbidden.
So, because olx depends on carousel_pro ^1.0.0, version solving failed.
pub get failed (1; So, because olx depends on carousel_pro ^1.0.0, version solving failed.)
What could I do to fix these issues?
(Thanks for listening :)
Here the issue is raised due to Flutter SDK version because it is unknown.
These are some steps that I have followed to solve this problem
Run the following git command into your terminal
=> git clone -b master https://github.com/flutter/flutter.git
(this command will clone a flutter folder which contains latest version of Flutter SDK. get more info about SDK - here)
after cloning, we just need to move cloned folder to our default location of flutter SDK.
In my case path of flutter SDK is as follows(ubuntu) -
=> file:///home/bulbul/snap/flutter/common/flutter
I replaced the last flutter folder with the folder which I have cloned before.
then I ran the "flutter --version" command for getting the version of flutter SDK and it gave me the latest version of flutter SDK and the problem was solved.
It worked for me hopefully It will work for you as well.
Happy learning :)
Use the latest flutter SDK then check if the git is available from the command line using git --version. If it's not available from the command line android studio terminal then add git to system path variable and restart android studio.
I'm trying to create a plugin package in order to access some specific hardware APIs, both in Android (using Kotlin) and in iOS (using Swift). To that end, I was trying to follow the instructions here:
https://flutter.dev/docs/development/packages-and-plugins/developing-packages
I'm right now only working on the Swift side of the problem, so what has been done so far is the following:
1) Went to the directory where other Dart packages live (which are non-Flutter ones, and which work perfectly okay) and ran:
flutter create --org com.example --template=plugin my_plugin
That created the whole thing as described in the documentation, and no error was reported.
2) Then, as stated in the previous link, I went to my_plugin/example and ran flutter build ios --no-codesign, with the following (apparently okay?) output:
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.example.myPluginExample for device (ios-release)...
Running pod install... 6.5s
├─Building Dart code... 2.9s
├─Generating dSYM file... 1.0s
├─Stripping debug symbols... 0.6s
├─Assembling Flutter resources... 1.0s
└─Compiling, linking and signing... 9.0s
Xcode build done. 19.8s
3) So now with the plugin just created, tried to add it to the main project and thus, in its pubspec.yaml file, inserted the following lines (the plugin is located in ../pkgs with respect to the Flutter application I'm working in:
dependencies:
flutter:
sdk: flutter
my_plugin:
path: ../pkgs/my_plugin
4) Now just tried to run the Flutter application both in a physical device and in the simulator, and the following error always showed up:
Launching lib/main.dart on iPhone Xʀ in debug mode...
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Finding Podfile changes
A my_plugin
- Flutter
Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `my_plugin` from `.symlinks/plugins/my_plugin/ios`
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
A Flutter
A my_plugin
Downloading dependencies
-> Installing Flutter (1.0.0)
-> Installing my_plugin (0.0.1)
- Running pre install hooks
[!] Unable to determine Swift version for the following pods:
- `my_plugin` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:115:in `verify_swift_pods_swift_version'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:459:in `validate_targets'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:138:in `install!'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.6.1/libexec/gems/cocoapods-1.6.1/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.6.1/libexec/bin/pod:22:in `load'
/usr/local/Cellar/cocoapods/1.6.1/libexec/bin/pod:22:in `<main>'
Error output from CocoaPods:
↳
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
Error running pod install
Error launching application on iPhone Xʀ.
Exited (sigterm)
5) I tried to fix it by adding the following line to the only 2 Podfile files that I can see in my whole directory structure (the one that belongs to the app and the one that belongs to the new plugin "example" -both files automatically created by Flutter's tools and both not having received any edit until today-):
config.build_settings['SWIFT_VERSION'] = '4.1'
(that idea was taken from https://stackoverflow.com/a/52194702/6348097, and yes: I tried at least one different version number). The error is still the same.
The resulting plugin's Podfile is:
platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
I did the same adding to the Flutter app's Podfile. Also, the first line where the iOS platform was specified, was originally commented (and that was generating a warning) so I also uncommented that line from both podfiles.
This is the output of flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale en-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)
• No issues found!
The question is just how to make this work. I did not even started adding my own code, but I'm stuck with the very basic Flutter's plugin creation tool. Also, I have no idea why I need all that dirty and complex example subdir in my package (so as a secondary question that is not really important: can I just remove it once this works?)
EDIT: I did another test: created an empty app using VSC's "Flutter: New Project" command (which creates the "Flutter 101" increment-a-counter example). Then followed again the steps described above in order to create the plugin package, and got the same error when included that package on the newly created project and ran it in the iOS simulator. So there is absolutely no code from me there, except for having added the new plugin as a dependency to the example app.
Try to open the IOS project in the folder ios/Runner/Runner.xcworkspac with Xcode. Then create / add a new Swift file anywhere in that directory. Xcode will then automatically apply changes needed to your support your swift part of your flutter app.
The other thing could be that your PodFile was modified somehow: try to compare it to Google's master PodFile through this link: PodFile Master File
After having tried several things, none of which worked, I found this solution on a GitHub thread:
https://github.com/ko2ic/image_downloader/issues/9#issuecomment-471608482
Having followed these steps strictly, did finally work.
A few interesting thing were:
I also tried to create the plugin from Android Studio (instead of from the command line or from VSC). It did not work without the steps described in the previous link, but the steps were finally done on that Android Studio created plugin (so I just don't know if this would work with a VSC created plugin, must I would say that most likely yes, since I did not see any difference on the outcome of the commands). I mention this because this answer was suggesting that that may fix the problem: https://stackoverflow.com/a/54919007/6348097
There are 2 Podfile files in the sources: one for the plugin, and another one for the app itself. I modified both and I opened both XCode (automaticall generated) projects.
I also added the following line to the Podfile: config.build_settings['SWIFT_VERSION'] = '4.2', right before the only occurrence of the following line: config.build_settings['ENABLE_BITCODE'] = 'NO'
In both Podfile files, uncommented the platform :ios, '8.0', and changed the versino to 9.0. This did not solve the problem, but at some point fixed a warning when running pod install
Only when using cocoapods(after run pod install), generamba setup failes with the following message when settin path to a .xcodeproj.
The path to a .xcodeproj file of the project is 'GrambaSample.xcodeproj'. Do you want to use it? (yes/no) yes
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.4.2/lib/xcodeproj/project/object.rb:321:in `configure_with_plist': [!] Xcodeproj doesn't know about the following attributes {"inputFileListPaths"=>[], "outputFileListPaths"=>[]} for the 'PBXShellScriptBuildPhase' isa. (RuntimeError)
This error won't appear is not using cocoapods.
How can I be able to setup Generamba while using cocoapods.
To avoid this issue you should update CocoaPods to the latest beta version by executing
gem install cocoapods --pre
Latest beta version of CocoaPods now using inputFileListPaths and outputFileListPaths.
More info here See .xcfilelist Support