samedi 18 juin 2016

Cocoapods issue with app extension


I have been using cocoapods for this project for more than an year. This app has App Extension.

The Podfile I have been using was like this:

source 'https://github.com/CocoaPods/Specs.git'

target 'MyTarget', :exclusive => false do
platform :ios, '8.0'
  pod 'Reachability', '~> 3.2'
  pod 'AFNetworking', '~> 2.5'
  pod 'OpenSSL-Classic', '1.0.1.j'
  pod 'CargoBay', '~> 2.1'
  pod 'TWMessageBarManager', '~> 1.7'
  pod 'OHAlertView', '~> 3.0'
  pod 'IIShortNotificationPresenter', '~> 1.2'
  pod 'OAStackView', '~> 1.0'
  pod 'RWBlurPopover', '~> 3.1'
  pod 'AQSPermissionsLib', '~> 0.2'
end

target 'MyTargetAppExtension', :exclusive => false do
platform :ios, '8.0'
pod 'Reachability', '~> 3.2'
pod 'OpenSSL-Classic', '1.0.1.j'
pod 'CargoBay', '~> 2.1'
end

That was working perfectly.

Today I have decided to update cocoapods. Then I was forced to change the Podfile to a new format, because cocoapods was whining about deprecations on the Podfile syntax.

The Podfile is now like this:

source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
use_frameworks!


target 'MyTarget' do
  pod 'Reachability', '~> 3.2'
  pod 'AFNetworking', '~> 2.5'
  pod 'OpenSSL-Classic', '1.0.1.j'
  pod 'CargoBay', '~> 2.1'
  pod 'TWMessageBarManager', '~> 1.7'
  pod 'OHAlertView', '~> 3.0'
  pod 'IIShortNotificationPresenter', '~> 1.2'
  pod 'OAStackView', '~> 1.0'
  pod 'RWBlurPopover', '~> 3.1'
  pod 'AQSPermissionsLib', '~> 0.2'
end

target 'MyTargetAppExtension' do
  inherit! :search_paths
  pod 'Reachability', '~> 3.2'
  pod 'OpenSSL-Classic', '1.0.1.j'
  pod 'CargoBay', '~> 2.1'
end

That installs without issues but when I try to compile the project I see dozens of errors like this

/Pods/OHAlertView/OHAlertView/OHAlertView.m:221:94: 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

pointing to lines like this

UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow] ?: [[[UIApplication sharedApplication] windows] lastObject];

enter image description here

That in a nutshell is Xcode complaining that UIKit is being used by the App Extension target.

Apparently this new version of cocoapods is including all the pods in the App Extension target.

How do I solve that?

NOTE: I don't want to disable the warning. I want the pods that are not supposed to be integrated to the app extension targets not to be.


Aucun commentaire:

Enregistrer un commentaire