cocoapods-mangle 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cocoapods_mangle/defines.rb +29 -0
- data/lib/cocoapods_mangle/gem_version.rb +1 -1
- data/spec/integration/integration_spec.rb +95 -44
- data/spec/unit/defines_spec.rb +1 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12bdc6a5d84c28840e77fd5b88b8a460460eec6886e77a069dd09764e7288d88
|
4
|
+
data.tar.gz: 5d8d4f20a4ddc3a6d0f580e9e27fc1836989a2ea47e62c69033d1c6354acdfdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0d0292dc9c564f905f3e140c6401dffecf45fbfb4df9659365219d33486ea7c22c24beb3730fa494be71fd5f7cfe3d80c2bce6dbb4b54edbb5e382e73f1cbf8
|
7
|
+
data.tar.gz: 7400bc11b992f41aeb45f2f1747c6eb1f90c5cb9196425a0827632f063085a57e4e515d6da08e10e75c11452dd0e96619e0e4eefae33b60f108fee26f4b67663
|
@@ -23,6 +23,8 @@ module CocoapodsMangle
|
|
23
23
|
# @return [Array<String>] The classes defined in the binaries
|
24
24
|
def self.classes(binaries)
|
25
25
|
all_symbols = run_nm(binaries, '-gU')
|
26
|
+
all_symbols = all_symbols.reject { |symbol| swift_symbol?(symbol) }
|
27
|
+
|
26
28
|
class_symbols = all_symbols.select do |symbol|
|
27
29
|
symbol[/OBJC_CLASS_\$_/]
|
28
30
|
end
|
@@ -36,6 +38,8 @@ module CocoapodsMangle
|
|
36
38
|
# @return [Array<String>] The constants defined in the binaries
|
37
39
|
def self.constants(binaries)
|
38
40
|
all_symbols = run_nm(binaries, '-gU')
|
41
|
+
all_symbols = all_symbols.reject { |symbol| swift_symbol?(symbol) }
|
42
|
+
|
39
43
|
consts = all_symbols.select { |const| const[/ S /] }
|
40
44
|
consts = consts.reject { |const| const[/_OBJC_/] }
|
41
45
|
consts = consts.reject { |const| const[/__block_descriptor.*/] }
|
@@ -110,6 +114,31 @@ module CocoapodsMangle
|
|
110
114
|
defines
|
111
115
|
end
|
112
116
|
|
117
|
+
# Is symbol a Swift symbol? This is used to avoid mangling Swift.
|
118
|
+
# @param [String] symbol
|
119
|
+
# The symbol to check
|
120
|
+
# @return [Boolean] true if it is a Swift symbol, false otherwise
|
121
|
+
def self.swift_symbol?(symbol)
|
122
|
+
# Swift binaries have many symbols starting with $s_ that should be excluded
|
123
|
+
# e.g. '0000000000000258 S _$s9ManglePod9SomeClassCMF'
|
124
|
+
symbol[/ _\$s/] ||
|
125
|
+
# Internal Swift symbols starting with __swift or ___swift such as should not be mangled
|
126
|
+
# e.g. '00000000000050ac S ___swift_reflection_version'
|
127
|
+
symbol[/ __(_)?swift/] ||
|
128
|
+
# Swift symbols starting with _symbolic should be ignored
|
129
|
+
# e.g. '0000000000000248 S _symbolic _____ 9ManglePod9SomeClassC'
|
130
|
+
symbol[/ _symbolic/] ||
|
131
|
+
# Swift symbol references to Objective-C symbols should not be mangled
|
132
|
+
# e.g. '00000000000108ca S _associated conformance So26SCNetworkReachabilityFlagsVs10SetAlgebraSCSQ'
|
133
|
+
symbol[/associated conformance/] ||
|
134
|
+
# _globalinit symbols should be skipped
|
135
|
+
# e.g. 0000000000000000 T _globalinit_33_A313450CFC1FC3D0CBEF4411412DB9E8_func0
|
136
|
+
symbol[/ _globalinit/] ||
|
137
|
+
# Swift classes inheriting from Objective-C classes should not be mangled
|
138
|
+
# e.g. '0000000000000290 S _OBJC_CLASS_$__TtC9ManglePod19SomeFoundationClass'
|
139
|
+
symbol[/_OBJC_CLASS_\$__/]
|
140
|
+
end
|
141
|
+
|
113
142
|
def self.run_nm(binaries, flags)
|
114
143
|
`nm #{flags} #{binaries.join(' ')}`.split("\n")
|
115
144
|
end
|
@@ -36,60 +36,111 @@ describe CocoapodsMangle do
|
|
36
36
|
before(:each) do
|
37
37
|
fixtures_dir = File.expand_path("#{File.dirname(__FILE__)}/../fixtures")
|
38
38
|
FileUtils.copy_entry(File.join(fixtures_dir, 'project'), project_dir)
|
39
|
-
FileUtils.copy_entry(File.join(fixtures_dir,
|
39
|
+
FileUtils.copy_entry(File.join(fixtures_dir, podpsec_fixture_dir), pod_dir)
|
40
40
|
File.open(File.join(project_dir, 'Podfile'), 'w') do |podfile|
|
41
41
|
podfile.write(podfile_contents)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context
|
46
|
-
let(:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
context "with a Swift pod" do
|
46
|
+
let(:podpsec_fixture_dir) { "swift-pod" }
|
47
|
+
|
48
|
+
context 'without frameworks' do
|
49
|
+
let(:podfile_contents) do
|
50
|
+
<<~PODFILE
|
51
|
+
platform :ios, '10.0'
|
52
|
+
plugin 'cocoapods-mangle'
|
53
|
+
target 'Mangle Integration' do
|
54
|
+
pod 'ManglePod', path: '../pod'
|
55
|
+
pod 'Alamofire', '5.2.2'
|
56
|
+
end
|
57
|
+
PODFILE
|
58
|
+
end
|
59
|
+
let(:expected_defines) do
|
60
|
+
%w[
|
61
|
+
PodsDummy_ManglePod=Mangle_Integration_PodsDummy_ManglePod
|
62
|
+
PodsDummy_Alamofire=Mangle_Integration_PodsDummy_Alamofire
|
63
|
+
]
|
64
|
+
end
|
65
|
+
|
66
|
+
include_examples 'mangling integration'
|
64
67
|
end
|
65
68
|
|
66
|
-
|
69
|
+
context 'with frameworks' do
|
70
|
+
let(:podfile_contents) do
|
71
|
+
<<~PODFILE
|
72
|
+
platform :ios, '10.0'
|
73
|
+
use_frameworks!
|
74
|
+
plugin 'cocoapods-mangle'
|
75
|
+
target 'Mangle Integration' do
|
76
|
+
pod 'ManglePod', path: '../pod'
|
77
|
+
end
|
78
|
+
PODFILE
|
79
|
+
end
|
80
|
+
let(:expected_defines) do
|
81
|
+
%w[
|
82
|
+
ManglePodVersionNumber=Mangle_Integration_ManglePodVersionNumber
|
83
|
+
ManglePodVersionString=Mangle_Integration_ManglePodVersionString
|
84
|
+
PodsDummy_ManglePod=Mangle_Integration_PodsDummy_ManglePod
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
include_examples 'mangling integration'
|
89
|
+
end
|
67
90
|
end
|
68
91
|
|
69
|
-
context
|
70
|
-
let(:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
92
|
+
context "with an Objective-C pod" do
|
93
|
+
let(:podpsec_fixture_dir) { "objc-pod" }
|
94
|
+
|
95
|
+
context 'without frameworks' do
|
96
|
+
let(:podfile_contents) do
|
97
|
+
<<~PODFILE
|
98
|
+
platform :ios, '10.0'
|
99
|
+
plugin 'cocoapods-mangle'
|
100
|
+
target 'Mangle Integration' do
|
101
|
+
pod 'ManglePod', path: '../pod'
|
102
|
+
end
|
103
|
+
PODFILE
|
104
|
+
end
|
105
|
+
let(:expected_defines) do
|
106
|
+
%w[
|
107
|
+
PodsDummy_ManglePod=Mangle_Integration_PodsDummy_ManglePod
|
108
|
+
CPMObject=Mangle_Integration_CPMObject
|
109
|
+
CPMConstant=Mangle_Integration_CPMConstant
|
110
|
+
CPMStringFromIntegerFunction=Mangle_Integration_CPMStringFromIntegerFunction
|
111
|
+
cpm_doSomethingWithoutParams=Mangle_Integration_cpm_doSomethingWithoutParams
|
112
|
+
cpm_doSomethingWithParam=Mangle_Integration_cpm_doSomethingWithParam
|
113
|
+
]
|
114
|
+
end
|
115
|
+
|
116
|
+
include_examples 'mangling integration'
|
79
117
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
118
|
+
|
119
|
+
context 'with frameworks' do
|
120
|
+
let(:podfile_contents) do
|
121
|
+
<<~PODFILE
|
122
|
+
platform :ios, '10.0'
|
123
|
+
use_frameworks!
|
124
|
+
plugin 'cocoapods-mangle'
|
125
|
+
target 'Mangle Integration' do
|
126
|
+
pod 'ManglePod', path: '../pod'
|
127
|
+
end
|
128
|
+
PODFILE
|
129
|
+
end
|
130
|
+
let(:expected_defines) do
|
131
|
+
%w[
|
132
|
+
ManglePodVersionNumber=Mangle_Integration_ManglePodVersionNumber
|
133
|
+
ManglePodVersionString=Mangle_Integration_ManglePodVersionString
|
134
|
+
PodsDummy_ManglePod=Mangle_Integration_PodsDummy_ManglePod
|
135
|
+
CPMObject=Mangle_Integration_CPMObject
|
136
|
+
CPMConstant=Mangle_Integration_CPMConstant
|
137
|
+
CPMStringFromIntegerFunction=Mangle_Integration_CPMStringFromIntegerFunction
|
138
|
+
cpm_doSomethingWithoutParams=Mangle_Integration_cpm_doSomethingWithoutParams
|
139
|
+
cpm_doSomethingWithParam=Mangle_Integration_cpm_doSomethingWithParam
|
140
|
+
]
|
141
|
+
end
|
142
|
+
|
143
|
+
include_examples 'mangling integration'
|
91
144
|
end
|
92
|
-
|
93
|
-
include_examples 'mangling integration'
|
94
145
|
end
|
95
146
|
end
|
data/spec/unit/defines_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-mangle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Treanor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -72,8 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 2.5.2.1
|
75
|
+
rubygems_version: 3.0.3
|
77
76
|
signing_key:
|
78
77
|
specification_version: 4
|
79
78
|
summary: A CocoaPods plugin which mangles the symbols of your dependencies
|