Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set deployment target for CocoaPods's pod

I use CocoaPods to manage dependencies in my project. I've written Podfile:

target 'MyApp' do   platform :ios, '8.0'   # Uncomment this line if you're using Swift or would like to use dynamic frameworks   #use_frameworks!    # Pods for MyApp   pod 'KeepLayout', :git => 'https://github.com/iMartinKiss/KeepLayout', :tag => 'v1.6.0'   pod 'EasyMapping'    target 'MyAppTests' do     inherit! :search_paths     # Pods for testing   end    target 'MyAppUITests' do     inherit! :search_paths     # Pods for testing   end  end 

This file works well with CocoaPods 0.x but I can't compile project after I've updated to CocoaPods 1.0. After I've run

pod update  

I can't compile my project with error:

/Users/<...>/Pods/KeepLayout/Sources/KeepAttribute.m:195:1: Cannot synthesize weak property because the current deployment target does not support weak references

I've seen that every library is builded with different deployment target. For example KeepLayout is builded with 4.3 deployment target.

How I can determine build target for every pod dependency?

like image 357
Andrew Romanov Avatar asked May 11 '16 11:05

Andrew Romanov


People also ask

How do I set a target deployment?

Navigate to Infrastructure ➜ Deployment Targets and click ADD DEPLOYMENT TARGET. Select the type of deployment target you are adding. Select the type of connection your deployment target will make, and follow the on-screen instructions.

How do I set a deployment target in iOS?

Deployment Target refers to the oldest version of iOS that is capable of running your project. To change your deployment target, open up your project file in Xcode and check the setting under Build Settings -> Deployment(...) Check this answer to add earlier devices support.

How do I specify iOS in POD file?

<Specifying pod versions Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number. Besides no version, or a specific one, it is also possible to use logical operators: '> 0.1' Any version higher than 0.1. '>= 0.1' Version 0.1 and any higher version.

What is a deploy target?

Last updated in 5 hours. Deployment targets are what Octopus Deploy deploys to. They can be Windows servers, Linux servers, Kubernetes (K8s) clusters, Azure Web Apps, and more. Environments are how you organize your deployment targets into groups that represent different stages of your deployment pipeline.


1 Answers

While some development versions of CocoaPods (as well as pre-1.0 versions) may have propagated the deployment target of the project down to the pods, this is no longer the case in 1.0. To work around this, the current developer recommends using a post-install hook.

Here's a brute force approach to force a hard-coded deployment target for every pod in the generated Pods project. Paste this at the end of your Podfile:

post_install do |installer|   installer.pods_project.targets.each do |target|     target.build_configurations.each do |config|       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.2'     end   end end 
like image 131
Alex Nauda Avatar answered Sep 20 '22 07:09

Alex Nauda