xcframework_converter 0.4.0 → 0.5.0
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/xcframework_converter/arm_patcher.rb +26 -9
- data/lib/xcframework_converter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc55b13f203a5434a0844c4e3e2bdab78de4cf7e9c518a4e504eb4513aaa65d6
|
4
|
+
data.tar.gz: 2867a3113f62112a2b324ec4822613edaa8168fbc75a2dc6ac398a074b481028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6664a2115bd38a245669ac19a3504359641c790e613a472fe38f755c8f20c23bd38caa57333b6c5817e3d14c7185df8521ecb7394f28a431529d7f8ca5bcdfbe
|
7
|
+
data.tar.gz: 2cef2f4dc73b1e9091bd5f3580ec1c307ec40e5248c9732e0de781aa5d8a0b33f9e27e3befda29c5d924c9a6fccc9ef3aa1f9f6d11588297b796cedb66abf69a
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'cocoapods'
|
4
4
|
require 'cocoapods/xcode/xcframework'
|
5
|
+
require 'digest/md5'
|
5
6
|
require 'fileutils'
|
7
|
+
require 'shellwords'
|
6
8
|
require 'xcodeproj'
|
7
9
|
|
8
|
-
# rubocop:disable Metrics/AbcSize
|
10
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
9
11
|
|
10
12
|
module XCFrameworkConverter
|
11
13
|
# Patches a binary (static or dynamic), turning an arm64-device into an arm64-simualtor.
|
@@ -61,16 +63,31 @@ module XCFrameworkConverter
|
|
61
63
|
`xcrun lipo \"#{slice.binary_path}\" -thin arm64 -output \"#{extracted_path}\"`
|
62
64
|
extracted_path_dir = slice.path.join('arm64-objects')
|
63
65
|
extracted_path_dir.mkdir
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
object_files = `ar t \"#{extracted_path}\"`.split("\n").map(&:chomp).sort
|
67
|
+
.select { |o| o.end_with?('.o') }
|
68
|
+
.group_by(&:itself).transform_values(&:count)
|
69
|
+
processed_files = []
|
70
|
+
index = 0
|
71
|
+
while object_files.any?
|
72
|
+
object_files.keys.each do |object_file|
|
73
|
+
file_shard = Digest::MD5.hexdigest(object_file).to_s[0..2]
|
74
|
+
file_dir = extracted_path_dir.join("#{index}-#{file_shard}")
|
75
|
+
file_path = file_dir.join(object_file)
|
76
|
+
file_dir.mkdir unless file_dir.exist?
|
77
|
+
`ar p \"#{extracted_path}\" \"#{object_file}\" > \"#{file_path}\"`
|
78
|
+
macho_file = MachO::MachOFile.new(file_path)
|
79
|
+
sdk_version = macho_file[:LC_VERSION_MIN_IPHONEOS].first.version_string.to_i
|
80
|
+
`\"#{arm2sim_path}\" \"#{file_path}\" \"#{sdk_version}\" \"#{sdk_version}\"`
|
81
|
+
$stderr.printf '.'
|
82
|
+
processed_files << file_path
|
83
|
+
end
|
84
|
+
`ar d \"#{extracted_path}\" #{object_files.keys.map(&:shellescape).join(' ')}`
|
85
|
+
$stderr.printf '#'
|
86
|
+
object_files.reject! { |_, count| count <= index + 1 }
|
87
|
+
index += 1
|
70
88
|
end
|
71
89
|
$stderr.puts
|
72
|
-
`cd \"#{extracted_path_dir}\" ; ar
|
73
|
-
|
90
|
+
`cd \"#{extracted_path_dir}\" ; ar cqv \"#{extracted_path}\" #{processed_files.map(&:shellescape).join(' ')}`
|
74
91
|
`xcrun lipo \"#{slice.binary_path}\" -replace arm64 \"#{extracted_path}\" -output \"#{slice.binary_path}\"`
|
75
92
|
extracted_path_dir.rmtree
|
76
93
|
extracted_path.rmtree
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcframework_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Makarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|