xcframework_converter 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a1169fa0a3c860b9ddffd50b22592d95ba42d5f32a1f97dbc7507827491ac47
|
4
|
+
data.tar.gz: 05b3b160406d9b1db0db39cc0c999e4c5370d08be44e5dbd5f069089751ab890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4356364e00c34af6f9a817d9a3bea2411f46ab0fee145586bbb48d9f1ffa23335a1728970535ea2e8e94559eae15cb3de4abecce8c983fa1b9b653235878a50e
|
7
|
+
data.tar.gz: a29311d0abee698408d037bbca8ebba0a9603e2eb9c4851c4b74c2581688a324fe529f26a374c04ea29405a45174931eff113362e99edf460b953dfb66364f8a
|
data/bin/xcfconvert
CHANGED
@@ -5,8 +5,10 @@ require 'bundler/setup'
|
|
5
5
|
require 'xcframework_converter'
|
6
6
|
|
7
7
|
if ARGV.empty?
|
8
|
-
warn 'Usage: xcfconvert <path/to/Framework.framework>'
|
8
|
+
warn 'Usage: xcfconvert <path/to/Framework.framework> [ios|tvos|watchos]'
|
9
9
|
exit 1
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
path = Pathname.new(ARGV.shift).realpath
|
13
|
+
platform = ARGV.shift&.to_sym || :ios
|
14
|
+
XCFrameworkConverter.convert_framework_to_xcframework(path, platform)
|
@@ -20,21 +20,24 @@ module XCFrameworkConverter
|
|
20
20
|
Pathname.new(__FILE__).dirname.join('../xcframework_template.plist')
|
21
21
|
end
|
22
22
|
|
23
|
-
def convert_framework_to_xcframework(path)
|
23
|
+
def convert_framework_to_xcframework(path, platform)
|
24
24
|
plist = Xcodeproj::Plist.read_from_path(plist_template_path)
|
25
25
|
xcframework_path = Pathname.new(path).sub_ext('.xcframework')
|
26
26
|
xcframework_path.mkdir
|
27
27
|
plist['AvailableLibraries'].each do |slice|
|
28
|
-
|
28
|
+
slice_library_identifier = slice['LibraryIdentifier'].sub('platform', platform.to_s)
|
29
|
+
slice_path = xcframework_path.join(slice_library_identifier)
|
29
30
|
slice_path.mkdir
|
30
31
|
slice['LibraryPath'] = File.basename(path)
|
32
|
+
slice['SupportedPlatform'] = platform.to_s
|
33
|
+
slice['LibraryIdentifier'] = slice_library_identifier
|
31
34
|
FileUtils.cp_r(path, slice_path)
|
32
35
|
end
|
33
36
|
Xcodeproj::Plist.write_to_path(plist, xcframework_path.join('Info.plist'))
|
34
37
|
FileUtils.rm_rf(path)
|
35
38
|
final_framework = Pod::Xcode::XCFramework.open_xcframework(xcframework_path)
|
36
39
|
final_framework.slices.each do |slice|
|
37
|
-
ArmPatcher.patch_arm_binary(slice) if slice.platform ==
|
40
|
+
ArmPatcher.patch_arm_binary(slice) if slice.platform == platform && slice.platform_variant == :simulator
|
38
41
|
ArmPatcher.cleanup_unused_archs(slice)
|
39
42
|
end
|
40
43
|
end
|
@@ -18,18 +18,33 @@ module XCFrameworkConverter
|
|
18
18
|
class << self
|
19
19
|
def patch_xcframework(xcframework_path)
|
20
20
|
xcframework = Pod::Xcode::XCFramework.open_xcframework(xcframework_path)
|
21
|
+
slices_to_convert = xcframework.slices.select do |slice|
|
22
|
+
slice.platform != :osx &&
|
23
|
+
slice.platform_variant != :simulator &&
|
24
|
+
slice.supported_archs.include?('arm64')
|
25
|
+
end
|
26
|
+
|
27
|
+
slices_to_convert.each do |slice|
|
28
|
+
patch_xcframework_impl(xcframework_path, slice.platform.name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def patch_xcframework_impl(xcframework_path, platform)
|
35
|
+
xcframework = Pod::Xcode::XCFramework.open_xcframework(xcframework_path)
|
21
36
|
|
22
37
|
return nil if xcframework.slices.any? do |slice|
|
23
|
-
slice.platform ==
|
38
|
+
slice.platform == platform &&
|
24
39
|
slice.platform_variant == :simulator &&
|
25
40
|
slice.supported_archs.include?('arm64')
|
26
41
|
end
|
27
42
|
|
28
43
|
original_arm_slice_identifier = xcframework.slices.find do |slice|
|
29
|
-
slice.platform ==
|
44
|
+
slice.platform == platform && slice.supported_archs.include?('arm64')
|
30
45
|
end.identifier
|
31
46
|
|
32
|
-
patched_arm_slice_identifier =
|
47
|
+
patched_arm_slice_identifier = "#{platform}-arm64-simulator"
|
33
48
|
|
34
49
|
warn "Will patch #{xcframework_path}: #{original_arm_slice_identifier} -> #{patched_arm_slice_identifier}"
|
35
50
|
|
@@ -39,8 +39,8 @@ module XCFrameworkConverter
|
|
39
39
|
after_rename = before_rename.map { |f| Pathname.new(f).sub_ext('.xcframework').to_s }
|
40
40
|
proxy = Pod::Specification::DSL::PlatformProxy.new(spec, platform.symbolic_name)
|
41
41
|
proxy.vendored_frameworks = consumer.vendored_frameworks - before_rename + after_rename
|
42
|
-
before_rename.map { |f| pod_path.join(f) }
|
43
|
-
end.flatten.uniq
|
42
|
+
before_rename.map { |f| [pod_path.join(f), platform.symbolic_name] }
|
43
|
+
end.flatten(1).uniq
|
44
44
|
|
45
45
|
convert_xcframeworks_if_present(frameworks_to_convert)
|
46
46
|
|
@@ -53,8 +53,8 @@ module XCFrameworkConverter
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def convert_xcframeworks_if_present(frameworks_to_convert)
|
56
|
-
frameworks_to_convert.each do |path|
|
57
|
-
convert_framework_to_xcframework(path) if Dir.exist?(path)
|
56
|
+
frameworks_to_convert.each do |path, platform|
|
57
|
+
convert_framework_to_xcframework(path, platform) if Dir.exist?(path)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -65,21 +65,31 @@ module XCFrameworkConverter
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def remove_troublesome_xcconfig_items(spec)
|
68
|
+
# some pods put these as a way to NOT support arm64 sim
|
69
|
+
# may stop working if a pod decides to put these in a platform proxy
|
70
|
+
|
68
71
|
xcconfigs = %w[
|
69
72
|
pod_target_xcconfig
|
70
73
|
user_target_xcconfig
|
71
74
|
].map { |key| spec.attributes_hash[key] }.compact
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
platforms = %w[
|
77
|
+
iphonesimulator
|
78
|
+
appletvsimulator
|
79
|
+
watchsimulator
|
80
|
+
]
|
81
|
+
|
82
|
+
(xcconfigs.product platforms).each do |xcconfig, platform|
|
83
|
+
excluded_archs_key = "EXCLUDED_ARCHS[sdk=#{platform}*]"
|
84
|
+
inlcuded_arch_key = "VALID_ARCHS[sdk=#{platform}*]"
|
85
|
+
|
86
|
+
excluded_arm = xcconfig[excluded_archs_key]&.include?('arm64')
|
87
|
+
not_inlcuded_arm = xcconfig[inlcuded_arch_key] && !xcconfig[inlcuded_arch_key].include?('arm64')
|
78
88
|
|
79
89
|
remember_spec_as_patched(spec) if excluded_arm || not_inlcuded_arm
|
80
90
|
|
81
|
-
xcconfig.delete(
|
82
|
-
xcconfig.delete(
|
91
|
+
xcconfig.delete(excluded_archs_key)
|
92
|
+
xcconfig.delete(inlcuded_arch_key)
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>
|
9
|
+
<string>platform-arm64_x86_64-simulator</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>Placeholder.framework</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
</dict>
|
22
22
|
<dict>
|
23
23
|
<key>LibraryIdentifier</key>
|
24
|
-
<string>
|
24
|
+
<string>platform-arm64_armv7</string>
|
25
25
|
<key>LibraryPath</key>
|
26
26
|
<string>Placeholder.framework</string>
|
27
27
|
<key>SupportedArchitectures</key>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
<string>armv7</string>
|
31
31
|
</array>
|
32
32
|
<key>SupportedPlatform</key>
|
33
|
-
<string>
|
33
|
+
<string>platform</string>
|
34
34
|
</dict>
|
35
35
|
</array>
|
36
36
|
<key>CFBundlePackageType</key>
|
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.7.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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|