"LoadError -dlopen..." while pod install in Mac M1 - ios

I have Mac M1 and am getting following error while using pod install to build flutter project in iOS.
I have already installed home brew, uninstall/install cocoapods using sudo arch -x86_64 gem install cocoapods, but still error occurs.
What can I do for solving this probrem..?
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
...
The result of flutter doctor -v has no issues.
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-arm, locale ja-JP)
• Flutter version 2.10.2 at /Users/sae/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 097d3313d8 (12 days ago), 2022-02-18 19:33:08 -0600
• Engine revision a83ed0e5e3
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/sae/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
[✓] Connected device (2 available)
• iPhone 13 (mobile) • C2EDE2E3-E820-42C2-B0EC-AFC07C401397 • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.109
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
If you need further information, please write a comment.

sudo arch -arm64e gem install cocoapods
sudo arch -arm64e gem install ffi

M1 macs are using ARM proccesors so the
sudo arch -x86_64 gem install cocoapods
isn't meant for such machines but x86 architectures.
Τry using sudo arch -arm64e gem install cocoapods

I have no idea why it solved the problem, but pod is updated regularly by using terminal in Mac instead of that in Android studio.
I used terminal of mac, moved the working directory to the ios folder of my project, and did 'pod update'.
It worked for me.
I read the comment of this:Cannot run the Flutter project with Firebase in MacBook M1

Related

I am getting this error "ld: framework not found Flutter" after upgrade xcode latest Version 13.4.1 (13F100). tried all solution but not succeed

This is the screenshot of error after running the app
Here is
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale en-IN)
• Flutter version 3.0.2 at /Users/magespider/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cd41fdd495 (9 days ago), 2022-06-08 09:52:13 -0700
• Engine revision f15f824b57
• Dart version 2.17.3
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/magespider/Library/Android/sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.68.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.42.0
[✓] Connected device (2 available)
• macOS (desktop) • macOS • darwin-arm64 • macOS 12.4 21F79 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115
! Error: Bhavin’s iPod is not connected. Xcode will continue when Bhavin’s iPod is connected. (code -13)
! Error: iPhone is busy: Waiting to connect and unlock the device. Xcode will continue when iPhone is finished. (code -10)
! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13)
! Error: Bhavin’s iPhone is not connected. Xcode will continue when Bhavin’s iPhone is connected. (code -13)
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Please help to resolve this issue, Thanks in advance
I tried the following solution
Deleted ios folder and then recreated
pod deintegrate, install
delete podfile, podfile.lock the Pods folder, and install the pod again.
tried to change the Other Linker Flag in Runner -> Build settings,
Added arm64 in Excluded Architecture.

Android studio "flutter run" working but Run button not working

When I click the android studio run button, I get the following error and no matter how many methods I tried, it doesn't work, but when I type the "flutter run" command, it works.
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
Exception: CocoaPods not installed or not in valid state.
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-x64, locale
tr-TR)
• Flutter version 2.8.1 at /Users/aksoyhlc/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /Users/aksoyhlc/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] Connected device (2 available)
• Aksoyhlc iPhone’u (mobile) •----- •
ios • iOS 14.7.1 18G82
• Chrome (web) • chrome •
web-javascript • Google Chrome 97.0.4692.99
I had this issue sometimes, the only way i found was to uninstall cocoapods, reinstall it and relaunch the IDE. Check the steps todo here: https://stackoverflow.com/a/64000509/9043877

iOS simulator for flutter

this is my second day on Mac. I just bought the new M1 one and I started installing my apps.
I was building some apps with Flutter in Windows.
Now I installed Xcode and it's working with iPhone 13 emulator but it's not showing is vsCODE.
This is the output of Flutter Doctor
[flutter] flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.3.1 20E241 darwin-arm, locale fr-TN)
• Flutter version 2.5.3 at /Users/macbookpro/DevTools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (il y a 3 semaines), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✗] Android toolchain - develop for Android devices
• Android SDK at /Users/macbookpro/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
[!] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
! CocoaPods 1.8.4 out of date (1.10.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.61.2)
• VS Code at /Users/macbookpro/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.28.0
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
exit code 0
On Mac you still have to start your Emulator in XCode, then after you created your Flutter Project you can open the directory on VS, do not forget to install the Flutter Plugin in VS.
I had a rough time a new macos user. I tried
sudo gem install cocoapods
then got the response
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210308-2865-1ivyp7s.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
i had installed cocoapods earlier using homebrew.
So instead this worked, you have to get the latest version first with homebrew.
brew install cocoapods
then
brew link --overwrite cocoapods
flutter doctor -v
will output
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.0)
• VS Code at /Users/myname/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • • ios
• com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 96.

How to upgrade your flutter project (app) to the latest flutter version after null safety?

I want to upgrade my project which is on Flutter 2.0 to the latest version of flutter (2.5).
I have already seen this question which is most relevant.
How do I upgrade an existing Flutter app?
In my Mac, I have Flutter upgraded to 2.5. You can see the output of flutter doctor -v below:
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-arm, locale
en-PK)
• Flutter version 2.5.0 at /Users/ahmad/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/ahmad/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.11.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • 57868E1C-4871-4185-A797-383121736AB8 • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 93.0.4577.82
• No issues found!
I have searched over the internet about it. Mostly, I see two things, either how to upgrade to null-safety (which means from earlier versions to 2.0) or how to upgrade Flutter sdk in your system.
I have tried running flutter upgrade command which says I'm up-to-date.
I have also tried running flutter pub upgrade.
Both do not change the version of flutter in the pubspec.lock file inside my project which says at the end of file:
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.0.0"
Please guide me how can I upgrade my project to the latest version.
Thanks in advance :)
The Flutter project will have the same version as your system does. If you have the latest Flutter version on your system, then the app built from that system will have the latest version.
For example, if your system has Flutter 2.8 (latest while answering) and you build an app through it, your app is based on 2.8.
You're using flutter: >=2.0.0 which basically tells your app to use 2.0.0. Usually using the flutter sdk constraint is only used in plugins. It's okay to leave this out, if you remove flutter: >=2.0.0 it will automatically use your SDK version

Cocoapods seems to install wrong pod version

Cocoapods seems to install a wrong pod version.
Here is an example line from my pubspec.yaml:
webview_flutter: ^1.0.7
When running pod install, this is what I see:
Installing webview_flutter (0.0.1)
In my flutter/.pub_cache/hosted/pub.dartlang.org/ I see the only the following versions:
webview_flutter-0.3.24
webview_flutter-1.0.7
When building with XCode, I get a few warnings from webview_flutter that point to the correct 1.0.7 version, so it seems the right pod is being used despite the cocoapods output. However, this is really confusing. Any thoughts how to solve this would be greatly appreciated.
I have tried re-installing cocoapods, deintegrating pods and building again, cleaning, updating pod repo, deleted Podfile.lock etc usual suspects.
Here's my environment:
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-FI)
• Flutter version 1.22.5 at /Users/ilonamooney/Documents/dev/flutter
• Framework revision 7891006299 (10 days ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/ilonamooney/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/ilonamooney/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] Connected device (1 available)
• Ilona’s iPhone (mobile) • a12e6e165529c7307dfdb723f37e02f3901f17d0 • ios • iOS 14.2```

Resources