cocoapods-kz 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-kz/command/install.rb +7 -6
- data/lib/cocoapods-kz/command/repair.rb +2 -2
- data/lib/cocoapods-kz/command/update.rb +7 -6
- data/lib/cocoapods-kz/gem_version.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_analyzer.rb +41 -4
- data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_generator.rb +268 -0
- data/lib/cocoapods-kz/helpers/{global_helper.rb → kz_global_helper.rb} +30 -6
- data/lib/cocoapods-kz/helpers/kz_pod_target.rb +76 -22
- data/lib/cocoapods-kz/helpers/repair_dynamic_swift.rb +2 -2
- data/lib/cocoapods-kz/helpers/repair_module_import.rb +16 -25
- data/lib/cocoapods-kz/native/analyzer.rb +4 -1
- data/lib/cocoapods-kz/native/dls.rb +2 -1
- data/lib/cocoapods-kz/native/file_accessor.rb +17 -0
- data/lib/cocoapods-kz/native/installer.rb +9 -24
- data/lib/cocoapods-kz/native/pod_target.rb +17 -0
- data/lib/cocoapods-kz/native/pod_target_installer.rb +30 -0
- data/lib/cocoapods-kz/native/specification.rb +31 -0
- data/lib/cocoapods-kz/native/target.rb +34 -0
- data/lib/cocoapods-kz/native/target_installer_helper.rb +125 -0
- data/lib/cocoapods-kz/native.rb +6 -2
- data/lib/cocoapods-kz/resources/kz_merge_swift_h.rb +14 -0
- metadata +10 -8
- data/lib/cocoapods-kz/helpers/build_framework_config.rb +0 -53
- data/lib/cocoapods-kz/helpers/create_hamp.rb +0 -236
- data/lib/cocoapods-kz/helpers/strip_framework_config.rb +0 -40
- data/lib/cocoapods-kz/helpers/xml_build_config.rb +0 -57
- data/lib/cocoapods-kz/native/user_project_integrator.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7044ff9b2863844afb3101f6cd2f76a13ff40cfa6f06a7e85f546148b18abdfa
|
4
|
+
data.tar.gz: 4fa7b00baa91abeecf6f7dea4703da717639859bc99dab57a4339c9f0bf8ed87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b58f94829d314e2305bb5844241e43a8371b4af795eee5fa653d974350953cb22caca090d54e5e4e2f6930c5dc04f4cfa0c8b59e4a9c125de3b95b2ada7cb9
|
7
|
+
data.tar.gz: e1b3385d1bfefe18eeb4d6db502e3e8fdc563f23b1114205eedf3ce72b8bdd4d8e8b95b7f1995da282ddbc9b6f156a177c6c8b856c0b74d07e87c33283bc101e
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cocoapods-kz/helpers/
|
1
|
+
require 'cocoapods-kz/helpers/kz_global_helper'
|
2
2
|
require 'cocoapods-kz/gem_version'
|
3
3
|
|
4
4
|
module Pod
|
@@ -19,10 +19,10 @@ module Pod
|
|
19
19
|
['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
|
20
20
|
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
21
21
|
'applies to projects that have enabled incremental installation'],
|
22
|
-
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
23
|
-
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
22
|
+
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
|
+
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
-
['--no-framework-update', "
|
25
|
+
['--no-framework-update', "build后不再生成frameowrk"]
|
26
26
|
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
27
27
|
end
|
28
28
|
|
@@ -31,18 +31,19 @@ module Pod
|
|
31
31
|
use_framework_tag = argv.flag?('framework')
|
32
32
|
help! if use_code_tag && use_framework_tag
|
33
33
|
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
34
|
-
if Pod.match_version?('~> 1.
|
34
|
+
if Pod.match_version?('~> 1.11')
|
35
35
|
KZ::KZGlobalHelper.instance.kz_pod_enable = true
|
36
36
|
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
37
37
|
end
|
38
38
|
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
39
|
-
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('
|
39
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
|
40
40
|
|
41
41
|
super
|
42
42
|
@additional_args = argv.remainder!
|
43
43
|
end
|
44
44
|
|
45
45
|
def run
|
46
|
+
KZ::KZGlobalHelper.instance.prepare
|
46
47
|
install = Pod::Command::Install.new(CLAide::ARGV.new([*@additional_args]))
|
47
48
|
install.validate!
|
48
49
|
install.run
|
@@ -13,8 +13,8 @@ module Pod
|
|
13
13
|
|
14
14
|
def self.options
|
15
15
|
[
|
16
|
-
['--module-import', "
|
17
|
-
['--dynamic-swift', "
|
16
|
+
['--module-import', "指定组件名(只针对开发组件),修复该组件所有文件头文件导入方式,壳工程使用“Main”,如果不指定,默认对所有开发组件进行修复"],
|
17
|
+
['--dynamic-swift', "指定组件名(只针对开发组件),将该组件中所有swift文件添加OC特性,壳工程使用“Main”,如果不指定,默认对所有开发组件进行修复"]
|
18
18
|
]
|
19
19
|
end
|
20
20
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cocoapods-kz/helpers/
|
1
|
+
require 'cocoapods-kz/helpers/kz_global_helper'
|
2
2
|
|
3
3
|
module Pod
|
4
4
|
class Command
|
@@ -19,10 +19,10 @@ module Pod
|
|
19
19
|
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
20
20
|
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
21
21
|
'applies to projects that have enabled incremental installation'],
|
22
|
-
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
23
|
-
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
22
|
+
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
|
+
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
-
['--no-framework-update', "
|
25
|
+
['--no-framework-update', "build后不再生成frameowrk"]
|
26
26
|
].concat(super)
|
27
27
|
end
|
28
28
|
|
@@ -31,18 +31,19 @@ module Pod
|
|
31
31
|
use_framework_tag = argv.flag?('framework')
|
32
32
|
help! if use_code_tag && use_framework_tag
|
33
33
|
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
34
|
-
if Pod.match_version?('~> 1.
|
34
|
+
if Pod.match_version?('~> 1.11')
|
35
35
|
KZ::KZGlobalHelper.instance.kz_pod_enable = true
|
36
36
|
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
37
37
|
end
|
38
38
|
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
39
|
-
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('
|
39
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
|
40
40
|
|
41
41
|
super
|
42
42
|
@additional_args = argv.remainder!
|
43
43
|
end
|
44
44
|
|
45
45
|
def run
|
46
|
+
KZ::KZGlobalHelper.instance.prepare
|
46
47
|
update = Pod::Command::Update.new(CLAide::ARGV.new([*@additional_args]))
|
47
48
|
update.validate!
|
48
49
|
update.run
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'kz_pod_target'
|
2
|
+
require_relative 'kz_global_helper'
|
2
3
|
|
3
4
|
module KZ
|
5
|
+
|
4
6
|
class KZAnalyzer
|
5
7
|
attr_accessor :all_kz_pod_targets
|
6
8
|
|
@@ -14,6 +16,24 @@ module KZ
|
|
14
16
|
@native_pod_targets.each { |native_pod_target|
|
15
17
|
create_kz_pod_target_from(native_pod_target, :kz_pod_origin_mode)
|
16
18
|
}
|
19
|
+
|
20
|
+
# 检测是否有product名称相同的target
|
21
|
+
temp_repeat_product_name = []
|
22
|
+
@all_kz_pod_targets.each do |name, kz_pod_target|
|
23
|
+
if temp_repeat_product_name.include?(kz_pod_target.product_name)
|
24
|
+
kz_pod_target.product_name = "#{kz_pod_target.name}.framework"
|
25
|
+
kz_pod_target.product_basename = kz_pod_target.name
|
26
|
+
result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
|
27
|
+
if result
|
28
|
+
kz_pod_target.repair_modulemap_path = result.resource_path + kz_pod_target.product_name + "Modules/module.modulemap"
|
29
|
+
else
|
30
|
+
kz_pod_target.repair_modulemap_path = "${PODS_CONFIGURATION_BUILD_DIR}/#{kz_pod_target.name}/#{kz_pod_target.product_name}/Modules/module.modulemap"
|
31
|
+
end
|
32
|
+
kz_pod_target.need_repair_module_import = true
|
33
|
+
else
|
34
|
+
temp_repeat_product_name << kz_pod_target.product_name
|
35
|
+
end
|
36
|
+
end
|
17
37
|
end
|
18
38
|
|
19
39
|
def create_kz_pod_target_from(native_pod_target, config_pod_mode)
|
@@ -47,7 +67,9 @@ module KZ
|
|
47
67
|
kz_dependent_target_info[native_dependent_target.name] = kz_dependent_pod_target if kz_dependent_pod_target
|
48
68
|
end
|
49
69
|
kz_pod_target.dependent_target_info = kz_dependent_target_info
|
50
|
-
|
70
|
+
kz_pod_config = KZGlobalHelper.instance.kz_pod_config[native_pod_target_name]
|
71
|
+
kz_pod_config = KZGlobalHelper.instance.kz_pod_config[kz_pod_target.root_name] if kz_pod_config == nil
|
72
|
+
kz_pod_target.add_kz_pod_config(kz_pod_config) do |repair_dependent_pod_target_name|
|
51
73
|
repair_native_pod_target = get_native_pod_target_with(repair_dependent_pod_target_name)
|
52
74
|
repair_kz_pod_target = nil
|
53
75
|
if repair_native_pod_target
|
@@ -76,7 +98,7 @@ module KZ
|
|
76
98
|
end
|
77
99
|
|
78
100
|
def get_real_config_pod_mode(kz_pod_target)
|
79
|
-
if
|
101
|
+
if specify_pod_names_contain(kz_pod_target.name)
|
80
102
|
return KZGlobalHelper.instance.specify_pod_mode
|
81
103
|
end
|
82
104
|
:kz_pod_origin_mode
|
@@ -84,11 +106,26 @@ module KZ
|
|
84
106
|
|
85
107
|
def get_use_config_pod_mode(kz_pod_target)
|
86
108
|
if KZGlobalHelper.instance.specify_pod_mode == :kz_pod_framework_mode
|
87
|
-
|
109
|
+
specify_pod_names_contain(kz_pod_target.name) ? :kz_pod_framework_mode : :kz_pod_code_mode
|
88
110
|
elsif KZGlobalHelper.instance.specify_pod_mode == :kz_pod_code_mode
|
89
|
-
|
111
|
+
specify_pod_names_contain(kz_pod_target.name) ? :kz_pod_code_mode : :kz_pod_framework_mode
|
90
112
|
end
|
91
113
|
end
|
92
114
|
|
115
|
+
def specify_pod_names_contain(target_name)
|
116
|
+
if KZGlobalHelper.instance.specify_pod_names.count > 0
|
117
|
+
KZGlobalHelper.instance.specify_pod_names.each do |specify_pod_name|
|
118
|
+
if specify_pod_name.end_with?("*")
|
119
|
+
_specify_pod_name = specify_pod_name.sub('*', '')
|
120
|
+
return true if target_name.start_with?(_specify_pod_name)
|
121
|
+
else
|
122
|
+
return true if specify_pod_name == target_name
|
123
|
+
end
|
124
|
+
end
|
125
|
+
false
|
126
|
+
else
|
127
|
+
true
|
128
|
+
end
|
129
|
+
end
|
93
130
|
end
|
94
131
|
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module KZ
|
5
|
+
class HmapContentStyle
|
6
|
+
QUOTES_PRIVATE = 1
|
7
|
+
QUOTES_REPAIR = 2
|
8
|
+
end
|
9
|
+
|
10
|
+
class KZGenerator
|
11
|
+
|
12
|
+
def initialize(main_project)
|
13
|
+
@all_kz_pod_targets = KZGlobalHelper.instance.kz_analyzer.all_kz_pod_targets
|
14
|
+
@main_project = main_project
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_framework_generator_build_phase(native_target)
|
18
|
+
return if KZ::KZGlobalHelper.instance.disable_generate_framework
|
19
|
+
|
20
|
+
build_phase = native_target.new_shell_script_build_phase('[KZ] Generate Framework')
|
21
|
+
build_phase.show_env_vars_in_log = '0'
|
22
|
+
build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}']
|
23
|
+
build_phase.shell_script = %q{
|
24
|
+
if [ "${MACH_O_TYPE}" != "staticlib" ]; then
|
25
|
+
exit 0
|
26
|
+
fi
|
27
|
+
|
28
|
+
PRODUCT_DIR=${PODS_BUILD_DIR}/Debug-iphoneos/${TARGET_NAME}/${FULL_PRODUCT_NAME}
|
29
|
+
PRODUCT_SIMULATOR_DIR=${PODS_BUILD_DIR}/Debug-iphonesimulator/${TARGET_NAME}/${FULL_PRODUCT_NAME}
|
30
|
+
CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
|
31
|
+
|
32
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}" ]; then
|
33
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}"
|
34
|
+
fi
|
35
|
+
mkdir -p "${KZ_FRAMEWORK_CACHE_PATH}"
|
36
|
+
|
37
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}" ]; then
|
38
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}"
|
39
|
+
fi
|
40
|
+
cp -r ${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME} "${KZ_FRAMEWORK_CACHE_PATH}"
|
41
|
+
|
42
|
+
find "${CURRENT_PRODUCT_DIR}" -iname "*.bundle" | while read -r BUNDLE_FILE; do
|
43
|
+
BUNDLE_NAME=$(basename ${BUNDLE_FILE})
|
44
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}" ]; then
|
45
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}"
|
46
|
+
fi
|
47
|
+
cp -r ${BUNDLE_FILE} "${KZ_FRAMEWORK_CACHE_PATH}"
|
48
|
+
done
|
49
|
+
|
50
|
+
if [ -f ${PRODUCT_DIR}/${PRODUCT_NAME} ] && [ -f ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} ]; then
|
51
|
+
lipo -create ${PRODUCT_DIR}/${PRODUCT_NAME} ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} -output "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/${PRODUCT_NAME}"
|
52
|
+
fi
|
53
|
+
|
54
|
+
if [ -d ${PRODUCT_DIR}/Modules/${PRODUCT_NAME}.swiftmodule ] && [ -d ${PRODUCT_SIMULATOR_DIR}/Modules/${PRODUCT_NAME}.swiftmodule ]; then
|
55
|
+
cp -r ${PRODUCT_DIR}/Modules/${PRODUCT_NAME}.swiftmodule "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Modules"
|
56
|
+
cp -r ${PRODUCT_SIMULATOR_DIR}/Modules/${PRODUCT_NAME}.swiftmodule "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Modules"
|
57
|
+
fi
|
58
|
+
|
59
|
+
PRODUCT_SWIFT_H=${PRODUCT_DIR}/Headers/${PRODUCT_NAME}-Swift.h
|
60
|
+
PRODUCT_SIMULATOR_SWIFT_H=${PRODUCT_SIMULATOR_DIR}/Headers/${PRODUCT_NAME}-Swift.h
|
61
|
+
TARGET_SWIFT_H=${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Headers/${PRODUCT_NAME}-Swift.h
|
62
|
+
if [ -f $PRODUCT_SWIFT_H ] && [ -f $PRODUCT_SIMULATOR_SWIFT_H ]; then
|
63
|
+
ruby "$KZ_MERGE_SWIFT_H_PATH" "$PRODUCT_SWIFT_H" "$PRODUCT_SIMULATOR_SWIFT_H" "$TARGET_SWIFT_H"
|
64
|
+
fi
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_flexlib_xml_build_rules(project, native_target)
|
69
|
+
return unless KZ::KZGlobalHelper.instance.have_flexLib_pod_target
|
70
|
+
|
71
|
+
native_target.build_configurations.each do |config|
|
72
|
+
config.build_settings["KZ_XML_FLEX_COMPILER"] = FLEX_COMPLIER_PATH.to_s
|
73
|
+
config.build_settings["KZ_XML_FLEX_DIR"] = "${TARGET_TEMP_DIR}/XmlFlexs"
|
74
|
+
config.build_settings["KZ_XML_FLEX_BUILD_DIR"] = "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.bundle"
|
75
|
+
end
|
76
|
+
|
77
|
+
xml_rule = new_build_rule(project, native_target, '[KZ] Custom Xml Build')
|
78
|
+
xml_rule.file_type = 'text.xml'
|
79
|
+
xml_rule.output_files = Array['${KZ_XML_FLEX_DIR}/${INPUT_FILE_BASE}.flex']
|
80
|
+
xml_rule.script = %Q{FLEX_PATH=${KZ_XML_FLEX_DIR}/${INPUT_FILE_BASE}.flex
|
81
|
+
rm -rf ${FLEX_PATH}
|
82
|
+
$KZ_XML_FLEX_COMPILER $INPUT_FILE_PATH $FLEX_PATH
|
83
|
+
if [ -f $FLEX_PATH ] ; then
|
84
|
+
cp $FLEX_PATH $KZ_XML_FLEX_BUILD_DIR
|
85
|
+
exit 0
|
86
|
+
else
|
87
|
+
exit 1
|
88
|
+
fi}
|
89
|
+
end
|
90
|
+
|
91
|
+
def new_build_rule(project, native_target, name)
|
92
|
+
new_rule = nil
|
93
|
+
native_target.build_rules.each do |build_rule|
|
94
|
+
new_rule = build_rule if build_rule.name == name
|
95
|
+
end
|
96
|
+
|
97
|
+
if new_rule == nil
|
98
|
+
new_rule = project.new(Xcodeproj::Project::PBXBuildRule)
|
99
|
+
native_target.build_rules << new_rule
|
100
|
+
end
|
101
|
+
|
102
|
+
new_rule.name = name
|
103
|
+
new_rule.compiler_spec = 'com.apple.compilers.proxy.script'
|
104
|
+
new_rule
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_hamp
|
108
|
+
# 创建壳工程hmap
|
109
|
+
main_sources_path = @main_project.project_dir + @main_project.root_object.display_name
|
110
|
+
private_hmap_hash = {}
|
111
|
+
traverse_folder(main_sources_path) do |header_path|
|
112
|
+
header_pathname = Pathname.new(header_path)
|
113
|
+
header_pathname_basename = header_pathname.basename.to_s
|
114
|
+
|
115
|
+
header_hmap_value = {}
|
116
|
+
header_hmap_value['suffix'] = header_pathname_basename
|
117
|
+
header_hmap_value['prefix'] = header_pathname.dirname.to_s + '/'
|
118
|
+
|
119
|
+
private_hmap_hash[header_pathname_basename] = header_hmap_value
|
120
|
+
end
|
121
|
+
|
122
|
+
unless private_hmap_hash.empty?
|
123
|
+
save_hmap_file(private_hmap_hash, KZ_POD_CONFIG_ROOT, @main_project.root_object.display_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
# 创建pod hmap
|
127
|
+
@all_kz_pod_targets.each do |target_name, kz_pod_target|
|
128
|
+
clean_hmap_cache(kz_pod_target)
|
129
|
+
|
130
|
+
# 修复头文件导入方式
|
131
|
+
all_repair_hmap_info = {}
|
132
|
+
need_repair_import_targets = kz_pod_target.repair_import
|
133
|
+
if need_repair_import_targets.count > 0
|
134
|
+
need_repair_import_targets.each { |need_repair_import_target|
|
135
|
+
repair_hmap_info = get_hmap_info_from(need_repair_import_target, HmapContentStyle::QUOTES_REPAIR)
|
136
|
+
all_repair_hmap_info.merge!(repair_hmap_info)
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
kz_pod_target.recursive_dependent_targets.each do |recursive_dependent_target|
|
141
|
+
if recursive_dependent_target.need_repair_module_import
|
142
|
+
header_paths = recursive_dependent_target.public_headers
|
143
|
+
header_paths.each do |header_pathname|
|
144
|
+
header_pathname_basename = header_pathname.basename.to_s
|
145
|
+
|
146
|
+
header_hmap_value_quotes = {}
|
147
|
+
header_hmap_value_quotes['suffix'] = header_pathname_basename
|
148
|
+
header_hmap_value_quotes['prefix'] = recursive_dependent_target.product_basename + '/'
|
149
|
+
all_repair_hmap_info["#{recursive_dependent_target.root_name}/#{header_pathname_basename}"] = header_hmap_value_quotes
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if all_repair_hmap_info.count > 0
|
155
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
156
|
+
save_hmap_file(all_repair_hmap_info, hmap_cache_path, target_name + '_repair')
|
157
|
+
kz_pod_target.repair_header_search_path = hmap_cache_path + "#{target_name}_repair.hmap"
|
158
|
+
end
|
159
|
+
|
160
|
+
# 添加私有头文件引用
|
161
|
+
if kz_pod_target.should_build?
|
162
|
+
private_hamp_info = get_hmap_info_from(kz_pod_target, HmapContentStyle::QUOTES_PRIVATE)
|
163
|
+
if private_hamp_info.count > 0
|
164
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
165
|
+
save_hmap_file(private_hamp_info, hmap_cache_path, target_name)
|
166
|
+
kz_pod_target.private_header_search_path = hmap_cache_path + "#{target_name}.hmap"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def traverse_folder(folder_path)
|
173
|
+
Dir.foreach(folder_path) do |file_name|
|
174
|
+
next if file_name == '.' || file_name == '..'
|
175
|
+
|
176
|
+
file_path = File.join(folder_path, file_name)
|
177
|
+
if File.file?(file_path)
|
178
|
+
yield(file_path) if file_name.end_with?('.h')
|
179
|
+
elsif File.directory?(file_path)
|
180
|
+
traverse_folder(file_path) do |path|
|
181
|
+
yield(path)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def clean_hmap_cache(kz_pod_target)
|
188
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
189
|
+
Dir.foreach(hmap_cache_path) do |file_name|
|
190
|
+
next if file_name == '.' || file_name == '..'
|
191
|
+
|
192
|
+
if file_name.end_with?(".hmap", ".json")
|
193
|
+
FileUtils.rm(hmap_cache_path + file_name) if File.exist?(hmap_cache_path + file_name)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def get_hmap_info_from(kz_pod_target, hmap_content_style)
|
199
|
+
header_paths = kz_pod_target.public_headers
|
200
|
+
header_paths = kz_pod_target.all_headers if hmap_content_style == HmapContentStyle::QUOTES_PRIVATE
|
201
|
+
hmap_info = {}
|
202
|
+
header_paths.each do |header_pathname|
|
203
|
+
header_pathname_basename = header_pathname.basename.to_s
|
204
|
+
|
205
|
+
header_hmap_value_quotes = {}
|
206
|
+
header_hmap_value_quotes['suffix'] = header_pathname_basename
|
207
|
+
header_hmap_value_quotes['prefix'] = header_pathname.dirname.to_s + '/'
|
208
|
+
hmap_info[header_pathname_basename] = header_hmap_value_quotes
|
209
|
+
|
210
|
+
if hmap_content_style == HmapContentStyle::QUOTES_PRIVATE
|
211
|
+
# pch
|
212
|
+
pchfile_path = kz_pod_target.prefix_header_path
|
213
|
+
if pchfile_path.exist?
|
214
|
+
suffix = pchfile_path.basename.to_s
|
215
|
+
hmap_info[suffix] = { 'suffix' => suffix, 'prefix' => "#{pchfile_path.dirname.to_s}/" }
|
216
|
+
end
|
217
|
+
|
218
|
+
unless kz_pod_target.is_dev_pod
|
219
|
+
# 个别第三方在使用自己组件文件时,会使用#import <xx/xx.h>的方式
|
220
|
+
hmap_info[kz_pod_target.product_basename + '/' + header_pathname_basename] = header_hmap_value_quotes
|
221
|
+
end
|
222
|
+
|
223
|
+
if kz_pod_target.uses_swift && kz_pod_target.is_dev_pod
|
224
|
+
# 修改SPBoss-Swift.h文件的导入方式
|
225
|
+
swift_bridge_file_name = "#{kz_pod_target.name}-Swift.h"
|
226
|
+
hmap_info[swift_bridge_file_name] = { 'suffix' => swift_bridge_file_name, 'prefix' => "#{kz_pod_target.name}/" }
|
227
|
+
|
228
|
+
# 以SPBoss为例,在混编模式中,SPBoss-Swift.h会使用#import <SPBoss/SPBoss.h>方式导入swift需要使用的OC头文件
|
229
|
+
# SPBoss中头文件会存在当前组件与framework的Headers中,有两份。SPBoss-Swift.h只在framework中
|
230
|
+
# 编译默认从SPBoss-Swift.h找SPBoss.h,然后找SPBoss.h中的头文件也都会在framework中寻在,会造成与当前组件头文件重复
|
231
|
+
# 需要重新将#import <SPBoss/SPBoss.h>方式修复为寻找当前组件中的SPBoss.h文件,而不是framework中的SPBoss.h
|
232
|
+
if header_pathname_basename == "#{kz_pod_target.name}.h"
|
233
|
+
hmap_info[kz_pod_target.name + '/' + header_pathname_basename] = header_hmap_value_quotes
|
234
|
+
end
|
235
|
+
end
|
236
|
+
elsif hmap_content_style == HmapContentStyle::QUOTES_REPAIR
|
237
|
+
header_hmap_value_slash = {}
|
238
|
+
header_hmap_value_slash['suffix'] = header_pathname_basename
|
239
|
+
prefix_name = kz_pod_target.product_basename
|
240
|
+
if header_pathname.dirname.to_s.include?('.framework')
|
241
|
+
header_pathname.dirname.to_s.split('/').each do |name|
|
242
|
+
if name.include?('.framework')
|
243
|
+
prefix_name = name.split('.').first
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
header_hmap_value_slash['prefix'] = prefix_name + '/'
|
248
|
+
hmap_info[header_pathname_basename] = header_hmap_value_slash
|
249
|
+
end
|
250
|
+
end
|
251
|
+
hmap_info
|
252
|
+
end
|
253
|
+
|
254
|
+
def save_hmap_file(hmap_hash, save_path, file_name)
|
255
|
+
hmap_json = JSON.pretty_generate(hmap_hash)
|
256
|
+
hmap_json_path = save_path + "#{file_name}.json"
|
257
|
+
hmap_path = save_path + "#{file_name}.hmap"
|
258
|
+
json_file = File.new(hmap_json_path, 'w')
|
259
|
+
return unless json_file
|
260
|
+
|
261
|
+
json_file.syswrite(hmap_json)
|
262
|
+
system "#{HMAP_EXECUTE_PATH} convert #{hmap_json_path} #{hmap_path}"
|
263
|
+
|
264
|
+
FileUtils.rm(hmap_json_path) unless KZ::KZGlobalHelper.instance.debug
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
268
|
+
end
|
@@ -8,17 +8,33 @@ require_relative 'kz_pod_target'
|
|
8
8
|
|
9
9
|
module KZ
|
10
10
|
KZ_POD_CONFIG_ROOT = Pod::Config.instance.installation_root + 'Pods/KZPodConfigure'
|
11
|
+
KZ_POD_CONFIG_ROOT_STR = "${PODS_ROOT}/KZPodConfigure"
|
11
12
|
# 修复pod lib报错问题
|
12
13
|
Pod::Config.instance.installation_root = nil
|
13
14
|
|
14
15
|
HMAP_EXECUTE_PATH = File.dirname(__FILE__) + '/../resources/hmap'
|
15
16
|
FLEX_COMPLIER_PATH = KZ_POD_CONFIG_ROOT + 'FlexCompiler'
|
16
17
|
KZ_LOCK_FILE_PATH = KZ_POD_CONFIG_ROOT + 'KZConfigLock'
|
18
|
+
KZ_MERGE_SWIFT_H_PATH = KZ_POD_CONFIG_ROOT + 'kz_merge_swift_h.rb'
|
19
|
+
|
20
|
+
def self.deal_path_for_xcconfig(path, add_quotes = false)
|
21
|
+
if path.is_a?(String)
|
22
|
+
path_str = path.sub(KZ::KZ_POD_CONFIG_ROOT.to_s, KZ::KZ_POD_CONFIG_ROOT_STR)
|
23
|
+
path_str = ('"' + path_str + '"') if add_quotes
|
24
|
+
return path_str
|
25
|
+
elsif path.is_a?(Pathname)
|
26
|
+
path_str = path.to_s.sub(KZ::KZ_POD_CONFIG_ROOT.to_s, KZ::KZ_POD_CONFIG_ROOT_STR)
|
27
|
+
path_str = ('"' + path_str + '"') if add_quotes
|
28
|
+
return path_str
|
29
|
+
end
|
30
|
+
path
|
31
|
+
end
|
17
32
|
|
18
33
|
class KZGlobalHelper
|
19
34
|
attr_accessor :kz_pod_enable
|
20
35
|
attr_accessor :kz_pod_config
|
21
36
|
attr_accessor :kz_analyzer
|
37
|
+
attr_accessor :kz_generator
|
22
38
|
attr_accessor :specify_pod_names
|
23
39
|
attr_accessor :specify_pod_mode
|
24
40
|
attr_accessor :debug
|
@@ -43,17 +59,21 @@ module KZ
|
|
43
59
|
@@instance ||= new
|
44
60
|
end
|
45
61
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
if value
|
62
|
+
def prepare
|
63
|
+
if Pod::Config.instance.podfile && Pod::Config.instance.podfile.plugins.has_key?("cocoapods-kz")
|
64
|
+
FileUtils.rm(KZ_LOCK_FILE_PATH) if File.exist?(KZ_LOCK_FILE_PATH)
|
51
65
|
FileUtils.mkdir_p(KZ_POD_CONFIG_ROOT) unless File.exist?(KZ_POD_CONFIG_ROOT)
|
52
66
|
|
53
67
|
flex_compiler_de_path = KZ_POD_CONFIG_ROOT + 'FlexCompiler'
|
54
68
|
FileUtils.rm(flex_compiler_de_path) if File.exist?(flex_compiler_de_path)
|
55
69
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', KZ_POD_CONFIG_ROOT)
|
56
70
|
system("chmod +x #{flex_compiler_de_path}")
|
71
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_merge_swift_h.rb', KZ_MERGE_SWIFT_H_PATH)
|
72
|
+
|
73
|
+
Pod::Config.instance.podfile.use_frameworks!(:linkage => :static)
|
74
|
+
else
|
75
|
+
@kz_pod_enable = false
|
76
|
+
@generate_kz_pod_targets = false
|
57
77
|
end
|
58
78
|
end
|
59
79
|
|
@@ -77,7 +97,7 @@ module KZ
|
|
77
97
|
end
|
78
98
|
|
79
99
|
def pod_config_result_with_target(kz_pod_target)
|
80
|
-
return nil unless @kz_pod_enable
|
100
|
+
return nil unless @kz_pod_enable
|
81
101
|
return nil unless kz_pod_target && kz_pod_target.config_pod_mode == :kz_pod_framework_mode
|
82
102
|
|
83
103
|
return @pods_config_cache[kz_pod_target.name] if @pods_config_cache.has_key?(kz_pod_target.name)
|
@@ -110,5 +130,9 @@ module KZ
|
|
110
130
|
end
|
111
131
|
end
|
112
132
|
|
133
|
+
def kz_merge_swift_h_path
|
134
|
+
KZ_POD_CONFIG_ROOT_STR + '/kz_merge_swift_h.rb'
|
135
|
+
end
|
136
|
+
|
113
137
|
end
|
114
138
|
end
|