Class 在多个地方实施

Class implemented in multiple places

我在 iOS 应用程序中通过 Cocoapods 使用 Twitter API。它在应用程序、框架和应用程序扩展中使用。项目构建没有错误,但在运行时,我收到此消息:

objc[27031]: Class TWTRScribeService is implemented in both ~/Library/Developer/Xcode/DerivedData/TweetSave-cydxfgkrgtggufefrpvocnxaxelr/Build/Products/Debug-iphonesimulator/SaveKit.framework/SaveKit and ~/Library/Developer/CoreSimulator/Devices/3630AFBE-7C59-4574-8F44-9592A12DEF82/data/Containers/Bundle/Application/D7A8F9C8-A39A-46DD-B737-A656415488F0/TweetSave.app/TweetSave. One of the two will be used. Which one is undefined.

TwitterKit 框架中的很多 类 重复了很多次。

这是我的 Podfile:

def twitterkit_pods
    pod 'TwitterKit'
    pod 'TwitterCore'
end

target 'TweetSave' do
    pod 'Fabric'
    twitterkit_pods 
end

target 'SaveKit' do
    twitterkit_pods
end

target 'Saver' do
    twitterkit_pods
end

TweetSave 是应用目标,SaveKit 是我的框架,Saver 是一个应用扩展。

这条消息是什么意思,我该如何预防?

您已将相同的 link 静态 类 编辑到应用程序和框架中,而运行时 link 用户对使用哪一个感到困惑。它会自行决定使用哪个并警告您这一事实。

我认为解决这个问题的唯一方法是动态 link TwitterLink.framework,如果可能的话,但是由于它是为在 iOS 应用程序中工作而设计的,它可能是一个静态框架.因此,我看不出有什么容易解决这个问题的。

如果应用程序在 SaveKit 框架中链接,就像它看起来的那样,那么它将以这种方式获取所有 类,并且您可以从应用程序中删除 twitterkit_pods目标。