Flutter - iOS; app is run but cannot archive - ios

I had a strange situation when my app is run via command line (flutter run) and in xCode but when I choose "Generic iOS Device" to archive, I got an error:
'shared_preferences/SharedPreferencesPlugin.h' file not found
I tried different methods related with plugins problem, recommended in Github and here. For example, this one:
xCode -> Project -> Clean
deleted Podfile.lock and directory Pods
pod install
flutter clean, flutter run
Everything works smoothly until I try to archive.
This is my Podfile (I have done it based on this example: https://github.com/flutter/flutter/issues/15409#issuecomment-387063765)
# 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
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
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'
end
# workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
target.headers_build_phase.files.each do |file|
file.settings = { 'ATTRIBUTES' => ['Public'] }
end
end
end
This is my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.13, on Mac OS X 10.13.6 17G65, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[!] Android Studio (not installed)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
Also, I have checked this question about problems with archiving in xCode but did not find answer.
Do you have any ideas what to do?
Thank you in advance for your support.

I fixed this issue by running flutter build ios and then archiving start working. Flutter build ios download and upgraded few build tools. I think they were causing this isse.

The temporary solution was to build with command line but the issue with building in Xcode still exist

Delete all Pod files inside /ios directory then run the following commands in /ios directory:
sudo pod init
sudo gem install cocoapods
sudo pod install

You may want to try to delete your ios folder and regenerate the project and see whether the error disappears or not:
flutter create .
Hope this help, I have met crash on a project for a few weeks ago since the new update with Xcode 11.4 and this method help me

Related

Unable to find a target named `Runner` in project `Runner.xcodeproj` did find `dev` and `prod`

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

flutter error Invalid `Podfile` file: no implicit conversion of nil into String. ive searched through discussions but I cant seem to fix the issue

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

Flutter iOS cannot build due to modular header settings in podfile

I have a flutter app that was working fine. I'm going through updating my flutter version and the versions of some of my plugins (on the newest XCode version 11). I can no longer build my app because either one of two things occurs:
1) If I don't have "use_modular_headers!" in my podfile, I get this error when trying to run pod install:
The Swift pod `DKPhotoGallery` depends upon `SDWebImage`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
2) If I add "use_modular_headers!" to the podfile, then I can successfully install the podfiles, but it fail when building with this error:
fatal error: module map file '/Users/mbpro/Documents/Perkl/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap' not found
The second error I've come to find out is because GRPC doesn't support modular headings. This is where I'm stuck, because due to flutter's way of dynamically generating podfile from the pubspec, it seems modular headers are either globally on or off, and I can't specifically turn on modular headers for specific pods.
Here is a list of my pubspec dependencies:
cloud_firestore: 0.13.6
firebase_auth: 0.16.1
firebase_core:
firebase_database:
firebase_storage:
firebase_messaging:
google_sign_in:
image_picker:
image_cropper:
intl:
flutter_sound:
flutter_launcher_icons:
flushbar:
file_picker:
path_provider:
#audioplayers:
provider:
sliding_up_panel:
font_awesome_flutter:
marquee:
Any help on this is going to greatly appreciated!! It's completely shut down my development since I can't build to test anything after upgrading.
Edit: Flutter Doctor -v output (everything looks fine)
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale en-US)
• Flutter version 1.17.3 at /Users/mbpro/Downloads/flutter
• Framework revision b041144f83 (8 days ago), 2020-06-04 09:26:11 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mbpro/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.3
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (1 available)
• iPhone SE (2nd generation) • 9FC22937-91AB-4F22-BB1E-20FFB1CAF4C8 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
• No issues found!
After a very long search, the answer is easy.
1- navigate to ios directory inside your app
2- edit podfile in text editor
3- search for target 'Runner' do
4- add use_frameworks! in the next line
5- save and run your app
for example, my full podfile looks like this before solving the issue
# 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
After solving the issue by adding the extra line it 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
use_frameworks!
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
I'been struggling all day with the same issue using a very similar plugin list.
Using this answer:
Using static libraries with CocoaPods 1.5 no such module at import
I was able to modify the flutter pod as follows and build the project:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
inhibit_all_warnings! # ------------------> NEW
use_frameworks! # ------------------> NEW
dynamic_frameworks = ['BoringSSL-GRPC'] # ------------------> NEW
# 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
pre_install do |installer| # ------------------> NEW BLOCK
installer.pod_targets.each do |pod|
puts "Evaluating static framework for pod #{pod.name}"
if dynamic_frameworks.include?(pod.name)
puts "Overriding the static_framework method for #{pod.name}"
pod pod.name, :modular_headers => false
end
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
Its my first time building the app in IOS and the total build time is around 35m (!), I don t known if it is related to this fix, or it's something else.
Also tried doing the inverse, all dynamic and the DKPhotoGalley static, but that makes the build fail with errors on the DKPhotoGallery code.
if someone can chime in with a better approach or understanding of the underlying issue would be great.
Figured it out. I reverted file_picker to 1.6.3+2 now I am able to run my iOS app with no problems. Enjoy. Hope you don't use any of the newer features added to file picker after this version. I was lucky enough to where I don't. I believe this breaking change is why. Either way this worked for me hope it works for you.

Framework not found FirebaseInstanceID on Xcode

I get below error from Xcode. Tried many solutions available on Internet but of no use.
ld: framework not found FirebaseInstanceID
Solutions I tried:
https://stackoverflow.com/a/31298214/10182352
framework not found FirebaseInstanceID in Xcode
https://stackoverflow.com/a/52386172/10182352
Tried deleting Podfile.lock and Podfile and initiated again by:
pod init
pod install
pod update
My Podfile looks like:
# 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 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
# 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
pod 'FirebaseCore'
pod 'Firebase/Analytics'
pod 'Firebase/Performance'
pod 'Crashlytics', '~> 3.12.0'
pod 'GoogleSignIn', '~> 4.4.0'
I have also make sure that I have opened xcodeworkspace not xcodeproject.
For more clarification, I have removed this framework from my Frameworks tab search paths too.
#Paul your answer was spotless. I managed to eradicate this annoying problem following your suggestion:
Open MyRockingApp.xcodeproj
Linking -> Other Linker Flags -> Debug/Release
Delete -framework "FirebaseInstanceID"
Thank you very much!
After 12 hours of constantly going through the DOCs of Firebase and implementing every answers on Stack Overflow I managed to eradicate this error. Below steps are what I did for this:
The framework mentioned above isn't included in the PODs which I have installed. So you need to explicitly download the framework from https://firebase.google.com/download/ios
Once the SDK is downloaded, firstly clear the DerivedData by going to Xcode -> Preferences -> Locations -> Derived Data. Move into that directory and delete the DerivedData folder.
Delete Podfile.lock and Pods folder and do pod init and pod install.
Open XCode and copy the path of framework SDK that you downloaded. For me it is: /user/Downloads/Firebase/FirebaseMessaging/FirebaseInstanceID.xcframework/ios-i386_x86_64-simulator and copy this in Framework Search Paths which is under Build Settings.
Drag and drop the folder named FirebaseInstanceID.framework into Frameworks list as shown in second image of the question(left side).
Remove -l"FirebaseInstanceID" from linker list.
[Target/Build Settings/Linking/Other linker flags].
When updating the pod, it removed the library, but did not remove key from target.linker.list. After manual deletion pod.update not returns it back.
I suspect the Xcode project has a lingering reference to FirebaseInstanceID. The latest versions of the pods listed do not need it.
It should work to remove references to FirebaseInstanceID from the Xcode project.
pod deintegrate
pod install
Resolved my problem.

Flutter Podfile and Pods folders not created in ios directory

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

Resources