MACOSX_DEPLOYMENT_TARGET keeps reverting to old values - xcode

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.

Related

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 - macOS; app run but cannot archive

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.

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

Xcode 12 deployment target warnings when using CocoaPods

I get this warning on Xcode 12:
The iOS Simulator deployment target IPHONEOS_DEPLOYMENT_TARGET is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99
How to support this version?
A short working solution is here! Just copy and paste the code snippet at the end of your Podfile and run the pod install command.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
end
In this case, 12.0 is the minimum supporting iOS version for AppStore submission. You can change it based on your project requirements.
This is a problem with the target at your cocoa pods.
To me, the answer was to put this code at the end of your pod file:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
end
end
end
It resolved all my problems, compiling and archiving the project.
Another way is just to change the IPHONEOS_DEPLOYMENT_TARGETin the pods project like described in this image:
Best regards.
Update: To fix this issue you just need to update the Deployment Target to 9.0. This can be updated by opening the .xcworkspace file, choose the Pods.xcodeproj on Xcode, and updating the iOS Deployment Target to 9.0 or later as depicted in the below image.
Another easy fix is to add the following to your Podfile and running pod install on terminal in the directory.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
Previous: You can't provide support for iOS 8.0 on Xcode 12 unless you import the support files. To provide support by default you would have to use Xcode 11. It would be better to check for the number of users that use your app on iOS 8 and update the minimum supported version to iOS 9 or higher.
Flutter now requires an additional line for this to work as of late 2021.
Paste the updated code snippet below at the end of your Podfile and run pod install command.
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 10.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
end
end
end
end
Note: If you have the below code in your podfile, then replace it with the above code.
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
This is happening because support for iOS 8 has been dropped in Xcode 12 but the minimum deployment target for the offending pod is still iOS 8. This is documented in the Xcode 12 release notes:
Deprecations
Xcode now supports debugging apps and running tests on iOS devices running iOS 9.0 and above.
Workaround. You can append the following to your Podfile as a workaround for now (and then run pod install as usual):
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
This will remove the deployment target settings from all pods using iOS 8 or below, allowing them to simply inherit the project deployment target that you have specified at the top of your Podfile. For instance:
platform :ios, '10.0'
I also needed to add
s.platform = :ios, "9.0"
to my .podspec file for this to work, as well as the post_install script from any of the above (or below) answers.
Note: s.platform was
s.platform = :ios
I'm using Flutter so my steps:
delete Podfile.lock file
Change to platform :ios, '10.0'
delete Pods folder in ios folder
Goto Terminal and Pod install everything

How would I install Google Sign-In on a Swift macOS app?

When I try the normal way through Cocoapods:
# Uncomment the next line to define a global platform for your project
platform :osx, '10.13'
target '1072 Scouting' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Google/SignIn'
# Pods for scouting1072-mac
end
I get the error:
[!] The platform of the target `1072 Scouting` (macOS 10.13) is not compatible with `Google/SignIn (3.1.0)`, which does not support `osx`.
How would I install Google Sign-In so I can have similar functionality to an install on an iOS project?

Resources