Xcode 12 deployment target warnings when using CocoaPods - xcode

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

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.

Swift Package Manager and Cocoapods together: Compiler errors in Swift Package after Cocoapod Pod addition

I am developing an iOS app using the ParseSwift SDK. When I set up my project I added ParseSwift via the Swift Package Manager, which worked like a charm. Server connection and saving and querying for data on the server all works and my app compiles in its current state.
To add online meeting capabilities I have been trying to add the JitsiMeet iOS SDK.
After trying to add it via Swift Package Manager, I read on the Jitsi forum that the preferred way of adding it to an existing project is via Cocoapods, and there are currently no plans of supporting the Swift Package Manager. After finding several questions about interoperability of SPM and Cocoapods here I was hoping it would be smooth sailing.
After some back and forth to make Cocoapods work with my M1, I then tried several different Podfile variants to successfully add the JitsiMeetSDK Pod to my project. These variants include:
adding or leaving out the platform part so it is assigned by Cocoapods
adding or leaving out use_frameworks!
installing with or without the post_install block (which is taken from the Jitsi documentation)
This is my Podfile:
platform :ios, '15.0'
target 'MyApp' do
use_frameworks!
pod 'JitsiMeetSDK'
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 short version is: this does not work. My app doesn't compile anymore.
Here is the strange part: while Cocoapods successfully adds the JitsiMeetSDK Pod, when I open the .xcworkspace file and try to compile it I now get tons of compiler warnings for the ParseSwift package that I added via the Swift Package Manager. These errors all concern Concurrency or features only available in iOS 15 - which should not be a problem, since I set the platform to ios, '15.0' in my Podfile.
The ParseSwift files are also annotated and do have checks for Concurrency, which is why I understand this error even less. (screenshots of compiler errors and annotations below)
Is there an order that I have to follow when it comes to adding packages (first Cocoapods, then SPM)? Or any App settings I need to change now that two package managers are in the mix? Any help is appreciated!
I am using
Xcode 13.1
Swift version 5.5.1 (arm64)
Cocoapods 1.11.2 (installed via Home-brew for M1 support)
ParseSwift SDK 2.5.0 (via SPM)
JitsiMeet SDK 4.0.0 (via Cocoapods)
Here is a screenshot of the error messages (one example of almost 300 such cases):
So, I used your Podfile with a new project and ended up with the exact same result.
Then I tried first run Cocoapods for JitsiMeetSDK, then adding the ParseSwift with SPM. Same result.
The only way I was able to make it work was by having Cocoapods install both ParseSwift and JitsiMeetSDK.
platform :ios, '15.0'
target 'TestPackageManagers (iOS)' do
use_frameworks!
pod 'JitsiMeetSDK'
pod 'ParseSwift'
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
pod install ran like a charm and I was able to compile and run everything.
You mentioned you are using ParseSwift SDK 2.5.0 in Xcode 13.1. This isn't possible.
Xcode made changes related to backwards compatibility in Xcode 13.2+.
You can resolve everything easily by upgrading to Xcode 13.2+. If you look at the release notes for ParseSwift it says specifically:
Requires Xcode 13.2 or above to use async/await. Not compatible with Xcode 13.0/1, will need to upgrade to 13.2+. Still works with Xcode 11/12
Basically, ParseSwift 2.4.0+ requires Xcode 13.2+. If you want to use Xcode 13.1 or lower, you need to use ParseSwift 2.3.1 or lower. More info can be found in the PR that made the change.
You will face this same issue with any dependency that adds the async/await backwards compatibility for iOS13, so it's recommended to upgrade to Xcode 13.2+ sooner than later.
In addition, the problem isn't related to a mix of SPM and Cocoapods, these dependency managers have nothing to do with each other and you shouldn't have any issues using ParseSwift through SPM along with others in Cocoapods.
The described Concurrency errors were due to updating the ParseSwift package dependencies without updating Xcode to 13.2+ as #CoreyB pointed out.
Xcode 13.2 introduced other, unrelated bugs to my project but solved the Concurrency issue. The bugs were an Xcode 13.2 issue, and updating to Xcode 13.2.1 fixed these bugs.
After the update, I was able to add JitsiMeetSDK via Cocoapods to my existing project.
Thanks to #CoreyB and #Alex Kusmenkovsky for their helpful input!

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

Kingfisher Swift Compiler error when Archiving

I'm using xCode 13 beta 4 and want to archive my project containing Kingfisher.
The app runs fine under iOS 15, however I get the following errors when I look to archive it. Anyone with an idea what I should do? Thanks!
If you are using Xcode 13, here is a workaround.
If you need to use Xcode 13 but cannot upgrade to v7, use the version6-xcode13 branch. However, you have to drop iOS 10 support due to an Xcode 13 bug.
pod 'Kingfisher', :git => 'https://github.com/onevcat/Kingfisher.git', :branch => 'version6-xcode13'
Having Xcode 13 upgrade, after pod update, I start getting the same issue as you, after a workaround, I found two ways:
Downgrade Kingfisher to 5.x like:
pod 'Kingfisher', '~>5.15.7'
OR
In Deployment Info, upgrade your iOS support version to 12.0
Waiting for any fix from Kingfisher, I opted for downgrading to 5.x
Using Kingfisher 7.0.0 beta version should solve it.
E.g. pod 'Kingfisher', '~> 7.0'
This script worked for me on Xcode 13
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end

Android Studio, Xcode, Cocopods

Im new to app development so forgive me if this is a trivial question.
I am trying to build a Flutter application in Android Studios using Xcode simulator as my IOS emulator. When I run main.dart on my application i get the following error in Android Studios console. error message in console
I have tried a variety of fixes but am unsure of any answers.
Delete Podfile and run pod init then pod install
If anyone could shed some light on what is actually wrong with my issue that would be terrific.
Add/ change this at the bottom of your Podfile (located at ios/Podfile)
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
Actually the problem is with deployment target. You can change this as following:
Change it to 8.0. If 8.0 is not available then try with other iPhone simulator with a higher iOS version.
And please read your error fully, it mentions about the deployment target.

Resources