SolvedCocoaPods Podfile without use_frameworks! triggers "deployment target" warnings in Xcode 10

djbe
251

Report

What did you do?

bundle exec pod install

What did you expect to happen?

Install pods correctly, with no warnings in the Xcode project.

What happened instead?

Xcode shows a bunch of warnings when building:

warning: The iOS Simulator deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'Fabric')
warning: The iOS Simulator deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'Crashlytics')
warning: The iOS Simulator deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'FSCalendar')
warning: The iOS Simulator deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'SwiftTryCatch')
warning: The iOS Simulator deployment target is set to 4.3, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'Sourcery')
warning: The iOS Simulator deployment target is set to 4.3, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'OneSignal')
warning: The iOS Simulator deployment target is set to 4.3, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'SwiftGen')
warning: The iOS Simulator deployment target is set to 4.3, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'LocalizableCheck')
warning: The iOS Simulator deployment target is set to 4.3, but the range of supported deployment target versions for this platform is 8.0 to 12.0. (in target 'SwiftLint')

These warnings do not appear when using the use_frameworks! flag in the Podfile. It's only when I remove it (and pod install), that I start getting these warnings.

CocoaPods Environment

Stack

   CocoaPods : 1.6.0.beta.1
        Ruby : ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
    RubyGems : 2.6.13
        Host : Mac OS X 10.13.6 (17G65)
       Xcode : 9.4.1 (9F2000)
         Git : git version 2.15.2 (Apple Git-101.1)
Ruby lib dir : /Users/davidjennes/.rbenv/versions/2.4.2/lib
Repositories : bitbucket-appwise-podspecs - git@bitbucket.org:appwise/appwise-podspecs.git @ 7695d3238f55b0574fc2fdf6f2e1d324a31a6465
               master - https://github.com/CocoaPods/Specs.git @ d53e8527c3736bf23269687d9a3a6752f84b28f6

Installation Source

Executable Path: /Users/davidjennes/.rbenv/versions/2.4.2/bin/pod

Plugins

cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0

Podfile

platform :ios, '10.0'

inhibit_all_warnings!

target 'Student App' do
	project 'Student App',
		'Development - Debug' => :debug,
		'Development - Release' => :release,
		'Staging - Debug' => :debug,
		'Staging - Release' => :release,
		'Production - Debug' => :debug,
		'Production - Release' => :release

	pod 'AppwiseCore'
	pod 'AppwiseCore/CoreData'
	pod 'AppwiseCore/DeepLink'
	pod 'AppwiseCore/UI'

	# Tools
	pod 'LocalizableCheck'
	pod 'Sourcery'
	pod 'SwiftGen'
	pod 'SwiftLint'

	# Other
	pod 'BonMot'
	pod 'CompoundFetchedResultsController'
	pod 'Crashlytics'
	pod 'FetchedDataSource'
	pod 'FSCalendar', :modular_headers => true
	pod 'IQKeyboardManagerSwift'
	pod 'Nuke'
	pod 'Nuke-Alamofire-Plugin'
	pod 'OneSignal'
	pod 'p2.OAuth2'
	pod 'Reusable'
	pod 'SnapKit'

	# Temp fix
	pod 'SwiftTryCatch', :modular_headers => true
end

post_install do | installer |
	require 'fileutils'

	# generate acknowledgements
	FileUtils.cp_r('Pods/Target Support Files/Pods-Student App/Pods-Student App-acknowledgements.plist', 'Application/Resources/Settings.bundle/Acknowledgements.plist', :remove_destination => true)
end

Project that demonstrates the issue

None that I can share.

Note: the only slightly related issue I can find is #6038, but that's for the podspec side, not the Podfile side (I think?).

30 Answers

✔️Accepted Answer

For those wanting a quick fix:

post_install do |installer|
  installer.generated_projects.each do |project|
    project.build_configurations.each do |config|
        if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
        end
    end
    project.targets.each do |target|
      target.build_configurations.each do |config|
        if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
        end
      end
    end
  end
end

edit: updated snippet now supports the new generate_multiple_pod_projects option
edit2: Now supports Xcode 11.1

Other Answers:

I use this fix. It respects Podfile platform setting. The idea is simple: set deployment target of the Pods project to all the pods. This should always be correct to my mind.

platform :ios, '9.3'

    post_install do |installer|

    puts 'Determining pod project minimal deployment target'

    pods_project = installer.pods_project
    deployment_target_key = 'IPHONEOS_DEPLOYMENT_TARGET'
    deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
    minimal_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }

    puts 'Minimal deployment target is ' + minimal_deployment_target
    puts 'Setting each pod deployment target to ' + minimal_deployment_target
    
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings[deployment_target_key] = minimal_deployment_target
        end
    end
end

More Issues: