My flutter app runs fine on android simulator but on trying to launch on ios simulator, it runs the pod install command forever.
So I opened Xcode and found this error:
The sandbox is not in sync with the Podfile.lock. Run 'pod install' or
update your CocoaPods installation.
Here is my podfile:
# 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 have run pod install over and over and also tried updatig cocoapods with
gem install cocoapods
How can I get around with this?
It's really been bugging me for weeks.
If you are running a command flutter run that command requires you to be in the root of the project, but when you need to install cocoapods for iOS project, you first need to move to ios folder, and than run it.
cd ios/
pod install
cd ../
flutter run
Or you can wrap this all up in a single command
cd ios/ && pod install && cd ../ && flutter run
Here are the commands you can use to install pods in a Flutter app using CocoaPods:
flutter create .
pod 'PodName'
pod install
pod update
pod remove PodName
pod list
Note: You should always run these commands from the root directory of your Flutter project.
Related
Since the newest flutter version there is a new structure of the Podfile. For the ffmpeg package I have to add some additional packages to the podfile. But with the new version I don´t know how to handle this.
This is the old structure of the required part
# 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)
if name == 'flutter_ffmpeg'
pod name+'/full-gpl-lts', :path => File.join(symlink, 'ios') // I need this!
else
pod name, :path => File.join(symlink, 'ios')
end
end
How I tried to put this in the new structure
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
symlink = File.join('.symlinks', 'plugins', 'flutter_ffmpeg')
File.symlink(path, symlink)
pod 'flutter_ffmpeg/https-gpl', :path => File.join(symlink, 'ios')
end
But I can´t get it to work. I get the error [!] Invalid Podfile file: File exists # syserr_fail2_in - .symlinks/plugins/flutter_ffmpeg.
Do you have an idea how to write this in the new Podfile format?
This commit seems to be the one that changed podfile structure in flutter tools.
It introduces
def flutter_install_all_ios_pods(ios_application_path = nil)
flutter_install_ios_engine_pod(ios_application_path)
flutter_install_ios_plugin_pods(ios_application_path)
end
What happens is your code
The symlink for flutter_ffmpeg is already created by flutter_install_all_ios_pods and so is the pod.
What I would do
I don't know of a way to remove a pod and i don't want to fork flutter's podhelper, so I would duplicate their method like so:
# Create this "fork" of flutter_install_ios_plugin_pods
def install_plugin_pods(ios_application_path = nil)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
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
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
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')
plugin_pods = flutter_parse_plugins_file(plugins_file)
plugin_pods.each do |name, path|
symlink = File.join(symlink_plugins_dir, name)
File.symlink(path, symlink)
# Changes relative to flutter_ffmpeg
if name == 'flutter_ffmpeg'
pod name+'/https-gpl', :path => File.join('.symlinks', 'plugins', name, 'ios')
else
pod name, :path => File.join('.symlinks', 'plugins', name, 'ios')
end
end
end
target 'Runner' do
use_frameworks!
use_modular_headers!
# Remove this line
# flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
flutter_install_ios_engine_pod(File.realpath(__FILE__))
install_plugin_pods(File.realpath(__FILE__))
end
I cannot test this until tomorrow, i will update this post then.
I'm trying to add firebase to my new flutter project and I have followed the guides (here, and the other official guides by flutter and firebase)
As soon as I add the cloud_firestore to my dependencies I can't compile the project
This is my pubspec.yaml file
name: homemanagement
description: A new Flutter application.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.13.0+1
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
This is Podfile
# 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
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
The issue is that when I try to run the app in my IOS simulator (iPhone 11 pro max)
the process gets stuck on Running pod install...
I have tried to clear cache with flutter pub cache repair and to reinstall with pod install
but it always gets stuck on Installing gRPC-Core (1.28.0)
I have tried to find the issue in Google but couldn't find a solution
P.S:
Works fine on Android
I resolved it by deleting all the cache related to gRPC at /Users/<user>/Library/Caches/CocoaPods/Pods/Release/ and .../Specs/Release/, and running pod install again.
This happens as you have to
.download ios tools,
.ios-profile tools,
.ios release tools
Run:
flutter precache --ios
now run:
pod install
everything will work fine.
I am trying to build ios version of my app on Codemagic without a Mac. The build fails with the following messages.
[!] Automatically assigning platform `iOS` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
[!] CocoaPods could not find compatible versions for pod "flutter_facebook_login":
In Podfile:
flutter_facebook_login (from `.symlinks/plugins/flutter_facebook_login/ios`)
Specs satisfying the `flutter_facebook_login (from `.symlinks/plugins/flutter_facebook_login/ios`)` dependency were found, but they required a higher minimum deployment target.
It seems that ios version requirement of flutter_facebook_login package is higher than ios 8. I think it will be solved if I can specify a higher ios version.
How can I solve this issue?
Finally, I solved the issue by manually creating Podfile as in the following.
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
use_frameworks!
use_modular_headers!
def parse_KV_file(file,seperator='=')
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=seperator)
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
# Flutter Pods
use_frameworks!
use_modular_headers!
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 build or flutter run is executed once first."
end
generated_xcode_build_settings.map{ |p|
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
pod 'Flutter', :path => p[:path]
end
}
# Plugin Pods
plugin_pods = parse_KV_file("../.flutter-plugins")
plugin_pods.map{ |p|
pod p[:name], :path => File.expand_path("ios",p[:path])
}
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
you can uncomment the target in podfile.
or you can add
platform :ios, '11.0'
at the top of you pod file. you can specify the version you need inside the quote
I am working on a flutter project with a firebase backend and am trying to add the ios aspect of my project to a firebase project. The directions say to add the following pods:
# Add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# Add the pods for any other Firebase products you want to use in your app
# For example, to use Firebase Authentication and Cloud Firestore
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
but the issue is I have no idea where to write these in the file. Here is the file located here (ios/Podfile). Can someone who is more familiar with ios development please show me where to add these pods? Thanks!
# 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
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.
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 pub 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
# 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
Thanks again! I also might have another file. Do they mean the Podfile.lock file?
You want to add those lines to the 'Podfile' file, not Podfile.lock. You can add the line at the beginning or the end, but adding it to the very beginning is probably good so you can easily see how the default file has been modified.
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
...
Another thing to keep in mind is when adding your GoogleServices-Info.plist file, you have to add the file in xcode. You can just drag the file into the Runner directory in xcode. But it's not enough to, for example, just download that file into the correct folder.
I want to run my app flutter App on IOS Simulator but it says "running pod install..." infinitely
I tried to find a solution but couldn't find any.
Here is my pod file which was automatically generated by cocoa pod:
# 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
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.
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['ENABLE_BITCODE'] = 'NO'
end
end
end
The expected result was "The app should run on IOS simulator soon" but it's stuck on "running pod install..."
And then gives the following error:
Automatically assigning platform ios with version 8.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.
Delete the podfile.lock file from iOS folder after that go to ios folder and run a below command
Pod install
It will install all the packages which are in your podfile.
Also, you need to set the target platform. Stay in the iOS folder and run below command
open Runner.xcworkspace
then your app will be open in XCode. Click on the "Runner" and set your target platform to 8.0. I fix my iOS build issue using this hope this will work for you.
use a terminal.
go to your ios folder
run
pod install --verbose
you will see what is going on
If you are developing on a recent M1 Mac with Apple Silicon, you may need an additional command after installing Cocoapods found here.
sudo gem install ffi