After searching long hours on github and stack for similar errors, none of the proposed solutions helped me to resolve this error.
I tried quite a few things (a bit out of order):
remove IOS derived data
change firestore package version
flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace
pod init, install and update
uncomment platform :ios, '9.0' from podfile (maybe not linked to this issue)
Here is the error:
** BUILD FAILED **
Xcode's output:
↳
/Users/flo/Mobile/we_ll_see/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module
'cloud_firestore' not found
#import cloud_firestore;
~~~~~~~^~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Need some help guys
this is a very bad and unlucky error. After trying to solve this issue for hours, i finally found the solution. The problem is, that your Podfile isn't updating with the pubspec.yaml file. I think, that your Podfile is nearly empty:
target 'Runner' do
use_frameworks!
end
But thats a big problem. This Podfile will be created if you try: $ rm Podfile and then $ pod init.
Here is my solution:
... but before, you have to check something, otherwise my solution probably won't work:
RUN:
$ pod install
If the result of this command is:
There are 0 dependencies from the Podfile and 0 total pods installed.
You can be sure, that this solution works. Otherwise it will also function but maybe you should write me your result of the command line in the comments!!
Now back to the solution...
Step: Update your Podfile with the following code (Please delete the old stuff of the file):
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Now the Podfile is updating the pods you wrote down in your podspec.yaml file.
Now you have to sync you podspec.yaml file with the xcode pods, by calling:
$ pod install
Then you will see all you pods downloading. After this you can run your flutter project, by calling flutter run or just in your editor.
Note: The Podfile.lock file lists down the pods and versions of each pod. The 'real' Podfile is only used for the connection between the podspec.yaml file and the real pods. If you look at your Podfile.lock file, you will see, that there aren't any pods written down and that's causing the problem. If there aren't any pods to install, each module (e.g. 'cloud-firestore') won't be found...
I hope this answer helps you, you can ask me in the comments if something didn't work, but i know, that this won't happen :)
Edit for macos:
platform :osx, '10.11'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path =
File.expand_path(File.join('..', 'Flutter', 'ephemeral',
'Flutter-
Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If
you're running pod install manually, make sure \"flutter pub
get\"
is
executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #.
{generated_xcode_build_settings_path}. Try deleting Flutter-
Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools',
'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods
File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
For me I just update deployment target to the same as define in Pod file.
Note you need to open Runner.xcworkspace not Runner.xcodeproj.
If you are using Android Studio the error might occur if you are creating the Podfile manually.
Flutter runs using just the pubspec.yaml file. You don't have to set up the Podfile by yourself. If you follow the installation guideline on the firestore homepage just skip everything after adding GoogleService-Info.plist file using Xcode.
I tried
rm Podfile
pod init
pod install
but it always showed installed 0 dependencies
then I deleted
podfile.lock
and tried
pod install again
and it installed all project dependencies including cloud_firestore.
and flutter run and flutter build ios worked.
Sharing this in case it helps someone else in the future. I had the same issue as the original poster. I tried all of the solutions suggested above and none of them worked for me. As of the writing of this message, at least 5 different people have reported the same issue in the flutterfire repo on Github but no one has posted a clear solution there either.
What did work for me was deleting the entire ios directory in my Flutter project, then rebuilding it:
flutter create -i swift .
It was very time consuming, but it solved the issue. The 'cloud_firestore' not found error is no longer occurring for me. In addition to rebuilding the ios folder, I had to re-add GoogleService-Info.plist to Runner, re-add icons, re-add signing & capabilities in Xcode, and re-add target properties in Xcode such as privacy usage descriptions, etc.
I'd recommend trying all of the other options mentioned above first, but if like me they do not solve the issue for you, deleting and rebuilding the entire ios folder may be an effective next step.
Make sure you are placing the google services info plist file which you download from firebase into as same folder as info-plist
Remove cocoapods entirely by
sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
rm Podfile
deleting the Podfile/Podfile.lock
Then simply run
flutter run
I also faced the same issue and I tried all the solutions above but none of them worked. Then I tried the following steps and it works.
flutter channel dev
flutter upgrade
flutter run
Well, in my case the issue was the deployment target.
It seems that the default deployment target is 9.0 and Firestore requires a higher deployment target.
I updated my Podfile platform ios, '10.0'
Also in Xcode, from the build settings of the runner project, I changed the deployment target to ios 10.
That worked for me.
I have watched several solutions & now I have got the answer why this is happing.
You can solve this issue in 1 minute.
Just add those lines on Podfile:
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.4.0' // you have to add this line
...
...
...
...
end
I am using tag version: '9.4.0'. You might need to change this as per you using firebase cloud storage.
Just boom. You solve the problem !!!
, my previous answer was unclear. This was just one of many errors I've got while trying to set up Cloud Firestore, so I didn't go through the whole process.
In order for firebase to work, eventually, you have to follow all of the steps from this page:
https://firebase.flutter.dev/docs/firestore/overview/
If you are having problems with generating the firebase_options.dart file, then you need to follow the steps on this page:
https://firebase.google.com/docs/cli#mac-linux-auto-script
The last step is optional, but it reduces build time, and I really don't know how or why, but it made some of the other errors also disappear...
Step 4. Improve iOS & macOS build times, from this page https://firebase.flutter.dev/docs/firestore/overview/
And of course, don't forget to add dependencies in pubspec.yaml
Ref: https://pub.dev/packages/firebase_core/install
There is also a great comment here about using Firebase.initializeApp()
Ref: https://stackoverflow.com/a/63492262/17626190
For anyone still facing this error, the following worked for me:
I was facing the exact same error. My pod file looked exactly like the one asked in the question
target 'Runner' do
use_frameworks!
end
I solved by doing the following:
Delete the ios folder
in the main directory, run the following
flutter create .
This will generate a new ios folder.
run flutter clean
run flutter pub get
cd ios/ and run pod install
That should install all the pods properly in your ios project now.
None of the answers worked for me so I am adding the one that did.
Replace the contents of your Podfile with the following.
platform :ios, '12.0'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
def flutter_install_ios_plugin_pods(ios_application_path = nil)
ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
raise 'Could not find iOS application path' unless ios_application_path
symlink_dir = File.expand_path('.symlinks', ios_application_path)
system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils.
symlink_plugins_dir = File.expand_path('plugins', symlink_dir)
system('mkdir', '-p', symlink_plugins_dir)
plugins_file = File.join(ios_application_path, '..', '.flutter-plugins-dependencies')
plugin_pods = flutter_parse_plugins_file(plugins_file)
plugin_pods.each do |plugin_hash|
plugin_name = plugin_hash['name']
plugin_path = plugin_hash['path']
if (plugin_name && plugin_path)
symlink = File.join(symlink_plugins_dir, plugin_name)
File.symlink(plugin_path, symlink)
if plugin_name == 'flutter_ffmpeg'
pod 'flutter_ffmpeg/full-lts', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
else
pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
end
end
end
end
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Run pub get
Run pod install
In my case, I have a Mac with Apple Chip, so I have to run pod install with arch -x86_64
So... first configure your platforms, and follow the instructions
flutterfire configure --project=...
Then, add the Firebase Core libraries
flutter pub add firebase_core
Run "flutter run" it will fail
flutter run
So, go to ios folder
cd ios
Edit Podfile and change "platform :ios, '9.0'" to "platform :ios, '11.0'" (or higher)
Then execute
arch -x86_64 pod install --repo-update
And then
flutter run
Replace the contents of your Podfile with the following.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
platform :ios, '9.0'
target 'Runner' do
use_frameworks!
use_modular_headers!
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'Firebase/Analytics'
# flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
after a while i found out the solution and its quite simple, for anyone who trying to archive and upload flutter app to app store and having the issue of not detecting the Firebase modules please follow these steps:
note: if you have been already trying and you have created podFiles or plist files like google-services.plist please remove them all and start over...
1- make sure when you use mac device that you install flutter SDK and all the necessary tools (VSCode, git, Cocoapods) in case you are using it only for deployment.
2- after setting up your mac device for flutter development open your files on VSCode and leave it open.
3- open XCode and select open a project or file and select the ios folder, or you can open XCode then return to VSCode and right click (Control + Click) on the ios folder and select "open with XCode".
4- go to your Firebase console and open your project, if you have already set-up your project with IOS click on the IOS project and scroll down to find "Download google-services.plist", Otherwise please setup your project for IOS by only installing google-services.plist file and skip the other steps.
5- go to your Downloads or the place that you downloaded the plist file on and drag it to your XCode under the bottom runner folder where your "info" file exist.
6- go to VSCode now and and open the terminal and type cd ios.
7- This step is the magic, on your terminal type flutter pub get, and you will see an auto podFile generated on your ios folder !.
8- now type pod install and congratulations all pods and dependencies for Firebase are installed correctly.
9- Close XCode and re-open it choosing the ios folder you will notice a change on the files structure.
10- from products tap above choose destination to "any ios device" then Archive.
have a good day !
Your issue not may be a big situation. You might be opening the wrong file in the wrong folder.
So, check out from which folder you are opening in Xcode as Runner.xcworkspace.
You need to from Runner.xcworkspace folder not Runner.xcodeproj.
For my case I just changed the pod file platform ton 12.0 and the Xcode platform to 12.0. This is after adding the following code to pod file
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
Related
Context
We have a Flutter application that is fully functional and it's already published to both the PlayStore and the AppStore.
We're trying to add a Rust binary to the app so that we can use some SDKs that are written in that language.
In order to achive this, we're using Flutter's FFI system with which we can execute native calls to the compiled binary and consume the results from those executions.
In Android we haven't had any problems, it works both in development mode and in production, the binary is added to the bundle when compiling and published with the app to the PlayStore.
The problem
The problem we are having is with iOS. When we run the app locally in development mode, the app works just fine, it compiles seamlessly and we can execute native calls to Rust both from an iOS emulator and from a physical device. Now, when we try compiling the app for deployment to the AppStore is when the problems arise.
The compiling process is divided in 2 steps, first we build the Runner.app package:
flutter build ios
This generates the Runner.app that is then used as input for the Xcode to generate the Archive that will be uploaded to the AppStore:
Xcode Archive
The problem we are facing is that when we archive the Runner.app, the binary gets stripped away by the compiler and the Rust functions are not packaged. This means that when the app reaches the AppStore (both TestFlight and Production) the binary is not there.
Our setup
Our app is built using:
Flutter 2.8.1-stable
Rust 1.58.1
The binary we're trying to bundle is a Compiled static libary: library.a. This binary was built using cargo-lipo as a universal library. (We know cargo-lipo is in maintainance status, but we've also tried bundling binaries built directly with cargo build and the results are the same).
This is our Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '10.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 flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
This is the podspec of the Dart plugin that has the Rust binary:
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint defiant_core.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'defiant_core'
s.version = '0.0.1'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email#example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes**/*.h'
s.vendored_libraries = "**/*.a"
s.static_framework = true
s.dependency 'Flutter'
s.platform = :ios, '9.0'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-force_load $(PODS_TARGET_SRCROOT)/**/*.a" }
s.swift_version = '5.0'
end
What we've tried so far and got the same result (or worse)
Compiling the binary using cargo build instead of cargo-lipo
Playing with the iOS version in the Podfile and the podspec
Removing the use_frameworks! line
Changing this 2 lines following different Github issues suggestions:
# ...
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-force_load $(PODS_TARGET_SRCROOT)/**/*.a" }
# ...
Removing this line s.static_framework = true
Setting the exact location of the .a file in the line s.vendored_libraries = "**/*.a"
Changing the code striping configs in Build Settings in the Runner Target in Xcode:
Xcode Runner Target Build Settings
Compiling the headers file (.h) and linking the binary (.a) in the Build Phase in the Runner Target in Xcode:
Headers and Binary Build Phase
Changing the target architecture in the Runner Build Settings in Xcode:
Changing architecture Runner Build Settings
Conclusion
So far, nothing has worked... We're running out of ideas, so we'd be more than grateful if anyone could point us in the right direction.
Cheers!
I met the same problem, and fixed by following:
https://github.com/fzyzcjy/flutter_rust_bridge/issues/496
http://cjycode.com/flutter_rust_bridge/integrate/ios_headers.html
I think the reason is the release build will strip the symbols which aren't used, and the symbols generated by Rust are directly used by Dart not the App. So you need to use them directly in the App.
So, I am completely new to flutter.
I was given a project that had been developed a few months before (december 2020) on visual studio code with flutter and dart in order to deploy it on the app store.
I would like to point out that the project was working very well at that time, and a test version had even been deployed on iphones.
I have to make sure that it works locally, and then I'm going to deploy it to the app store.
So I opened the source code of the project in my visual studio, I tried to compile it but it didn't work, I don't know if when you open the source code of a project, there are specific configurations to do,
I'm not sure if there are any specific configurations to be made when opening source code for a project, but after browsing the forum, I realized that the error must have come from the most recent version of my flutter, and that's not the version the application was developed with.
So I followed the instructions coming from this solution here Flutter iOS build failed an error of pod files: Podfile is out of date and here <.https://stackoverflow.com/questions/65516334/flutter-error-invalid-podfile-file-no-implicit-conversion-of-nil-into-string> to generate my podfiles again. Except that now this error is generated at compile time
Launching lib/main.dart on iPhone 8 in debug mode...
Running pod install... 1,674ms
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
[!] Unable to find a target named `Runner` in project `Runner.xcodeproj`, did
find `dev` and `prod`.
Would anyone have an idea please?
my previous pod file was
# Uncomment this line to define a global platform for your project
# 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
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |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)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end
target 'Runner' do
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# 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')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end
target 'prod' do
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# 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')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
and the new created one looks like
# Uncomment this line to define a global platform for your project
# 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 flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
and actually when i run flutter doctor, i get
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.55.2)
[✓] Connected device (2 available)
• No issues found!
and actually opening my project in xcode gives me this
I assume you use flutter 1.X previously.
So here is what do when i recently download flutter v2.0.4
when i first open my old project, vscode will show all my file contains error. So what i do is to run flutter pub get. This will get rid of the error.
Next i try to run in debug mode in iOS simulator. After that, i open up the ios (inside the project) folder with xcode, Click on Runner under 'targets` and check the signing before i test it on my iphone.
So in your case, discard any changes that you recently made or stash it with git if you need it first. And run flutter pub get and test it on simulator. This should fix the issue, and they apply/pop your stash back and now you are good to go.
Also note that whenever you run flutter clean, you have to run flutter pub get again. Else you will see VSCode will show all your files in lib folder in red.
Run this if flutter clean and flutter pub get doesn't do the job properly:
$ flutter clean
$ flutter pub get
$ cd ios
$ rm Podfile
$ pod setup
$ flutter build ios
This is the error I am receiving.
I tried flutter clean and changing the syntax of some lines but im new to dart and flutter so im not really sure. I reinstalled cocoa pods and ruby as well but Im receiving the same error. I also made sure to update ruby to the latest version.
[!] Invalid `Podfile` file: no implicit conversion of nil into String.
# from /Users/(name)/Downloads/Projects/doctor_consultation_app/ios/Podfile:57
# -------------------------------------------
# unless File.exist?(copied_framework_path)
> FileUtils.cp(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
# end
# -------------------------------------------
This is my pod file.
# Uncomment this line to define a global platform for your project
# 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
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |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)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end
target 'Runner' do
use_frameworks!
use_modular_headers!
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# 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')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
I got this error when I updated my flutter sdk to the new flutter 2.0, but my project was created with older version of flutter sdk (1.22).
Fixed It by deleting the Podfile and Podfile.lock in ios folder and then run:
flutter run
or
flutter build ios
That way flutter will generate the new Podfile for flutter 2.0
I have same problem when I update my mac --> BigSur and use Ruby .
And I solve it by rm -rf ios and flutter create .
Then fix some file changes in new ios
Warning!!!
if use this on your existing app, it will deleted your iOS folder, but You may have some custom settings in it. So you should add your commit into the new file!!!
I was in channel beta and I solved like this. flutter channel stable and flutter upgrade
The Pod file can change depending on the channel you are using.
Try to update flutter
flutter channel stable
flutter upgrade
Delete your pod file and the Pods folder then rebuild your ios project
flutter build ios
I had to delete the podfile and add it back, then add my extensions back in. Now it seems to be working again. Most of the file got stripped, for example the new file has no parse_KV_file method.
I solve it just replace: copied_flutter_dir = File.join(__dir__, 'Flutter') to copied_flutter_dir = File.join('.', 'Flutter').
pls make sure to remove to .dart_tool folder from the root of the project,
Then inside the ios folder, try flutter clean and flutter build ios
Just sharing my experience with this type of issue, it looks like its basically a versioning issue of pods. I've worked in several hybrid platforms, and it turns out all of the platforms are struggling when comes to build for iOS. Here's how I resolved it:
I've checked my flutter channel whether it's beta or stable, I found it was beta so I switched into the stable channel. commands are flutter channel to see the active channel, then switch to stable if its selected beta by running the command flutter channel stable
remove all generated pod/related files for a fresh build. do the following:
run rm -rf ios/Pods
run rm -rf ios/.symlinks
run rm -rf ios/Flutter/Flutter.framework
run flutter clean
run cd ios in case you're not in the ios folder.
run pod cache clean --all
run pod repo update
run pod install
uncomment platform :ios, 'X.0' from Podfile inside ios folder, and replace X with the current version you're woking.
run flutter build ios better use --verbose to see if any other issues are there.
Hope this will help if anyone stuck at the same problem.
thanks to these guys.
https://stackoverflow.com/a/64318163/3502024
https://stackoverflow.com/a/65539806/3502024
I get this error every time I try adding Cloud Firestore to my Flutter project. I first tried it with my main project, where it failed. I tried it on a clean new project where I get the same result every single time. I've read at least 10 different posts where someone had this error. None of it has worked. I tried deleting Pods and Podfile/Podfile.lock and generating new ones. I've tried using the newest dependency "cloud_firestore: ^0.14.0".
This is my pubspec.yaml:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
cloud_firestore: ^0.14.0
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
This my Podfile (part of it):
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Runner' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Runner
end
# add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
pod 'Firebase/Firestore'
I am getting miserable because I've spent two days watching YouTube videos, checking any article I could and, I kid you not, nothing has worked. I've even contacted Firebase Support to get some answer, but I haven't gotten any response yet.
If you happen to know how I could fix this, I will seriously be so thankful!
Trust me, I search for over 5 hours, tried every solution I can find on internet. And only one work:
Delete the Podfile, Podfile.lock, Pods folder
flutter clean
cd ios
pod deintegrate ( this way pod will not reinstall the old libray )
cd ../
flutter run
Most of the solution don't include step 4, so that why even you clean and reinstall pod, it still behave the same.
At the developer, we can learn how to reverse the binary tree in 2 hour and struggle with install steps for over a day, one of the most annoying thing of being developer.
you are missing firebase_core
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2
check this official guide for more: Cloud Firestore
replace your podfile with this one
ENV['COCOAPODS_DISABLE_STATS'] = 'true' //add this line at the beginning of that file
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
platform :ios, '9.0'
target 'Runner' do
use_frameworks!
use_modular_headers!
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'Firebase/Analytics'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
flutter clean
flutter run
Created a new flutter project from Android Studio using the wizard.
Newly created project folder does not have any of the Pods folders or podfile in the ios directory.
This Flutter.io page states (emphasis mine):
While there is a Podfile in the iOS folder in your Flutter project,
only use this if you are adding native dependencies needed for
per-platform integration.
There is no podfile at all in my ios directory.
I found this comment in a different question here suggesting running the project on the ios simulator would generate the file but running the project on the sim and device both do not result in any podfile creation for me.
Is there some step in the ios side of the new flutter project creation that I missed? There's no way for me to add ios-specific dependencies without the podfile.
Output of flutter doctor:
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.12.6 16G1408, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio (version 3.1)
[!] VS Code (version 1.25.1)
[✓] Connected devices (1 available)
Here is what I usually do:
go into ios folder
delete the Podfile.lock file
rm -rf Pods
pod cache clean --all
pod deintegrate
pod setup
pod install
You may also want to do
pod repo update
Once you run flutter build ios a Podfile and Podfile.lock will be created for you in the ios directory.
Follow the steps in the deploy steps official documentation.
I will suggest simply go to your Flutter Package and do flutter create .
It will automatically create all the missing files and even Podfile.
I have used this command in my project and it is fruitful.
Recently, I encountered the same problem. No Podfile created even when I add dependency packages in the pubspec.yaml file. In the end, I have to manually add a Pod file in the ios directory and issue 'pod deintegrate', 'pod setup' and 'pod install'.
Here is my podfile. You can try it:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
pod 'Firebase/Core'
pod 'FBSDKLoginKit' #optional
pod 'GoogleAnalytics'
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
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
use_frameworks!
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
#pre_install do |installer|
# workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
# Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
#end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '4.2'
end
# Peter aded on 8 Oct 2018
# workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
#target.headers_build_phase.files.each do |file|
# file.settings = { 'ATTRIBUTES' => ['Public'] }
#end
end
end
Also, I tried using Vcode to create a new Flutter project. Add package in pubspec.yaml file, save and the podfile was automatically created,
Create a new Flutter project using Vcode
Start VS Code
Invoke View>Command Palette…
Type ‘flutter’, and select the ‘Flutter: New Project’ action
Enter a project name (e.g. myapp), and press Enter
Specify a location to place the project, and press the blue OK
button
Wait for the project creation to continue, and the main.dart file to
appear
Add a package in the pubspec.yaml file and save it.
The podfile should be created.
flutter:
plugin:
platforms:
ios:
pluginClass: AppDelegate
You need to add the above lines to the pubspec.yaml and then the pub would automatically generate the Podfile inside the ios folder.
[Windows/Android studio] To create podfile all you need is to run pod init in ios folder in your flutter project, If you are using window and not yet installed CocoPods, then you need to install ruby which is prerequires to install CocoPods (pod command) which in turn is used to create podfile
Once they are installed, navigate to ios folder in your flutter project and run the following command to create init podfile in ios folder:
pod init
For me the reason the podfile in the ios folder was not being created was the fact that I had made it a module in the pubspec:
module:
androidX: true
androidPackage: ******
iosBundleIdentifier: ******
Removing this part from the pubspec made flutter generate the podfile again when running pub get. I'm using it as a module but like to be able to run the project standalone as well, so for that reason I put the module bit back in again after running a pub get.
I had just created a new project and didn't see the Podfile in the ios/ directory. I needed the Podfile in order to setup Firebase integration. Although it has been pointed out in a comment by #ncuillery, I thought I should add an answer for the reason that a comment may be missed very easily!
All you have to do is add a dependency to the pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_auth: ^1.0.2 # <--- add this line (doesn't have to be firebase_auth)
Run pub get to get the dependencies. If the command exists successfully, in the terminal you should see:
Process finished with exit code 0
The Podfile should have been created after running the command with the dependency listed and can then be found at ios/Podfile.
I found the Podfile and Podfile.lock in the ios folder as created by the Flutter tools, yet Pods.xcodeproj was missing in the Xcode view of the project.
I opened a command-line terminal, went into ios folder and ran
pod install
that was enough for me to fix the project.
you can use this command to find this issue https://docs.flutter.dev/development/add-to-app/ios/project-setup.
it's worked for me.
flutter build ios-framework --output=some/path/MyApp/Flutter/
use pwd command to get the current directory
replace --output=some/path/MyApp/Flutter/ by --output=currentdirectory/directoryapp/ios/Flutter
so
flutter build ios-framework --output=currentdirectory/directoryapp/ios/Flutter
for me it was:
flutter build ios-framework --output=/Users/ilimigroup/StudioProjects/Telia-ios/telia/ios/Flutter
after that, you can run in xcode
If you are on window please try this for pod file install in android studion
npx pod install
Adding default Podfile content if that can be helpful for someone, else if needed proper solution resolved this issue inside other question
# platform :ios, '11.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 flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Easiest method that worked for me is just do:
pod init
in the terminal