0

有没有办法只将 pod 的一个子集用于应用程序的子目标(例如我的应用程序的共享扩展)

我试过这样做:

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

但是,当我尝试构建我的应用程序时,似乎所有 pod 都用于共享扩展,这会导致崩溃,因为某些 pod 使用[UIApplication sharedApplication]了共享扩展中不可用的

4

1 回答 1

1

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

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

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
于 2018-04-23T11:44:54.540 回答