xcframework_converter 0.6.0 → 0.7.1

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: 77324350e0b69d68739d71e4e2bd510b2c46e82076d82c066eb1af2ab7019ff0
4
- data.tar.gz: dd8c817ba142772da87f18c46fffe50f32e2bad22d4bb8a9e3101650b38818a0
3
+ metadata.gz: 35dfe6daaed9a14ce70ce476912803dcb85c523827e3e98ae43b1855ba3d57d5
4
+ data.tar.gz: c8b6704a6203a759d4018a0d361254ff787a7ff7eb7fc0fb0c611bf709fe1b4e
5
5
  SHA512:
6
- metadata.gz: e7a7693803108e192822db1f4ab0de16bed32d4dc134dd3a69b1b6e54eab4e185e4d466d0626ecd46adc4c0bee677de8a9b8ca28d99485a0f5975147133cd94b
7
- data.tar.gz: 59a9cac8d54309ddd9efea3901425ad5499cccac741cd6d35cb4a493794a8cf35d083ad63ba6e0528065cd717ee1521c7a8794cd445d2093813f65336af9209e
6
+ metadata.gz: 66110d117bc3ad0da9be586b2943d18044efb5f288f21ddeaca14e7747b8406c45aad64d274e921ed94a2d8df02c82b40a95b7e5d87c79772524b4d20af8f8ca
7
+ data.tar.gz: a9e3f1bb7d58bef415767bc22c6c11fe65db6d38892bcf6a5faf43ecd8c2f79deae4ef0b9246c4cd720df5d2575a4a101aefc4d078da266cab192cefdba7f354
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
- XCFrameworkConverter.convert_framework_to_xcframework(Pathname.new(ARGV[0]).realpath)
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
- slice_path = xcframework_path.join(slice['LibraryIdentifier'])
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 == :ios && slice.platform_variant == :simulator
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 == :ios &&
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 == :ios && slice.supported_archs.include?('arm64')
44
+ slice.platform == platform && slice.supported_archs.include?('arm64')
30
45
  end.identifier
31
46
 
32
- patched_arm_slice_identifier = 'ios-arm64-simulator'
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XCFrameworkConverter
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.1'
5
5
  end
@@ -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
 
@@ -49,12 +49,12 @@ module XCFrameworkConverter
49
49
  remove_troublesome_xcconfig_items(spec)
50
50
  end
51
51
 
52
- warn "Specs with patched XCFrameworks: #{@patched_specs.sort.join(', ')}"
52
+ warn "Specs with patched XCFrameworks: #{patched_specs.sort.join(', ')}"
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,27 +65,40 @@ 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
- xcconfigs.each do |xcconfig|
74
- # some pods put these as a way to NOT support arm64 sim
75
- # may stop working if a pod decides to put these in a platform proxy
76
- excluded_arm = xcconfig['EXCLUDED_ARCHS[sdk=iphonesimulator*]']&.include?('arm64')
77
- not_inlcuded_arm = xcconfig['VALID_ARCHS[sdk=iphonesimulator*]'] && !xcconfig['VALID_ARCHS[sdk=iphonesimulator*]'].include?('arm64')
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('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
82
- xcconfig.delete('VALID_ARCHS[sdk=iphonesimulator*]')
91
+ xcconfig.delete(excluded_archs_key)
92
+ xcconfig.delete(inlcuded_arch_key)
83
93
  end
84
94
  end
85
95
 
86
96
  def remember_spec_as_patched(spec)
97
+ patched_specs << spec.root.name
98
+ end
99
+
100
+ def patched_specs
87
101
  @patched_specs ||= Set.new
88
- @patched_specs << spec.root.name
89
102
  end
90
103
  end
91
104
  end
@@ -6,7 +6,7 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_x86_64-simulator</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>ios-arm64_armv7</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>ios</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.6.0
4
+ version: 0.7.1
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-23 00:00:00.000000000 Z
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.1.4
86
+ rubygems_version: 3.1.6
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Convert an ancient .framework to an .xcframework.