xcframework_converter 0.2.1 → 0.3.3

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: 5109f0543cf6df9ebebacdcdc107e1a9bdfc11e365d918d62775678a9742a51a
4
- data.tar.gz: 76cbc87f54d47b30e6c371f72c6855439e359eb620c0971821985b8c5697ad42
3
+ metadata.gz: 9b2d19f2b78a5ddedb9c26708a8ead42cfe3a76a21dfeeb244f6f9e49f835ef2
4
+ data.tar.gz: 5334b7a2cea325d36a5e15ca30cd14aafd47c49a40f99fb0ff5e2ff45094edd9
5
5
  SHA512:
6
- metadata.gz: 3a5650ef13956e95ee516e8d226afa1f282baf3c6268ea52b267c9fb0b5854aa6fc60a9bdf14e315e2274642f584c493da1231f111959f7494875a8d28dc253a
7
- data.tar.gz: 545cff6294e8dc3734d0599a03dd40f48e0b1016bd7df06e0efba44e9b297373d64cded2c84004961cd3504b0aed9e2d7595ceda162a0f85d36abc8a318efabd
6
+ metadata.gz: 519151d17e2cb3aa6c4140ee9bf4c05b55b4deb1582508271d99e6d9fb26a4f8c450b60b9f9b3c9ed590d8fd7c7b352ec1624e5a294b3a31700bf74a626c4205
7
+ data.tar.gz: fc7b29d598afe23fc1d3047dcc2446bb160986da8b8297b81ef9b8103e18635104f0ea043898c4c7ff3d27b03e1a38c673ece942c8b084bbc1292d0ab9eccd40
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}\"`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XCFrameworkConverter
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.3'
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,31 +42,50 @@ 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
+ convert_xcframeworks_if_present(frameworks_to_convert)
46
+
47
+ remember_spec_as_patched(spec) unless frameworks_to_convert.empty?
46
48
 
47
49
  remove_troublesome_xcconfig_items(spec)
48
50
  end
51
+
52
+ warn "Specs with patched XCFrameworks: #{@patched_specs.sort.join(', ')}"
49
53
  end
50
54
 
51
- def convert_xcframeworks_if_present(spec, frameworks_to_convert)
55
+ def convert_xcframeworks_if_present(frameworks_to_convert)
52
56
  frameworks_to_convert.each do |path|
53
57
  convert_framework_to_xcframework(path) if Dir.exist?(path)
54
58
  end
55
59
  end
56
60
 
57
- def patch_xcframeworks_if_needed(spec, xcframeworks)
61
+ def patch_xcframeworks_if_needed(xcframeworks)
58
62
  xcframeworks.each do |path|
59
63
  patch_xcframework(path) if Dir.exist?(path)
60
64
  end
61
65
  end
62
66
 
63
67
  def remove_troublesome_xcconfig_items(spec)
64
- # some pods put these as a way to NOT support arm64 sim
65
- # may stop working if a pod decides to put these in a platform proxy
66
- spec.attributes_hash['pod_target_xcconfig']&.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
67
- spec.attributes_hash['user_target_xcconfig']&.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
68
- spec.attributes_hash['pod_target_xcconfig']&.delete('VALID_ARCHS[sdk=iphonesimulator*]')
69
- spec.attributes_hash['user_target_xcconfig']&.delete('VALID_ARCHS[sdk=iphonesimulator*]')
68
+ xcconfigs = %w[
69
+ pod_target_xcconfig
70
+ user_target_xcconfig
71
+ ].map { |key| spec.attributes_hash[key] }.compact
72
+
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')
78
+
79
+ remember_spec_as_patched(spec) if excluded_arm || not_inlcuded_arm
80
+
81
+ xcconfig.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
82
+ xcconfig.delete('VALID_ARCHS[sdk=iphonesimulator*]')
83
+ end
84
+ end
85
+
86
+ def remember_spec_as_patched(spec)
87
+ @patched_specs ||= Set.new
88
+ @patched_specs << spec.root.name
70
89
  end
71
90
  end
72
91
  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.1
4
+ version: 0.3.3
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