xcframework_converter 0.2.0 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 105e63e07d147cd791c478f9351e73e1f71bbd861160b5a1391d99c7c0affc9d
4
- data.tar.gz: cf2e6a358aeb0a7018d06a2bf48382ab01d768eb870589da0abddab7044278e3
3
+ metadata.gz: b4026adcb50f4a5beae016b1df87c2b95c84062d3ddb5f4aa480127ef334d0ef
4
+ data.tar.gz: 6b4b75587762fa609056196b16c2560065db7351924dafe4915ca158a10fb1d0
5
5
  SHA512:
6
- metadata.gz: fe005277c05790de2d906188fbc0ab3818b9dd27980bf68bdeb2e56ec3ef2f0184fc61224ddeb32c29689ad316f3179eb51dd4a3345bf423bdd7cd5d75569697
7
- data.tar.gz: '0805b456eebbfc655bd5991c001b241b29bf614f154615be67be7124d3bc1fc95532a0612647ac1d56e05d10373c97c7f6e14489adb68481e24e6b5a03ff89c6'
6
+ metadata.gz: c9460cf57bfb886843148ae1353759c57149ff4de6d1963f363e094354bf2290277e1c4bc409c259ee968a65cee3f97190754717d0a9ad4871dac957276705fe
7
+ data.tar.gz: 0c63408a190166c3f9ca44de4734497e91ff57c1574738647e3eebe7ca6a07deba9d6deacb16a9fcc04d8e39e7f80cd8989c3b8d146a5c501e6f796646a66d9b
data/bin/xcfpatch ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'xcframework_converter'
6
+
7
+ if ARGV.empty?
8
+ warn 'Usage: xcfpatch <path/to/XCFramework.xcframework>'
9
+ exit 1
10
+ end
11
+
12
+ XCFrameworkConverter.patch_xcframework(Pathname.new(ARGV[0]).realpath)
data/lib/arm2sim.swift CHANGED
@@ -77,8 +77,10 @@ enum Transmogrifier {
77
77
 
78
78
  let offsetSections = sections.map { section -> section_64 in
79
79
  var section = section
80
- section.offset += UInt32(offset)
81
- section.reloff += section.reloff > 0 ? UInt32(offset) : 0
80
+ if section.flags != S_ZEROFILL {
81
+ section.offset += UInt32(offset)
82
+ section.reloff += section.reloff > 0 ? UInt32(offset) : 0
83
+ }
82
84
  return section
83
85
  }
84
86
 
@@ -56,7 +56,9 @@ module XCFrameworkConverter
56
56
  file = MachO::MachOFile.new(object_file)
57
57
  sdk_version = file[:LC_VERSION_MIN_IPHONEOS].first.version_string.to_i
58
58
  `xcrun swift \"#{arm2sim_path}\" \"#{object_file}\" \"#{sdk_version}\" \"#{sdk_version}\"`
59
+ $stderr.printf '.'
59
60
  end
61
+ $stderr.puts
60
62
  `cd \"#{extracted_path_dir}\" ; ar crv \"#{extracted_path}\" *.o`
61
63
 
62
64
  `xcrun lipo \"#{slice.binary_path}\" -replace arm64 \"#{extracted_path}\" -output \"#{slice.binary_path}\"`
@@ -31,7 +31,7 @@ module XCFrameworkConverter
31
31
 
32
32
  patched_arm_slice_identifier = 'ios-arm64-simulator'
33
33
 
34
- STDERR.puts "Will patch #{xcframework_path}: #{original_arm_slice_identifier} -> #{patched_arm_slice_identifier}"
34
+ warn "Will patch #{xcframework_path}: #{original_arm_slice_identifier} -> #{patched_arm_slice_identifier}"
35
35
 
36
36
  plist = xcframework.plist
37
37
  slice_plist_to_add = plist['AvailableLibraries'].find { |s| s['LibraryIdentifier'] == original_arm_slice_identifier }.dup
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XCFrameworkConverter
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.2'
5
5
  end
@@ -29,7 +29,7 @@ module XCFrameworkConverter
29
29
  .map { |f| pod_path.join(f) }
30
30
  end.flatten.uniq
31
31
 
32
- patch_xcframeworks_if_needed(spec, xcframeworks_to_patch)
32
+ patch_xcframeworks_if_needed(xcframeworks_to_patch)
33
33
 
34
34
  frameworks_to_convert = spec.available_platforms.map do |platform|
35
35
  consumer = Pod::Specification::Consumer.new(spec, platform)
@@ -42,33 +42,48 @@ module XCFrameworkConverter
42
42
  before_rename.map { |f| pod_path.join(f) }
43
43
  end.flatten.uniq
44
44
 
45
- convert_xcframeworks_if_present(spec, frameworks_to_convert)
45
+ remember_spec_as_patched(spec) unless frameworks_to_convert.empty?
46
+
47
+ remove_troublesome_xcconfig_items(spec)
46
48
  end
49
+
50
+ warn "Specs with patched XCFrameworks: #{@patched_specs.sort.join(', ')}"
47
51
  end
48
52
 
49
- def convert_xcframeworks_if_present(spec, frameworks_to_convert)
53
+ def convert_xcframeworks_if_present(frameworks_to_convert)
50
54
  frameworks_to_convert.each do |path|
51
55
  convert_framework_to_xcframework(path) if Dir.exist?(path)
52
56
  end
53
- remove_troublesome_xcconfig_items(spec) unless frameworks_to_convert.empty?
54
57
  end
55
58
 
56
- def patch_xcframeworks_if_needed(spec, xcframeworks)
57
- patched = xcframeworks.map do |path|
58
- next nil unless Dir.exist?(path)
59
-
60
- patch_xcframework(path)
61
- end.compact
62
- remove_troublesome_xcconfig_items(spec) unless patched.empty?
59
+ def patch_xcframeworks_if_needed(xcframeworks)
60
+ xcframeworks.each do |path|
61
+ patch_xcframework(path) if Dir.exist?(path)
62
+ end
63
63
  end
64
64
 
65
65
  def remove_troublesome_xcconfig_items(spec)
66
- # some pods put these as a way to NOT support arm64 sim
67
- # may stop working if a pod decides to put these in a platform proxy
68
- spec.attributes_hash['pod_target_xcconfig']&.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
69
- spec.attributes_hash['user_target_xcconfig']&.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
70
- spec.attributes_hash['pod_target_xcconfig']&.delete('VALID_ARCHS[sdk=iphonesimulator*]')
71
- spec.attributes_hash['user_target_xcconfig']&.delete('VALID_ARCHS[sdk=iphonesimulator*]')
66
+ xcconfigs = %w[
67
+ pod_target_xcconfig
68
+ user_target_xcconfig
69
+ ].map { |key| spec.attributes_hash[key] }.compact
70
+
71
+ xcconfigs.each do |xcconfig|
72
+ # some pods put these as a way to NOT support arm64 sim
73
+ # may stop working if a pod decides to put these in a platform proxy
74
+ excluded_arm = xcconfig['EXCLUDED_ARCHS[sdk=iphonesimulator*]']&.include?('arm64')
75
+ not_inlcuded_arm = xcconfig['VALID_ARCHS[sdk=iphonesimulator*]'] && !xcconfig['VALID_ARCHS[sdk=iphonesimulator*]'].include?('arm64')
76
+
77
+ remember_spec_as_patched(spec) if excluded_arm || not_inlcuded_arm
78
+
79
+ xcconfig.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
80
+ xcconfig.delete('VALID_ARCHS[sdk=iphonesimulator*]')
81
+ end
82
+ end
83
+
84
+ def remember_spec_as_patched(spec)
85
+ @patched_specs ||= Set.new
86
+ @patched_specs << spec.root.name
72
87
  end
73
88
  end
74
89
  end
metadata CHANGED
@@ -1,66 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcframework_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.2
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-01-09 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.10.0
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '1'
19
+ version: '1.10'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.10.0
30
24
  - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '1'
26
+ version: '1.10'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: xcodeproj
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 1.20.0
40
31
  - - "~>"
41
32
  - !ruby/object:Gem::Version
42
- version: '1'
33
+ version: '1.20'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.20.0
50
38
  - - "~>"
51
39
  - !ruby/object:Gem::Version
52
- version: '1'
40
+ version: '1.20'
53
41
  description: Convert an ancient .framework (dynamic or static) to an .xcframework.
54
42
  Add an arm64 Simulator patch.
55
43
  email:
56
44
  - igormaka@gmail.com
57
45
  executables:
58
46
  - xcfconvert
47
+ - xcfpatch
59
48
  extensions: []
60
49
  extra_rdoc_files: []
61
50
  files:
62
51
  - README.md
63
52
  - bin/xcfconvert
53
+ - bin/xcfpatch
64
54
  - lib/arm2sim.swift
65
55
  - lib/xcframework_converter.rb
66
56
  - lib/xcframework_converter/arm_patcher.rb