Import module only if iOS 11 is available - ios

I want to import a module from CocoaPods in my project which has the minimum deployment target set to iOS 9.0.
In my Podfile, I set the minimum deployment target for that specific framework to iOS 11 like this:
#CoreML
platform :ios, '11.0'
pod 'xxx', '1.0.0'
so that it would allow me to pod install.
The problem is when I import it in my file, I receive the following error:
Module file's minimum deployment target is ios11.0 v11.0.
How should I import it only if iOS 11 is available? I tried using
if #available(iOS 11, *) { ... }
and #available(iOS 11), but with no luck.

Podfiles don‘t support Pod-specific deployment targets. You can set a deployment target for all Pods and the resulting aggregate target like you did with platform :ios, 'x.y'
You could set a Pod-specific deployment target in the Podspec of your Lib: spec.ios.deployment_target = '11.0' -> But that wouldn’t help in your case.
It makes no sense to use a higher deployment target in your Podfile (11.0) than in your Project (9.0). These values should always be equal.
Solution: set platform :ios, '9.0' in your Podfile and conditionally import / use your 11.0-only Lib with #available and #available. You may also need to optionally link your lib under "Link with Libraries", see Apple Doc
If this doesn’t work for you, please share more information (full Podfile, Xcode & Cocoapods Version, Podspec of the Lib)

Related

Why is Xcode pods project saying the supported platform is for Mac when the podfile states iOS?

I've got a pod file like so:
platform :ios, '11.0'
workspace 'MyWorkspace'
target 'MyTarget' do
various pods
When I look at the pods project in the workspace it looks like this:
If I click on the individual pod targets, each one says the supported platform is iOS, so why does the pod project say the supported platform is macOS? Will it cause problems, should I change it and the base SDK to be iOS?

Minimum iOS deployment version of flutter package

I have written a flutter package for local use and I am trying to get the minimum deployment version working so that no devices < 11.0 can use it.
I have set the following in the library using xcode (never sure whether to use xCode or edit the files manually)
And also have edited the libraries ios/<LIBRARY_NAME>.podspec file manually to have the following
s.dependency 'Flutter'
s.platform = :ios, '11.0'
s.ios.deployment_target = '11.0'
When i ran pod install (also tried pub get) in the IOS directory of an app using the library it prints the following
[!] The platform of the target `Runner` (iOS 9.0) may not be compatible with `<LIBRARY_NAME> (x.x.x)` which has a minimum requirement of iOS 11.0.
And I have also set the app to have ios 9.0 (which should error) in the ios/Podfile
e.g.
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
When I run the app builds, installs and runs fine. I have also tried cleaning the pod cache in between pod installs.
Can somebody explain what I have done wrong or am missing, trial and error isn't really working when the builds are like 5-10 minutes :(
Also I don't really understand what s.platform = :ios, '11.0' is setting in the iOS podspec when there is also deployment_target?
Thanks
Change 9.0 to 11.0 in your pod file.
platform :ios, '11.0'

Specs satisfying the `ParseFacebookUtils` dependency were found, but they required a higher minimum deployment target

enter image description herewhen I am installing pod file for latest parse sdk by using the below syntax in podfile:
pod 'Parse'
pod 'Facebook-iOS-SDK'
pod 'ParseFacebookUtils'
pod 'ParseFacebookUtils'
pod 'ParseFacebookUtilsV4'
Getting error like ld: library not found for -lPods
Please help me.
Your podfile should have platform same as set in your Project target->General-> Deployment Info.
Like if deployment info is set to be 9.0, then add the line to your podfile.
platform :ios, '9.0'
This problem could happen in the latest React Native 0.63, which I had just experienced. RN 0.63 required iOS 10 or higher. The solution is just platform :ios in Podfile to 10 or higher.
I was running into this same issue, make sure that every Deployment Target in your project is at least 8.1 for every Project and Target.
This includes Pods > Build Settings > iOS Deployment Target, all Targets there, and your main Project and Targets.

watchOS 2 working with CocoaPods

Has anyone gotten CocoaPods working with watchOS 2? I tried using ‘use_framework!’ with ‘platform :watchos, ‘2.0’ but it says "[!] Invalid Podfile file: Unsupported platform watchos2. Platform must be :ios or :osx.. Updating CocoaPods might fix the issue.”
I am on the latest version of CocoaPods.
CocoaPods released new version which is 0.38.0 and now supports watchOS 2.
http://blog.cocoapods.org/CocoaPods-0.38/
According to the blog above, deployment target can be set to watchOS 2 in Podspec.
Pod::Spec.new do |s|
# …
s.watchos.deployment_target = '2.0'
end
You can set target for watchOS 2 in Podfile with the version.
However, library has to set the deployment target explicitly, so you need to check whether it's supported for each library in Podspec.
The latest version of CocoaPods supports this.
If you just need to get a pod working on watchOS 2 (e.g. Parse), the you can simply use a Podfile such as this:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'MyApp' do
end
target 'MyApp WatchKit App' do
end
target 'MyApp WatchKit Extension' do
platform :watchos, '2.0'
pod 'Parse', '~> 1.11'
end
If however, you need to use the pod in multiple targets of different platforms (e.g. iOS and watchOS 2), things are slightly tricker. See this answer for more information.
CocoaPods currently doesn't support watchos. There is a work in progress issue here for adding support for it.

How to ignore the Base SDK for a single pod

For an iOS project that requires iOS 5.1 I want to include an Pod that requires at least iOS 6.0 (ARChromeActivity). When I'm trying to install this Pod I only get the message:
[!] The platform of the target `Pods` (iOS 5.1) is not compatible with `ARChromeActivity (1.0.0)` which has a minimum requirement of iOS 6.0.
How can I include this Pod in my project anyway and ignore the base SDK for this single Pod?
Disclaimer: The purpose of the podspec's platform attribute is to make sure the library isn't installed with a version of the OS it has not been tested on by its maintainers. That being said, in your Podfile you can simple change the platform requirements to what you want to emulate for example,
platform :ios, '6.0'
Obviously that is for all your pods not just a single one but you can see why that feature doesn't exist. In the newer versions of CocoaPods you actually don't need that line at all and it will detect your target version from your project, obviously since you're trying to use code that's not meant for the version you're using that wouldn't help you but it's typically quite useful.
Edit:
Alternatively you can edit the spec's source directly. In this case open ~/.cocoapods/master/ARChromeActivity/1.0.0/ARChromeActivity.podspec in some editor and change:
s.platform = :ios, '6.0'
to
s.platform = :ios, '5.0'
Then run pod install
The correct thing to do would be not to change s.platform in the Podspec but to fix the s.io.deployment target:
s.ios.deployment_target = '5.0'

Resources