Reputation: 921
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:
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.
Upvotes: 3
Views: 3816
Reputation: 185
My problem was solved by changing the podfile and changing the order of the build phases of my runner.
Within the PodFile, within the post_install I added the following snippet:
unless target.name == 'Runner'
config.build_settings['SKIP_INSTALL'] = "YES"
end
In my Runner's Build Phases, I needed to leave it in this sequence:
Upvotes: 0
Reputation: 76
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
Upvotes: 0
Reputation: 2391
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.
Upvotes: 1
Reputation: 83
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
Upvotes: 0
Reputation: 921
The temporary solution was to build with command line but the issue with building in Xcode still exist
Upvotes: 0