From af9fab412648f64c9bc7f4d22ff203fa9f07c20a Mon Sep 17 00:00:00 2001 From: dabing1022 Date: Tue, 12 Jan 2021 20:44:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=20=E5=BA=93=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=B8=AD=E5=90=AB=E6=9C=89=E4=B8=AD=E5=88=92=E7=BA=BF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=A4=B4=E6=96=87=E4=BB=B6=E6=89=BE=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=202.=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84modulemap=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cocoapods-imy-bin/helpers/build_utils.rb | 23 ++++++++++++++----- .../helpers/framework_builder.rb | 13 +++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb index 133ec5a..dedc660 100755 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb +++ b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb @@ -14,6 +14,22 @@ 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 @@ -21,12 +37,7 @@ def Utils.is_swift_module(spec) #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")) diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/framework_builder.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/framework_builder.rb index 25529b1..bdfc494 100755 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/framework_builder.rb +++ b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/framework_builder.rb @@ -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| @@ -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?