iOS 解决swift使用OC静态库找不到module

pod 生成 modulemap
方式一:利用pod的preinstall:

pre_install do |installer|
#获取 Pods 下公开头文件目录
    headers_path = "#{Dir::pwd}/Pods/your framework path/Headers"
    modulemap_path = "#{Dir::pwd}/Pods/your modulemap path"
    generate_umbrella('your framework name', headers_path)
   generate_modulemap('your framework name', modulemap_path)
end

生成modulemap

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

生成umbrella.h

def generate_umbrella(name, path)
  f = File.new(File.join("#{path}/#{name}_umbrella.h"), "w+")
  f.puts("#import <Foundation/Foundation.h>")
  Dir.foreach(path) do |filename|
    if filename != "." and filename != ".."
      f.puts("#import \"#{filename}\"")
    end
  end
end
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容