仅将 pods 的子集用于子目标

Only use subset of pods for child target

有没有办法仅将 pods 的子集用于应用的子目标(例如我的应用的共享扩展)

我试过这样做:

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

然而,当我尝试构建我的应用程序时,似乎所有 pods 都用于共享扩展,这会导致崩溃,因为一些 pods 使用 [UIApplication sharedApplication],这在共享扩展

您必须在分配第二个目标之前结束一个目标的实例。

请用以下代码替换上面的代码:

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