制作cocoapods私有仓库(三)non-modular header inside framework module

当制作的私有 Framework的Header引入了Static Library的Header的时候,就会报一个non-modular header inside framework module的错误
解决方法是在podfile末尾加入,并且不使用use_framework!

def generate_modulemap(name, path)
    f = File.new(File.join("#{path}/module.modulemap"), "w+")
    module_name = "#{name}"
    while(module_name["+"])
        module_name["+"] = "_"
    end           
    f.puts("module XB#{module_name} {")
    f.puts("    umbrella header \"#{name}_umbrella.h\"")
    f.puts("    export *")
    f.puts("}")
end

def generate_umbrella(name, path) 
    f = File.new(File.join("#{path}/#{name}_umbrella.h"), "w+")
    f.puts("#import ")
    Dir.foreach(path) do |filename|
        if filename != "." and filename != ".."
            f.puts("#import \"#{filename}\"")
        end
    end
end

post_install do |installer|
    require "fileutils"
    headers_path = "#{Dir::pwd}/Pods/Headers/Public/"

    installer.pods_project.targets.each do |target|
        target_header_path = "#{headers_path}#{target.product_name}"
        if File.exist?(target_header_path)
            filename = target.product_name
            if filename != "." and filename != ".."
                generate_umbrella(filename, target_header_path)
                generate_modulemap(filename, target_header_path)
            end
        end
    end
end

感谢
让CocoaPods static library支持Module
私有Pods封装个推SDK功能(解决方案)

你可能感兴趣的:(制作cocoapods私有仓库(三)non-modular header inside framework module)