Skip to content

Commit

Permalink
fix: 1. 库名称中含有中划线导致头文件找不到的问题修复 2. 完善modulemap生成
Browse files Browse the repository at this point in the history
  • Loading branch information
dabing1022 committed Jan 12, 2021
1 parent e05c950 commit af9fab4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
23 changes: 17 additions & 6 deletions cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,30 @@ def Utils.is_framework(spec)
return Utils.is_swift_module(spec)
end

def Utils.spec_header_dir(spec)
spec_header_dir = "./Headers/Public/#{spec.name}"

unless File.exist?(spec_header_dir)
spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
end

unless File.exist?(spec_header_dir)
# 一些库名称中使用了中划线如AAA-BBB,public header中库名称会默认处理成下划线AAA_BBB
module_name = spec.name.gsub("-", "_")
spec_header_dir = "./Pods/Headers/Public/#{module_name}"
end

spec_header_dir
end

def Utils.is_swift_module(spec)

is_framework = false
dir = File.join(CBin::Config::Builder.instance.gen_dir, CBin::Config::Builder.instance.target_name)
#auto 走这里
if File.exist?(dir)
Dir.chdir(dir) do
public_headers = Array.new
spec_header_dir = "./Headers/Public/#{spec.name}"

unless File.exist?(spec_header_dir)
spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
end
spec_header_dir = Utils.spec_header_dir(spec)
return false unless File.exist?(spec_header_dir)

is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ def copy_headers

#by slj 如果没有头文件,去 "Headers/Public"拿
# if public_headers.empty?
spec_header_dir = "./Headers/Public/#{@spec.name}"
unless File.exist?(spec_header_dir)
spec_header_dir = "./Pods/Headers/Public/#{@spec.name}"
end
spec_header_dir = CBin::Build::Utils.spec_header_dir(@spec)
raise "copy_headers #{spec_header_dir} no exist " unless File.exist?(spec_header_dir)

Dir.chdir(spec_header_dir) do
headers = Dir.glob('*.h')
headers.each do |h|
Expand Down Expand Up @@ -253,6 +251,13 @@ def copy_headers
module * { export * }
}
MAP
else
# by ChildhoodAndy
# try to read modulemap file from public header
module_map_file = File.join(spec_header_dir, "#{@spec.name}.modulemap")
if Pathname(module_map_file).exist?
module_map = File.read(module_map_file)
end
end

unless module_map.nil?
Expand Down

0 comments on commit af9fab4

Please sign in to comment.