Created
November 16, 2017 10:09
-
-
Save Limon-O-O/9bf134f4a79caa50ddd8f031adf143f0 to your computer and use it in GitHub Desktop.
Cocoapods Support Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <Foundation/Foundation.h>") | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
让CocoaPods static library支持Module
基于 CocoaPods 进行 iOS 开发