Cocoapods“OTHER_LDFLAGS”因-all_load而重复符号

时间:2015-08-07 04:47:52

标签: ios objective-c xcode cocoapods linker-errors

我的应用程序使用的供应商 - 静态库不喜欢“-all_load”链接器标志。如果我使用它会抛出重复的错误。

我现在遇到的问题是我还需要使用新的盒子sdk。 SDK的podspec具有以下内容。

s.xcconfig = { "OTHER_LDFLAGS" => "-ObjC -all_load" }

因此,构建失败,并在供应商库中出现重复符号。

我在网上看到,我只能在需要-force_load的库上使用-ObjC -all_load来避免陷入这种情况。我无法将其用作解决方案,因为我无法控制BOX podspec

有没有办法可以覆盖我的应用中的任何一个;我真的很感激任何帮助。

1 个答案:

答案 0 :(得分:0)

经过几个小时的斗争,我想到了如何完成这项工作。在此发布,以便它可以帮助遇到类似问题的人。我将下面的post_install挂钩添加到Podfile中,并且它可以工作!!

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            if target.name == "Pods"
                xcconfig_path = config.base_configuration_reference.real_path
                xcconfig = File.read(xcconfig_path)
                new_xcconfig = xcconfig.gsub("-ObjC -all_load",'-force_load $(BUILT_PRODUCTS_DIR)/libPods-box-ios-sdk.a')
                File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
            end
        end
    end
end
相关问题