Skip to content

Commit 53c1bc5

Browse files
authored
Improve Filtering of Swift Symbols (#28)
* Improve Filtering of Swift Symbols - If an Objective-C class has the title `Swift` in it e.g `SentrySwiftAsyncIntegration` then it was being excluded from the list of symbols to mangle. - Added improved Swift Symbol filtering so that we only target actual Swift symbols
1 parent d7eb290 commit 53c1bc5

File tree

7 files changed

+45
-26
lines changed

7 files changed

+45
-26
lines changed

Gemfile.lock

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
cocoapods-mangle (1.1.4)
5-
cocoapods (~> 1.14)
4+
cocoapods-mangle (1.1.5)
5+
cocoapods (~> 1.15)
66

77
GEM
88
remote: https://rubygems.org/
@@ -21,10 +21,10 @@ GEM
2121
json (>= 1.5.1)
2222
atomos (0.1.3)
2323
claide (1.1.0)
24-
cocoapods (1.14.3)
24+
cocoapods (1.15.2)
2525
addressable (~> 2.8)
2626
claide (>= 1.0.2, < 2.0)
27-
cocoapods-core (= 1.14.3)
27+
cocoapods-core (= 1.15.2)
2828
cocoapods-deintegrate (>= 1.0.3, < 2.0)
2929
cocoapods-downloader (>= 2.1, < 3.0)
3030
cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -39,7 +39,7 @@ GEM
3939
nap (~> 1.0)
4040
ruby-macho (>= 2.3.0, < 3.0)
4141
xcodeproj (>= 1.23.0, < 2.0)
42-
cocoapods-core (1.14.3)
42+
cocoapods-core (1.15.2)
4343
activesupport (>= 5.0, < 8)
4444
addressable (~> 2.8)
4545
algoliasearch (~> 1.0)
@@ -61,7 +61,7 @@ GEM
6161
coderay (1.1.3)
6262
colored2 (3.1.2)
6363
concurrent-ruby (1.2.3)
64-
diff-lcs (1.4.4)
64+
diff-lcs (1.5.1)
6565
escape (0.0.4)
6666
ethon (0.16.0)
6767
ffi (>= 1.15.0)
@@ -74,41 +74,41 @@ GEM
7474
concurrent-ruby (~> 1.0)
7575
json (2.7.1)
7676
method_source (1.0.0)
77-
minitest (5.21.1)
77+
minitest (5.22.2)
7878
molinillo (0.8.0)
7979
nanaimo (0.3.0)
8080
nap (1.1.0)
8181
netrc (0.11.0)
82-
pry (0.13.1)
82+
pry (0.14.2)
8383
coderay (~> 1.1)
8484
method_source (~> 1.0)
8585
pry-remote (0.1.8)
8686
pry (~> 0.9)
8787
slop (~> 3.0)
8888
public_suffix (4.0.7)
8989
rexml (3.2.6)
90-
rspec (3.9.0)
91-
rspec-core (~> 3.9.0)
92-
rspec-expectations (~> 3.9.0)
93-
rspec-mocks (~> 3.9.0)
94-
rspec-core (3.9.2)
95-
rspec-support (~> 3.9.3)
96-
rspec-expectations (3.9.2)
90+
rspec (3.13.0)
91+
rspec-core (~> 3.13.0)
92+
rspec-expectations (~> 3.13.0)
93+
rspec-mocks (~> 3.13.0)
94+
rspec-core (3.13.0)
95+
rspec-support (~> 3.13.0)
96+
rspec-expectations (3.13.0)
9797
diff-lcs (>= 1.2.0, < 2.0)
98-
rspec-support (~> 3.9.0)
99-
rspec-mocks (3.9.1)
98+
rspec-support (~> 3.13.0)
99+
rspec-mocks (3.13.0)
100100
diff-lcs (>= 1.2.0, < 2.0)
101-
rspec-support (~> 3.9.0)
102-
rspec-support (3.9.3)
103-
rspec_junit_formatter (0.4.1)
101+
rspec-support (~> 3.13.0)
102+
rspec-support (3.13.0)
103+
rspec_junit_formatter (0.6.0)
104104
rspec-core (>= 2, < 4, != 2.12.0)
105105
ruby-macho (2.5.1)
106106
slop (3.6.0)
107107
typhoeus (1.4.1)
108108
ethon (>= 0.9.0)
109109
tzinfo (2.0.6)
110110
concurrent-ruby (~> 1.0)
111-
xcodeproj (1.23.0)
111+
xcodeproj (1.24.0)
112112
CFPropertyList (>= 2.3.3, < 4.0)
113113
atomos (~> 0.1.3)
114114
claide (>= 1.0.2, < 2.0)

cocoapods-mangle.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
1717
spec.test_files = Dir['spec/**/*.rb']
1818
spec.extra_rdoc_files = ['README.md', 'CHANGELOG.md']
1919
spec.require_paths = ['lib']
20-
spec.add_dependency 'cocoapods', '~> 1.14'
20+
spec.add_dependency 'cocoapods', '~> 1.15'
2121
end

lib/cocoapods_mangle/defines.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,15 @@ def self.swift_symbol?(symbol)
125125
# Internal Swift symbols starting with __swift or ___swift such as should not be mangled
126126
# e.g. '00000000000050ac S ___swift_reflection_version'
127127
symbol[/ __(_)?swift/] ||
128-
# Internal Swift symbols starting with Swift such as should not be mangled
129-
# e.g. 'Swift51Override'
130-
symbol[/Swift/] ||
128+
# Internal Swift symbols starting with digit+Swift+optional_digit should not be mangled
129+
# e.g. '34SwiftOverride', '34Swift570Override'
130+
symbol[/\d+Swift(\d+)?/] ||
131+
# Internal Swift symbols starting with Swift+digit should not be mangled
132+
# e.g. 'Swift570Override'
133+
symbol[/Swift\d+/] ||
134+
# Internal SwiftUI symbols starting with digit+SwiftUI+optional_digit such as should not be mangled
135+
# e.g. '55SwiftUI', '55SwiftUI45'
136+
symbol[/\d+SwiftUI(\d+)?/] ||
131137
# Swift symbols starting with symbolic should be ignored
132138
# e.g. '0000000000000248 S symbolic _____ 9ManglePod9SomeClassC'
133139
symbol[/symbolic /] ||
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module CocoapodsMangle
22
NAME = 'cocoapods-mangle'
3-
VERSION = '1.1.4'
3+
VERSION = '1.1.5'
44
end

spec/fixtures/symbols/all_defined_symbols.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,9 +1208,15 @@ libManglePod.a(SomeFunc.o):
12081208
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
12091209
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
12101210
0000000000000012 s l_llvm.swift_module_hash
1211+
0000000000000012 S someSwift50Overrides
1212+
0000000000000012 S someSwiftUI50Overrides
12111213

12121214
libManglePod.a(SomeStruct.o):
12131215
0000000000000010 S ___swift_reflection_version
12141216
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
12151217
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
12161218
0000000000000012 s l_llvm.swift_module_hash
1219+
1220+
libManglePod.a(BrianSwiftAsyncIntegration.o):
1221+
0000000000000118 S _OBJC_CLASS_$_BrianSwiftAsyncIntegration
1222+
00000000000000f0 S _OBJC_METACLASS_$_BrianSwiftAsyncIntegration

spec/fixtures/symbols/non_global_defined_symbols.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,14 @@ libManglePod.a(SomeFunc.o):
252252
0000000000000010 S ___swift_reflection_version
253253
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
254254
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
255+
0000000000000012 S __swift_someSwift50Overrides
256+
0000000000000012 S __swift_someSwiftUI50Overrides
255257

256258
libManglePod.a(SomeStruct.o):
257259
0000000000000010 S ___swift_reflection_version
258260
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
259261
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
262+
263+
libManglePod.a(BrianSwiftAsyncIntegration.o):
264+
0000000000000118 S _OBJC_CLASS_$_BrianSwiftAsyncIntegration
265+
00000000000000f0 S _OBJC_METACLASS_$_BrianSwiftAsyncIntegration

spec/unit/defines_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
FLAnimatedImage
3636
FLWeakProxy
3737
FLAnimatedImageView
38+
BrianSwiftAsyncIntegration
3839
]
3940
end
4041

0 commit comments

Comments
 (0)