cocoapods-kz 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-kz/command/clean.rb +30 -23
- data/lib/cocoapods-kz/command/info.rb +37 -0
- data/lib/cocoapods-kz/command/install.rb +13 -3
- data/lib/cocoapods-kz/command/kz.rb +1 -0
- data/lib/cocoapods-kz/command/repair.rb +1 -0
- data/lib/cocoapods-kz/command/update.rb +13 -3
- data/lib/cocoapods-kz/gem_version.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_analyzer.rb +20 -6
- data/lib/cocoapods-kz/helpers/kz_config_result.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +167 -1
- data/lib/cocoapods-kz/helpers/kz_generator.rb +19 -5
- data/lib/cocoapods-kz/helpers/kz_global_helper.rb +21 -4
- data/lib/cocoapods-kz/helpers/kz_log.rb +11 -0
- data/lib/cocoapods-kz/helpers/kz_pod_target.rb +81 -15
- data/lib/cocoapods-kz/native/dls.rb +10 -0
- data/lib/cocoapods-kz/native/file_accessor.rb +8 -3
- data/lib/cocoapods-kz/native/installer.rb +28 -5
- data/lib/cocoapods-kz/native/pod_target.rb +10 -0
- data/lib/cocoapods-kz/native/pod_target_installer.rb +22 -6
- data/lib/cocoapods-kz/native/pod_target_integrator.rb +62 -0
- data/lib/cocoapods-kz/native/pods_project_writer.rb +22 -0
- data/lib/cocoapods-kz/native/target_installer_helper.rb +39 -2
- data/lib/cocoapods-kz/native.rb +2 -1
- data/lib/cocoapods-kz/resources/arm64ToSimulator +0 -0
- data/lib/cocoapods-kz/resources/kz_fix_force_load_exe.sh +12 -0
- data/lib/cocoapods-kz/resources/kz_generator_framework.sh +18 -22
- data/lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb +17 -0
- metadata +9 -4
- data/lib/cocoapods-kz/native/analyzer.rb +0 -23
- data/lib/cocoapods-kz/resources/kz_merge_swift_h.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c043498bc76c19c7f49d1b6f64f00f10535f3512b9eb85853e213e4faa9b4d1c
|
4
|
+
data.tar.gz: e86ca96c094fb8f90d6434d1ce99421c0d4c2d2bca37b0e91f23639f841ea3df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15a3769ef86e707c147f1d8d0f3b03832c316a895869703e501fdf3efb9f365938548bc73b2db8331624d90c9ba714bb41763755696d42e7e64cf800c80729d0
|
7
|
+
data.tar.gz: 70b54fcc641af9ae839c916568e6af18444dc42d00054fcae859e64c9639b780a52eab7320582c15a1c392245fb0cad1cc43cc91557c4ae8716de04c419a6086
|
@@ -7,8 +7,7 @@ module Pod
|
|
7
7
|
self.summary = 'pod kz clean 用于清理缓存以一些报错文件'
|
8
8
|
|
9
9
|
self.description = <<-DESC
|
10
|
-
在pod update过程中由于代码变动,module
|
11
|
-
让Xcode重新生成
|
10
|
+
在pod update过程中由于代码变动,module缓存容易产生签名过期的问题,部分属性文件,跳转也会存在路径不对的情况,需要清理老旧缓存文件,让Xcode重新生成
|
12
11
|
DESC
|
13
12
|
|
14
13
|
self.arguments = [
|
@@ -17,42 +16,50 @@ module Pod
|
|
17
16
|
|
18
17
|
def self.options
|
19
18
|
[
|
20
|
-
|
19
|
+
["--xcode", "清除module缓存与头文件索引问题"],
|
20
|
+
["--framework", "清除所有自生成本地缓存的framework"],
|
21
21
|
]
|
22
22
|
end
|
23
23
|
|
24
24
|
def initialize(argv)
|
25
|
-
clean_xcode = argv.flag?('xcode')
|
26
|
-
|
25
|
+
@clean_xcode = argv.flag?('xcode')
|
26
|
+
@clean_framework = argv.flag?('framework')
|
27
|
+
banner! unless @clean_xcode || @clean_framework
|
27
28
|
|
28
29
|
super
|
29
30
|
end
|
30
31
|
|
31
32
|
def run
|
32
|
-
|
33
|
-
|
33
|
+
if @clean_xcode
|
34
|
+
xcodeproj_path = Pathname.new(Dir[Pod::Config.instance.installation_root + "*.xcodeproj"].first)
|
35
|
+
return unless xcodeproj_path
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
xcode_derived_data_path = Pathname.new(Dir.home + "/Library/Developer/Xcode/DerivedData")
|
38
|
+
module_cache_noindex_path = xcode_derived_data_path + "ModuleCache.noindex"
|
39
|
+
FileUtils.rm_rf(module_cache_noindex_path) if module_cache_noindex_path.exist?
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
project_name = xcodeproj_path.basename.to_s.split(".").first
|
42
|
+
Dir.foreach(xcode_derived_data_path) do |file_name|
|
43
|
+
next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
if file_name.start_with?(project_name)
|
46
|
+
project_path = xcode_derived_data_path + file_name
|
47
|
+
index_noindex_path = project_path + "Index.noindex"
|
48
|
+
FileUtils.rm_rf(index_noindex_path) if index_noindex_path.exist?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
default_xcode_path = Pathname.new('/Applications/Xcode.app')
|
53
|
+
if default_xcode_path.exist?
|
54
|
+
system("osascript -e 'quit app \"Xcode\"'")
|
55
|
+
sleep 1
|
56
|
+
workspace_path = Dir[Pod::Config.instance.installation_root + "*.xcworkspace"].first
|
57
|
+
system("open \"#{workspace_path}\"")
|
47
58
|
end
|
48
59
|
end
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
system("osascript -e 'quit app \"Xcode\"'")
|
53
|
-
sleep 1
|
54
|
-
workspace_path = Dir[Pod::Config.instance.installation_root + "*.xcworkspace"].first
|
55
|
-
system("open \"#{workspace_path}\"")
|
61
|
+
if @clean_framework
|
62
|
+
FileUtils.rm_r(KZ::KZ_POD_CONFIG_ROOT) if File.exist?(KZ::KZ_POD_CONFIG_ROOT)
|
56
63
|
end
|
57
64
|
end
|
58
65
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Kz < Command
|
6
|
+
class Info < Kz
|
7
|
+
self.summary = 'pod kz info,用于打印项目pod信息'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
结合可选子命令用于执行各种修补脚本
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def initialize(argv)
|
14
|
+
KZ::KZGlobalHelper.instance.analyze_special_parameters(true, false, argv.arguments!)
|
15
|
+
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
installer = installer_for_config
|
21
|
+
installer.prepare
|
22
|
+
installer.resolve_dependencies
|
23
|
+
installer.download_dependencies
|
24
|
+
|
25
|
+
result_info = {}
|
26
|
+
KZ::KZGlobalHelper.instance.kz_analyzer.all_kz_pod_targets.values.each do |kz_pod_target|
|
27
|
+
pod_info = {}
|
28
|
+
pod_info["path"] = kz_pod_target.native_pod_target.sandbox.pod_dir(kz_pod_target.name)
|
29
|
+
pod_info["is_dev"] = kz_pod_target.is_dev_pod
|
30
|
+
result_info[kz_pod_target.name] = pod_info
|
31
|
+
end
|
32
|
+
puts result_info.to_json
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -22,14 +22,16 @@ module Pod
|
|
22
22
|
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
23
|
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
-
['--
|
25
|
+
['--framework-update', "build后不再生成frameowrk"],
|
26
|
+
['--arm64-simulator', "适配模拟器的arm64模式,会自动将只支持真机arm64的framework转成arm64模式"]
|
26
27
|
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
27
28
|
end
|
28
29
|
|
29
30
|
def initialize(argv)
|
30
31
|
use_code_tag = argv.flag?('code')
|
31
32
|
use_framework_tag = argv.flag?('framework')
|
32
|
-
banner!
|
33
|
+
banner! unless isOptionsArgvFlag(argv.options.keys)
|
34
|
+
banner! if (use_code_tag && use_framework_tag)
|
33
35
|
|
34
36
|
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
35
37
|
if Pod.match_version?('~> 1.11')
|
@@ -37,12 +39,20 @@ module Pod
|
|
37
39
|
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
38
40
|
end
|
39
41
|
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
40
|
-
KZ::KZGlobalHelper.instance.
|
42
|
+
KZ::KZGlobalHelper.instance.arm64_simulator = true if argv.flag?('arm64-simulator')
|
43
|
+
framework_update = argv.flag?('framework-update')
|
44
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if (framework_update != nil && framework_update == false)
|
41
45
|
|
42
46
|
super
|
43
47
|
@additional_args = argv.remainder!
|
44
48
|
end
|
45
49
|
|
50
|
+
def isOptionsArgvFlag(all_flags)
|
51
|
+
return true if all_flags.empty?
|
52
|
+
supported_flags = ["repo-update", "deployment", "clean-install", "code", "framework", "debug", "framework-update", "arm64-simulator"]
|
53
|
+
return (all_flags & supported_flags) == all_flags
|
54
|
+
end
|
55
|
+
|
46
56
|
def run
|
47
57
|
KZ::KZGlobalHelper.instance.prepare
|
48
58
|
install = Pod::Command::Install.new(CLAide::ARGV.new([*@additional_args]))
|
@@ -22,14 +22,16 @@ module Pod
|
|
22
22
|
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
23
|
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
-
['--no-framework-update', "build后不再生成frameowrk"]
|
25
|
+
['--no-framework-update', "build后不再生成frameowrk"],
|
26
|
+
['--arm64-simulator', "适配模拟器的arm64模式,会自动将只支持真机arm64的framework转成arm64模式"]
|
26
27
|
].concat(super)
|
27
28
|
end
|
28
29
|
|
29
30
|
def initialize(argv)
|
30
31
|
use_code_tag = argv.flag?('code')
|
31
32
|
use_framework_tag = argv.flag?('framework')
|
32
|
-
banner!
|
33
|
+
banner! unless isOptionsArgvFlag(argv.options.keys)
|
34
|
+
banner! if (use_code_tag && use_framework_tag)
|
33
35
|
|
34
36
|
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
35
37
|
if Pod.match_version?('~> 1.11')
|
@@ -37,12 +39,20 @@ module Pod
|
|
37
39
|
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
38
40
|
end
|
39
41
|
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
40
|
-
KZ::KZGlobalHelper.instance.
|
42
|
+
KZ::KZGlobalHelper.instance.arm64_simulator = true if argv.flag?('arm64-simulator')
|
43
|
+
framework_update = argv.flag?('framework-update')
|
44
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if (framework_update != nil && framework_update == false)
|
41
45
|
|
42
46
|
super
|
43
47
|
@additional_args = argv.remainder!
|
44
48
|
end
|
45
49
|
|
50
|
+
def isOptionsArgvFlag(all_flags)
|
51
|
+
return true if all_flags.empty?
|
52
|
+
supported_flags = ["sources", "exclude-pods", "clean-install", "code", "framework", "debug", "framework-update", "arm64-simulator"]
|
53
|
+
return (all_flags & supported_flags) == all_flags
|
54
|
+
end
|
55
|
+
|
46
56
|
def run
|
47
57
|
KZ::KZGlobalHelper.instance.prepare
|
48
58
|
update = Pod::Command::Update.new(CLAide::ARGV.new([*@additional_args]))
|
@@ -20,18 +20,32 @@ module KZ
|
|
20
20
|
# 检测是否有product名称相同的target
|
21
21
|
temp_repeat_product_name = []
|
22
22
|
@all_kz_pod_targets.each do |name, kz_pod_target|
|
23
|
-
|
23
|
+
result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
|
24
|
+
if temp_repeat_product_name.include?("#{kz_pod_target.product_name}_#{kz_pod_target.platform_name}")
|
24
25
|
kz_pod_target.product_name = "#{kz_pod_target.name}.framework"
|
25
26
|
kz_pod_target.product_basename = kz_pod_target.name
|
26
|
-
result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
|
27
27
|
if result
|
28
|
-
kz_pod_target.repair_modulemap_path =
|
28
|
+
kz_pod_target.repair_modulemap_path = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/Modules/module.modulemap"
|
29
|
+
if kz_pod_target.origin_uses_swift?
|
30
|
+
kz_pod_target.repair_swift_include_path = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/Modules"
|
31
|
+
end
|
29
32
|
else
|
30
|
-
kz_pod_target.repair_modulemap_path = "
|
33
|
+
kz_pod_target.repair_modulemap_path = "#{kz_pod_target.native_pod_target.configuration_build_dir}/#{kz_pod_target.product_name}/Modules/module.modulemap"
|
34
|
+
if kz_pod_target.origin_uses_swift?
|
35
|
+
kz_pod_target.repair_swift_include_path = "#{kz_pod_target.native_pod_target.configuration_build_dir}/#{kz_pod_target.product_name}/Modules"
|
36
|
+
end
|
31
37
|
end
|
32
38
|
kz_pod_target.need_repair_module_import = true
|
33
|
-
elsif kz_pod_target.
|
34
|
-
temp_repeat_product_name << kz_pod_target.product_name
|
39
|
+
elsif kz_pod_target.origin_should_build?
|
40
|
+
temp_repeat_product_name << "#{kz_pod_target.product_name}_#{kz_pod_target.platform_name}"
|
41
|
+
end
|
42
|
+
|
43
|
+
if kz_pod_target.force_load
|
44
|
+
if result
|
45
|
+
kz_pod_target.force_load_info = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/#{kz_pod_target.product_basename}"
|
46
|
+
else
|
47
|
+
kz_pod_target.force_load_info = "#{kz_pod_target.configuration_build_dir(true)}/#{kz_pod_target.product_name}/#{kz_pod_target.product_basename}"
|
48
|
+
end
|
35
49
|
end
|
36
50
|
end
|
37
51
|
end
|
@@ -30,7 +30,7 @@ module KZ
|
|
30
30
|
next if framework_name == '.' || framework_name == '..' || framework_name == '.DS_Store'
|
31
31
|
|
32
32
|
framework_path = @resource_path + framework_name
|
33
|
-
if File.directory?(framework_path) && framework_name.end_with?(".
|
33
|
+
if File.directory?(framework_path) && framework_name.end_with?(".xcframework")
|
34
34
|
framework_paths << framework_path
|
35
35
|
end
|
36
36
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'kz_pod_target'
|
2
2
|
require_relative 'kz_global_helper'
|
3
3
|
require_relative 'kz_config_result'
|
4
|
+
require 'tmpdir'
|
5
|
+
require_relative 'kz_log'
|
4
6
|
|
5
7
|
module KZ
|
6
8
|
class KZFrameworkManager
|
@@ -35,7 +37,7 @@ module KZ
|
|
35
37
|
Dir.foreach(version_folder) do |file_name|
|
36
38
|
next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
|
37
39
|
|
38
|
-
if file_name.end_with?(".
|
40
|
+
if file_name.end_with?(".xcframework") && File.directory?(version_folder + file_name)
|
39
41
|
have_framework = true
|
40
42
|
break
|
41
43
|
end
|
@@ -48,5 +50,169 @@ module KZ
|
|
48
50
|
@@all_resources_cache_info
|
49
51
|
end
|
50
52
|
|
53
|
+
def self.handle_origin_framework(origin_frameworks, kz_pod_target)
|
54
|
+
new_frameworks = []
|
55
|
+
destination_path = kz_pod_target.pod_config_cache_path(false, true)
|
56
|
+
origin_frameworks.each do |origin_framework_path|
|
57
|
+
if kz_pod_target.disable_to_simulator_frameworks.include?(origin_framework_path)
|
58
|
+
new_frameworks.append(origin_framework_path)
|
59
|
+
else
|
60
|
+
new_framework_path = self.convert_arm64_to_simulator(origin_framework_path, destination_path)
|
61
|
+
if new_framework_path == origin_framework_path
|
62
|
+
kz_pod_target.disable_to_simulator_frameworks.append(origin_framework_path)
|
63
|
+
end
|
64
|
+
new_frameworks.append(new_framework_path)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
new_frameworks
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.convert_arm64_to_simulator(origin_framework_path, destination_path)
|
71
|
+
framework_name = origin_framework_path.basename.to_s
|
72
|
+
if framework_name.end_with?(".framework")
|
73
|
+
framework_basename = framework_name.chomp(".framework")
|
74
|
+
xcframework_path = destination_path + "#{framework_basename}.xcframework"
|
75
|
+
return xcframework_path if File.exist?(xcframework_path) && !Dir.empty?(xcframework_path)
|
76
|
+
|
77
|
+
if self.create_xcframework(origin_framework_path, origin_framework_path, framework_basename, xcframework_path)
|
78
|
+
return xcframework_path
|
79
|
+
else
|
80
|
+
return origin_framework_path
|
81
|
+
end
|
82
|
+
elsif framework_name.end_with?(".xcframework")
|
83
|
+
framework_basename = framework_name.chomp(".xcframework")
|
84
|
+
xcframework_path = destination_path + "#{framework_basename}.xcframework"
|
85
|
+
return xcframework_path if File.exist?(xcframework_path)
|
86
|
+
|
87
|
+
info_plist_path = origin_framework_path + "Info.plist"
|
88
|
+
return origin_framework_path unless File.exist?(info_plist_path)
|
89
|
+
|
90
|
+
info_plist = Xcodeproj::Plist.read_from_path(info_plist_path)
|
91
|
+
available_libraries = info_plist["AvailableLibraries"]
|
92
|
+
available_libraries.each do |available_librarie|
|
93
|
+
if available_librarie["SupportedPlatformVariant"] == "simulator" && available_librarie["SupportedArchitectures"].include?("arm64")
|
94
|
+
return origin_framework_path
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# 找到真机arm64 framework与模拟器x86_64 framework
|
99
|
+
xc_framework_path = ""
|
100
|
+
xc_simulator_framework_path = ""
|
101
|
+
available_libraries.each do |available_librarie|
|
102
|
+
if available_librarie["SupportedPlatformVariant"] == "simulator"
|
103
|
+
if available_librarie["SupportedArchitectures"].include?("x86_64")
|
104
|
+
xc_simulator_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
|
105
|
+
end
|
106
|
+
elsif available_librarie["SupportedPlatform"] == "ios"
|
107
|
+
if available_librarie["SupportedArchitectures"].include?("arm64")
|
108
|
+
xc_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
xc_simulator_framework_path = xc_framework_path unless xc_simulator_framework_path != ""
|
114
|
+
if self.create_xcframework(xc_framework_path, xc_simulator_framework_path, framework_basename, xcframework_path)
|
115
|
+
return xcframework_path
|
116
|
+
else
|
117
|
+
return origin_framework_path
|
118
|
+
end
|
119
|
+
else
|
120
|
+
return origin_framework_path
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.create_xcframework(origin_framework_path, origin_simulator_framework_path, framework_basename, destination_xcframework_path)
|
125
|
+
tempdir = Pathname(Dir.mktmpdir)
|
126
|
+
arm64_path = tempdir + "arm64"
|
127
|
+
FileUtils.mkdir_p(arm64_path)
|
128
|
+
arm64_framework_path = arm64_path + "#{framework_basename}.framework"
|
129
|
+
FileUtils.cp_r(origin_framework_path, arm64_framework_path)
|
130
|
+
arm64_framework_exe_path = arm64_framework_path + framework_basename
|
131
|
+
if self.contain_multiple_arch?(arm64_framework_exe_path)
|
132
|
+
system("lipo #{arm64_framework_exe_path} -thin arm64 -output #{arm64_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
|
133
|
+
end
|
134
|
+
|
135
|
+
simulator_path = tempdir + "simulator"
|
136
|
+
FileUtils.mkdir_p(simulator_path)
|
137
|
+
simulator_framework_path = simulator_path + "#{framework_basename}.framework"
|
138
|
+
FileUtils.cp_r(origin_simulator_framework_path, simulator_framework_path)
|
139
|
+
simulator_framework_exe_path = simulator_framework_path + framework_basename
|
140
|
+
contain_x8664 = self.contain_x8664?(simulator_framework_exe_path)
|
141
|
+
if contain_x8664
|
142
|
+
system("lipo #{simulator_framework_exe_path} -thin x86_64 -output #{simulator_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
|
143
|
+
else
|
144
|
+
FileUtils.rm(simulator_framework_exe_path)
|
145
|
+
end
|
146
|
+
|
147
|
+
temp_framwork_exe_path = tempdir + "#{framework_basename}_arm64_simulator"
|
148
|
+
|
149
|
+
if self.is_dynamic_library?(origin_framework_path + framework_basename)
|
150
|
+
xcrun_vtool_show_result = `xcrun vtool -arch arm64 -show #{origin_framework_path + framework_basename}`.lines.map(&:chomp)
|
151
|
+
framework_sdk_version = "16.0"
|
152
|
+
framework_deployment_version = "12.0"
|
153
|
+
reach_cmd_tag = false
|
154
|
+
xcrun_vtool_show_result.each do |line|
|
155
|
+
reach_cmd_tag = false if line.start_with?("Load command")
|
156
|
+
|
157
|
+
line_infos = line.lstrip.split
|
158
|
+
next unless line_infos.count == 2
|
159
|
+
|
160
|
+
if line_infos.first == "cmd" && line_infos.last == "LC_VERSION_MIN_IPHONEOS"
|
161
|
+
reach_cmd_tag = true
|
162
|
+
end
|
163
|
+
|
164
|
+
if reach_cmd_tag
|
165
|
+
if line_infos.include?("sdk")
|
166
|
+
framework_sdk_version = line_infos.last
|
167
|
+
elsif line_infos.include?("version")
|
168
|
+
framework_deployment_version = line_infos.last
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
xcrun_vtool_set_result = system("xcrun vtool -arch arm64 -set-build-version 7 #{framework_deployment_version} #{framework_sdk_version} -replace -output #{temp_framwork_exe_path} #{arm64_framework_exe_path}")
|
173
|
+
unless xcrun_vtool_set_result
|
174
|
+
FileUtils.rm_r(tempdir)
|
175
|
+
return false
|
176
|
+
end
|
177
|
+
else
|
178
|
+
ar_x_path = tempdir + "ar_x"
|
179
|
+
FileUtils.mkdir_p(ar_x_path)
|
180
|
+
ar_x_success = system("cd #{ar_x_path}; ar x #{arm64_framework_exe_path}")
|
181
|
+
if ar_x_success
|
182
|
+
system("for file in #{ar_x_path}/*.o; do #{ARM64_TO_SIMULATOR_EXECUTE_PATH} $file; done")
|
183
|
+
system("ar crv #{temp_framwork_exe_path} #{ar_x_path}/*.o &> /dev/null")
|
184
|
+
else
|
185
|
+
FileUtils.rm_r(tempdir)
|
186
|
+
return false
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
if contain_x8664
|
191
|
+
system("lipo -create #{temp_framwork_exe_path} #{simulator_framework_exe_path} -output #{simulator_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
|
192
|
+
else
|
193
|
+
FileUtils.mv("#{temp_framwork_exe_path}", simulator_framework_exe_path)
|
194
|
+
end
|
195
|
+
FileUtils.mkdir_p(destination_xcframework_path) unless File.exist?(destination_xcframework_path)
|
196
|
+
system("xcodebuild -create-xcframework -framework $(readlink -f '#{arm64_framework_path}') -framework $(readlink -f '#{simulator_framework_path}') -output #{destination_xcframework_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
|
197
|
+
FileUtils.rm_r(tempdir)
|
198
|
+
|
199
|
+
return true
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.is_dynamic_library?(file_path)
|
203
|
+
file_result = `file -b #{file_path}`
|
204
|
+
return file_result.include?("dynamically linked shared library")
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.contain_x8664?(file_path)
|
208
|
+
file_result = `file -b #{file_path}`
|
209
|
+
return file_result.include?("for architecture x86_64")
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.contain_multiple_arch?(file_path)
|
213
|
+
file_result = `lipo -info #{file_path}`
|
214
|
+
return file_result.include?("Architectures in the fat file")
|
215
|
+
end
|
216
|
+
|
51
217
|
end
|
52
218
|
end
|
@@ -15,7 +15,7 @@ module KZ
|
|
15
15
|
|
16
16
|
build_phase = native_target.new_shell_script_build_phase('[KZ] Generate Framework')
|
17
17
|
build_phase.show_env_vars_in_log = '0'
|
18
|
-
build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${
|
18
|
+
build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework']
|
19
19
|
build_phase.shell_script = KZ.deal_path_for_xcconfig(KZ_GENERATOR_FRAMEWORK_PATH, true)
|
20
20
|
end
|
21
21
|
|
@@ -34,6 +34,15 @@ module KZ
|
|
34
34
|
xml_rule.script = KZ.deal_path_for_xcconfig(KZ_XML_BUILD_PATH, true)
|
35
35
|
end
|
36
36
|
|
37
|
+
def add_force_load_exe_path_build_phase(native_target, output_path)
|
38
|
+
return if KZ::KZGlobalHelper.instance.disable_generate_framework
|
39
|
+
|
40
|
+
build_phase = native_target.new_shell_script_build_phase('[KZ] Froce Load File Output Path')
|
41
|
+
build_phase.show_env_vars_in_log = '0'
|
42
|
+
build_phase.output_paths = [output_path]
|
43
|
+
build_phase.shell_script = KZ.deal_path_for_xcconfig(KZ_FIX_FORCE_LOAD_EXE, true)
|
44
|
+
end
|
45
|
+
|
37
46
|
def new_build_rule(project, native_target, name)
|
38
47
|
new_rule = nil
|
39
48
|
native_target.build_rules.each do |build_rule|
|
@@ -99,15 +108,19 @@ module KZ
|
|
99
108
|
|
100
109
|
if all_repair_hmap_info.count > 0
|
101
110
|
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
111
|
+
FileUtils.mkdir_p(hmap_cache_path) unless File.exist?(hmap_cache_path)
|
112
|
+
|
102
113
|
save_hmap_file(all_repair_hmap_info, hmap_cache_path, target_name + '_repair')
|
103
114
|
kz_pod_target.repair_header_search_path = hmap_cache_path + "#{target_name}_repair.hmap"
|
104
115
|
end
|
105
116
|
|
106
117
|
# 添加私有头文件引用
|
107
|
-
if kz_pod_target.
|
118
|
+
if kz_pod_target.current_should_build?
|
108
119
|
private_hamp_info = private_hmap_info(kz_pod_target)
|
109
120
|
if private_hamp_info.count > 0
|
110
121
|
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
122
|
+
FileUtils.mkdir_p(hmap_cache_path) unless File.exist?(hmap_cache_path)
|
123
|
+
|
111
124
|
save_hmap_file(private_hamp_info, hmap_cache_path, target_name)
|
112
125
|
kz_pod_target.private_header_search_path = hmap_cache_path + "#{target_name}.hmap"
|
113
126
|
end
|
@@ -132,13 +145,14 @@ module KZ
|
|
132
145
|
|
133
146
|
def clean_hmap_cache(kz_pod_target)
|
134
147
|
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
148
|
+
|
135
149
|
Dir.foreach(hmap_cache_path) do |file_name|
|
136
150
|
next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
|
137
151
|
|
138
152
|
if file_name.end_with?(".hmap", ".json")
|
139
153
|
FileUtils.rm(hmap_cache_path + file_name) if File.exist?(hmap_cache_path + file_name)
|
140
154
|
end
|
141
|
-
end
|
155
|
+
end if File.exist?(hmap_cache_path)
|
142
156
|
end
|
143
157
|
|
144
158
|
def repair_hmap_info(kz_pod_target)
|
@@ -169,7 +183,7 @@ module KZ
|
|
169
183
|
def private_hmap_info(kz_pod_target)
|
170
184
|
header_paths = kz_pod_target.all_headers
|
171
185
|
# 更新Headers
|
172
|
-
if kz_pod_target.is_dev_pod
|
186
|
+
if kz_pod_target.is_dev_pod
|
173
187
|
header_paths.each do |header_pathname|
|
174
188
|
symlink_path = kz_pod_target.local_private_headers_path + header_pathname.basename
|
175
189
|
File.symlink(header_pathname, symlink_path) unless File.symlink?(symlink_path) || File.exist?(symlink_path)
|
@@ -196,7 +210,7 @@ module KZ
|
|
196
210
|
hmap_info[kz_pod_target.product_basename + '/' + header_pathname_basename] = header_hmap_value_quotes
|
197
211
|
end
|
198
212
|
|
199
|
-
if kz_pod_target.
|
213
|
+
if kz_pod_target.current_uses_swift? && kz_pod_target.is_dev_pod
|
200
214
|
# 修改SPBoss-Swift.h文件的导入方式
|
201
215
|
swift_bridge_file_name = "#{kz_pod_target.name}-Swift.h"
|
202
216
|
hmap_info[swift_bridge_file_name] = { 'suffix' => swift_bridge_file_name, 'prefix' => "#{kz_pod_target.name}/" }
|
@@ -11,16 +11,19 @@ module KZ
|
|
11
11
|
KZ_POD_CONFIG_ROOT = Pod::Config.instance.installation_root + 'Pods/KZPodConfigure'
|
12
12
|
KZ_POD_CONFIG_SUPPORT_FILES = KZ_POD_CONFIG_ROOT + 'SupportFiles'
|
13
13
|
KZ_POD_CONFIG_POD_TARGETS = KZ_POD_CONFIG_ROOT + 'PodTargets'
|
14
|
+
KZ_POD_CONFIG_POD_TEMPDIR = KZ_POD_CONFIG_ROOT + '.tempdir'
|
14
15
|
KZ_POD_CONFIG_ROOT_STR = "${PODS_ROOT}/KZPodConfigure"
|
15
16
|
# 修复pod lib报错问题
|
16
17
|
Pod::Config.instance.installation_root = nil
|
17
18
|
|
18
19
|
HMAP_EXECUTE_PATH = File.dirname(__FILE__) + '/../resources/hmap'
|
19
20
|
FLEX_COMPLIER_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'FlexCompiler'
|
20
|
-
|
21
|
+
ARM64_TO_SIMULATOR_EXECUTE_PATH = File.dirname(__FILE__) + '/../resources/arm64ToSimulator'
|
21
22
|
KZ_GENERATOR_FRAMEWORK_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_generator_framework.sh'
|
22
23
|
KZ_XML_BUILD_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_xml_build.sh'
|
23
24
|
KZ_LOCK_FILE_PATH = KZ_POD_CONFIG_ROOT + 'KZConfigLock'
|
25
|
+
KZ_FIX_FORCE_LOAD_EXE = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_fix_force_load_exe.sh'
|
26
|
+
KZ_FEFRESH_PODS_PBXPROJ = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_refresh_pods_pbxproj.rb'
|
24
27
|
|
25
28
|
def self.deal_path_for_xcconfig(path, add_quotes = false)
|
26
29
|
if path.is_a?(String)
|
@@ -46,6 +49,8 @@ module KZ
|
|
46
49
|
attr_accessor :kz_config_lock
|
47
50
|
attr_accessor :disable_generate_framework
|
48
51
|
attr_accessor :generate_kz_pod_targets
|
52
|
+
attr_accessor :debug_shell_log_tag
|
53
|
+
attr_accessor :arm64_simulator
|
49
54
|
|
50
55
|
private_class_method :new
|
51
56
|
|
@@ -58,6 +63,15 @@ module KZ
|
|
58
63
|
@disable_generate_framework = false
|
59
64
|
@generate_kz_pod_targets = false
|
60
65
|
@olde_lock_file_content = nil
|
66
|
+
@debug_shell_log_tag = "&> /dev/null"
|
67
|
+
@arm64_simulator = false
|
68
|
+
end
|
69
|
+
|
70
|
+
def debug=(value)
|
71
|
+
@debug = value
|
72
|
+
if debug
|
73
|
+
@debug_shell_log_tag = ""
|
74
|
+
end
|
61
75
|
end
|
62
76
|
|
63
77
|
@@instance = nil
|
@@ -74,21 +88,24 @@ module KZ
|
|
74
88
|
end
|
75
89
|
FileUtils.mkdir_p(KZ_POD_CONFIG_SUPPORT_FILES) unless File.exist?(KZ_POD_CONFIG_SUPPORT_FILES)
|
76
90
|
FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TARGETS) unless File.exist?(KZ_POD_CONFIG_POD_TARGETS)
|
91
|
+
FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TEMPDIR) unless File.exist?(KZ_POD_CONFIG_POD_TEMPDIR)
|
77
92
|
|
78
93
|
FileUtils.rm(FLEX_COMPLIER_PATH) if File.exist?(FLEX_COMPLIER_PATH)
|
79
94
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', FLEX_COMPLIER_PATH)
|
80
95
|
system("chmod +x #{FLEX_COMPLIER_PATH}")
|
81
96
|
|
82
|
-
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_merge_swift_h.rb', KZ_MERGE_SWIFT_H_PATH)
|
83
|
-
|
84
97
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_generator_framework.sh', KZ_GENERATOR_FRAMEWORK_PATH)
|
85
98
|
system("chmod +x #{KZ_GENERATOR_FRAMEWORK_PATH}")
|
86
99
|
|
87
100
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_xml_build.sh', KZ_XML_BUILD_PATH)
|
88
101
|
system("chmod +x #{KZ_XML_BUILD_PATH}")
|
89
102
|
|
103
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_fix_force_load_exe.sh', KZ_FIX_FORCE_LOAD_EXE)
|
104
|
+
system("chmod +x #{KZ_FIX_FORCE_LOAD_EXE}")
|
105
|
+
|
106
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_refresh_pods_pbxproj.rb', KZ_FEFRESH_PODS_PBXPROJ)
|
107
|
+
|
90
108
|
Pod::Config.instance.podfile.use_frameworks!(:linkage => :static)
|
91
|
-
Pod::Config.instance.podfile.install!("cocoapods", :deterministic_uuids => false)
|
92
109
|
else
|
93
110
|
@kz_pod_enable = false
|
94
111
|
@generate_kz_pod_targets = false
|