0

Is there a way to only use a subset of pods for a child target of an app (e.g. a share extension of my app)

I tried doing it this way:

platform :ios, '8.0'
inhibit_all_warnings!
I18n.enforce_available_locales = false

def all_pods
    pod 'AFNetworking', '~> 2.3'
    pod 'AFNetworkActivityLogger', '~> 2.0.2'
    pod 'TPKeyboardAvoiding', '~> 1.2.3'
    pod 'SMPageControl', '~> 1.2'
    pod 'MLPAutoCompleteTextField', :git => 'https://github.com/EddyBorja/MLPAutoCompleteTextField.git', :branch => 'master'
    pod 'UIImage-Resize', '~> 1.0.1'
    pod 'M13BadgeView', '~> 1.0.0'
    pod 'CWStatusBarNotification', '~> 2.3.3'
end

target 'Lohi Connect' do
    all_pods
    target 'Lohi Connect Share' do
       pod 'MLPAutoCompleteTextField', :git => 'https://github.com/EddyBorja/MLPAutoCompleteTextField.git', :branch => 'master'
    end
end

however when I try to build my app it appears that all pods are used for the share extension which leads to crashes because some pods use [UIApplication sharedApplication] which is not available in share extension

Max90
  • 193
  • 2
  • 14

1 Answers1

1

You have to end the instance of one target before assigning the second target.

please replace above code by the following:

platform :ios, '8.0'
inhibit_all_warnings!
I18n.enforce_available_locales = false

def all_pods
    pod 'AFNetworking', '~> 2.3'
    pod 'AFNetworkActivityLogger', '~> 2.0.2'
    pod 'TPKeyboardAvoiding', '~> 1.2.3'
    pod 'SMPageControl', '~> 1.2'
    pod 'MLPAutoCompleteTextField', :git => 'https://github.com/EddyBorja/MLPAutoCompleteTextField.git', :branch => 'master'
    pod 'UIImage-Resize', '~> 1.0.1'
    pod 'M13BadgeView', '~> 1.0.0'
    pod 'CWStatusBarNotification', '~> 2.3.3'
end

target 'Lohi Connect' do
    all_pods
end
target 'Lohi Connect Share' do
       pod 'MLPAutoCompleteTextField', :git => 'https://github.com/EddyBorja/MLPAutoCompleteTextField.git', :branch => 'master'
end
ketaki Damale
  • 634
  • 7
  • 25
  • that's what I tried myself first, but that gives me the error: ``Error:linker command failed with exit code 1 (use -v to see invocation)`` – Max90 Apr 23 '18 at 11:47
  • @Max90 Check the whole error message the classes impacted. You might have used a class of "Lohi Connect" that use one of the others pods in "Lohi Connect Share". Separe them. – Larme Apr 24 '18 at 08:54