Flutter - macOS; app run but cannot archive - xcode

I had a strange situation that when i run my app is running fine via command line (flutter run) or by using xCode.
But when I choose "Any Mac (Apple Silicon, Intel)" to archive, I got an error:
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 macOS Podfile:
platform :osx, '10.11'
# 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', '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
This is the output of flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-2.0.pre.86, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-IN)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Community Edition (version 2020.3)
[✓] Connected device (3 available)
! Doctor found issues in 2 categories.
Do anyone have any ideas what to do?
Thank you in advance for your support.

Related

MACOSX_DEPLOYMENT_TARGET keeps reverting to old values

I'm trying to build a Flutter app that targets macOS. After adding some dependencies, like just_audio, I am given warnings regarding MACOSX_DEPLOYMENT_TARGET in various locations being set to various values which need to be changed to some other value.
So, I open Xcode and studiously set the values as instructed. After that the app compiles successfully without warnings and performs as expected once, twice, maybe even three times, but inevitably the warnings will return. When I go back into Xcode I find that all of the values have reverted back to what they were before. I've tried different target versions, from 10.15 up to 13.1 (currently installed), but the warnings always come back eventually.
Am I missing an important step? I'm not new to software development, but I am completely new to macOS and Xcode.
Here's a sample of the errors that keep coming back:
Launching lib/main.dart on macOS in debug mode...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-000210D03EB8401E }
{ platform:macOS, arch:x86_64, id:00006000-000210D03EB8401E }
/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'FMDB' from project 'Pods')
/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'sqflite' from project 'Pods')
/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'audio_session' from project 'Pods')
/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12.2, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'audio_service' from project 'Pods')
/Users/foo/projects/just_audio_background_test/macos/Runner.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'Flutter Assemble' from project 'Runner')
/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'FlutterMacOS' from project 'Pods')
Here's my flutter doctor output:
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-TW)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
The reason is because flutter will perform pod install when you try to run or build. So edit your post_install in Podfile like below.
The code added will force the deployment target to 10.13 when flutter executes pod install.
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
end
end
end
Full Example is below
platform :osx, '10.13'
# 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', '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)
target.build_configurations.each do |config|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
end
end
end
A more robust solution than the answer above is this:
post_install do |installer|
# Ensure pods also use the minimum deployment target set above
# https://stackoverflow.com/a/64385584/436422
puts 'Determining pod project minimum deployment target'
pods_project = installer.pods_project
deployment_target_key = 'MACOSX_DEPLOYMENT_TARGET'
deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
minimum_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }
puts 'Minimal deployment target is ' + minimum_deployment_target
puts 'Setting each pod deployment target to ' + minimum_deployment_target
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings[deployment_target_key] = minimum_deployment_target
end
end
end
Based on this answer to a similar question for iOS.

Pod install fails for Flutters video_editor example

I am able to clone and run flutter video_editor https://github.com/seel-channel/video_editor
in both the iPhone and Android
.
However, if I copy its example part, it works in Android but not on iPhone (physical). Ipod install fails. Please see attached screenhsot.
I am using all the same versions of everything, for the example part as well as the clone part.
Podfile
platform :ios, '9.3'
pubsec.yaml
video_editor:
path: ^1.8.0
helpers: ^1.1.1
image_picker: ^0.8.4
video_player: ^2.2.6
macOS Monterey
version 12.1
xCode version 13.1
It's work for me.
I download example from video editor.
Then in pubspec.yaml file I changed following
# video_editor:
# path: ../
video_editor: ^1.2.2
Then I fire command flutter pub get and pod install it's getting same error you want.
Then after I change platform :ios, '9.3' to platform :ios, '12.1' in pod file and changed deployment info 9.0 to 12.1 in target(Like below image) then fire commane pod install and it's work fine.

Setting iOS Version for React Native app and iOS Simulator

I'm completely confused about targeting a particular version of iOS in my React Native app and the simulator version.
The simulator version is showing iPhone 12 - iOS 14.4 even though when I go to XCode -> Preferences -> Components, I see iOS 13.7 Simulator -- see below:
And when I try to launch the app, even though it succeeds building the app, I get the following warning and as soon as my app launches, it crashes. Here's the warning:
The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range supported deployment target versions is 9.0 to 14.4.99. (in target 'boost-for-react-native' from project 'Pods')
Here's my Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'myapp' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'myappTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'myapp-tvOS' do
# Pods for myapp-tvOS
target 'ingridtm-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Anyone can tell me what I'm doing wrong here and how to get these versions right?
P.S. I'm on a MacOS Catalina Version 10.15.7 and the XCode version is 12.4. Thanks
This picture indicates that you have iOS 13.7 Simulator installed, so you can run your app on iOS 13.7 Simulator. At the same time, Xcode always has the latest iOS version installed. So in your case, Xcode 12.4 is shipped with iOS 14.4. Therefore, it means that you can run your app on iOS 13.7 and iOS 14.4 simulators.
For the warning, check out this answer

Flutter app on Xcode won't launch after upgrade

I have an app made in Flutter and since the latest version of Xcode absolutely nothing works as before.
I have been struggling with this problem for nearly a week now and the errors vary depending on the hour.
The main problem is that when distributing the application to Apple for review, they reject it with the following message:
2.1 Performance: App Completeness Guideline
2.1 - Performance - App Completeness
We discovered one or more bugs in your app when reviewed on iPad
running iOS 14.0 on Wi-Fi.
Specifically, we were still unable to login through Sign in with Apple
I find this strange as all my previous uploads got verified without any problems.
So to rectify this issue I'm trying to run the app through the simulator as I don't own an iPad.
And here is where the problems start.
Side note: Running on a physical iPhone works without problems and I'm opening the project runner.xcworkspace, not the runner.xccodeproj.
The main problem is that Xcode won't find any libraries, starting with the first one:
GeneratedPluginRegistrant.m:10:9: Module 'apple_sign_in' not found
I have tried every solution related to this issue but to no avail.
Remove the pod files, pod install,
pod deintegrate, pod init, pod install
flutter build ios --release, flutter run
Ive tried removing my project and cloning it for a fresh start
Sometimes not even a boilerplate app will work
I have checked github posts like https://github.com/flutter/flutter/issues/53573 and https://github.com/flutter/flutter/issues/33423 with no luck.
...checked countless threads.
Flutter doctor and pod-file below:
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021,
locale en-ES)
• Flutter version 1.20.4 at /Users/peter/flutter
• Framework revision fba99f6cf9 (11 days ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.1)
• Android SDK at /Users/peter/Library/Android/sdk
• Platform android-30, build-tools 30.0.1
• Java binary at:
/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
• CocoaPods version 1.9.3
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
[!] IntelliJ IDEA Community Edition (version 2017.2.5)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• iPhone 11 (mobile) • F1B8AE15-9028-4E0D-BD9D-2F2C7CC93ECE • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
! Doctor found issues in 2 categories.
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 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|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'YES'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
There are problems with Flutter 1.20.4 and XCode12/iOS14.
You need to update Flutter to the current beta (1.22.0-12.3.pre) which contains a lot of fixes for the new iOS/XCode versions.
See https://flutter.dev/docs/development/ios-14
Edit 10/01/2020:
Flutter 1.22.0 has been released to stable and should work with XCode 12 and iOS 14 out of the box.
It might be a problem with the iOS Simulator.
Check out this forum.
You might want to reply to them pointing out this issue from the forum, seems to have worked for others.
Try to allow the module in xcode to see if it finds apple_sign_in
Open Xcode select Runner > Signing % Capabilities > +Capabilities > Select Apple_Sign_In
Xcode screenshot

Your Xcode project requires migration

My project ios build fails after Xcode updating to 11.4.
steps from the manual (https://flutter.dev/docs/development/ios-project-migration) have already been made by flutter automatically(?) - everything written there has been done.
MacBook-Pro-ddd:my_awesome_project dm$ flutter clean
Cleaning Xcode workspace... 2,9s
Deleting build... 1ms
Deleting .dart_tool... 2ms
Deleting Generated.xcconfig... 0ms
Deleting flutter_export_environment.sh... 0ms
Deleting App.framework... 3ms
MacBook-Pro-ddd:my_awesome_project dm$ flutter build ios
Building ru.ddd.awesomeProject for device (ios-release)...
Your Xcode project requires migration. See https://flutter.dev/docs/development/ios-project-migration for details.
MacBook-Pro-ddd:my_awesome_project dm$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.0, on Mac OS X 10.15.4 19E287, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.6)
[!] IntelliJ IDEA Ultimate Edition (version 2020.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.44.2)
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
MacBook-Pro-ddd:my_awesome_project dm$
After following the official guides, Like #iluvatar_GR suggests delete App.Framework in addition also delete Flutter.framework from the Frameworks directory.
Run flutter clean and try running.
If there are any other errors other than project requires migration you might want to run rm -rf ios/Pods and try again.

Resources