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
网友评论