Skip to content

Commit

Permalink
Improve Filtering of Swift Symbols (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Br1an-Boyle authored Feb 16, 2024
1 parent d7eb290 commit 53c1bc5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 26 deletions.
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
cocoapods-mangle (1.1.4)
cocoapods (~> 1.14)
cocoapods-mangle (1.1.5)
cocoapods (~> 1.15)

GEM
remote: https://rubygems.org/
Expand All @@ -21,10 +21,10 @@ GEM
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -39,7 +39,7 @@ GEM
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -61,7 +61,7 @@ GEM
coderay (1.1.3)
colored2 (3.1.2)
concurrent-ruby (1.2.3)
diff-lcs (1.4.4)
diff-lcs (1.5.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
Expand All @@ -74,41 +74,41 @@ GEM
concurrent-ruby (~> 1.0)
json (2.7.1)
method_source (1.0.0)
minitest (5.21.1)
minitest (5.22.2)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
pry (0.13.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
public_suffix (4.0.7)
rexml (3.2.6)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
ruby-macho (2.5.1)
slop (3.6.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
2 changes: 1 addition & 1 deletion cocoapods-mangle.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
spec.test_files = Dir['spec/**/*.rb']
spec.extra_rdoc_files = ['README.md', 'CHANGELOG.md']
spec.require_paths = ['lib']
spec.add_dependency 'cocoapods', '~> 1.14'
spec.add_dependency 'cocoapods', '~> 1.15'
end
12 changes: 9 additions & 3 deletions lib/cocoapods_mangle/defines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,15 @@ def self.swift_symbol?(symbol)
# Internal Swift symbols starting with __swift or ___swift such as should not be mangled
# e.g. '00000000000050ac S ___swift_reflection_version'
symbol[/ __(_)?swift/] ||
# Internal Swift symbols starting with Swift such as should not be mangled
# e.g. 'Swift51Override'
symbol[/Swift/] ||
# Internal Swift symbols starting with digit+Swift+optional_digit should not be mangled
# e.g. '34SwiftOverride', '34Swift570Override'
symbol[/\d+Swift(\d+)?/] ||
# Internal Swift symbols starting with Swift+digit should not be mangled
# e.g. 'Swift570Override'
symbol[/Swift\d+/] ||
# Internal SwiftUI symbols starting with digit+SwiftUI+optional_digit such as should not be mangled
# e.g. '55SwiftUI', '55SwiftUI45'
symbol[/\d+SwiftUI(\d+)?/] ||
# Swift symbols starting with symbolic should be ignored
# e.g. '0000000000000248 S symbolic _____ 9ManglePod9SomeClassC'
symbol[/symbolic /] ||
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods_mangle/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CocoapodsMangle
NAME = 'cocoapods-mangle'
VERSION = '1.1.4'
VERSION = '1.1.5'
end
6 changes: 6 additions & 0 deletions spec/fixtures/symbols/all_defined_symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,15 @@ libManglePod.a(SomeFunc.o):
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
0000000000000012 s l_llvm.swift_module_hash
0000000000000012 S someSwift50Overrides
0000000000000012 S someSwiftUI50Overrides

libManglePod.a(SomeStruct.o):
0000000000000010 S ___swift_reflection_version
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
0000000000000012 s l_llvm.swift_module_hash

libManglePod.a(BrianSwiftAsyncIntegration.o):
0000000000000118 S _OBJC_CLASS_$_BrianSwiftAsyncIntegration
00000000000000f0 S _OBJC_METACLASS_$_BrianSwiftAsyncIntegration
6 changes: 6 additions & 0 deletions spec/fixtures/symbols/non_global_defined_symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,14 @@ libManglePod.a(SomeFunc.o):
0000000000000010 S ___swift_reflection_version
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod
0000000000000012 S __swift_someSwift50Overrides
0000000000000012 S __swift_someSwiftUI50Overrides

libManglePod.a(SomeStruct.o):
0000000000000010 S ___swift_reflection_version
0000000000000000 S __swift_FORCE_LOAD_$_swiftCompatibility50_$_ManglePod
0000000000000008 S __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_ManglePod

libManglePod.a(BrianSwiftAsyncIntegration.o):
0000000000000118 S _OBJC_CLASS_$_BrianSwiftAsyncIntegration
00000000000000f0 S _OBJC_METACLASS_$_BrianSwiftAsyncIntegration
1 change: 1 addition & 0 deletions spec/unit/defines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
FLAnimatedImage
FLWeakProxy
FLAnimatedImageView
BrianSwiftAsyncIntegration
]
end

Expand Down

0 comments on commit 53c1bc5

Please sign in to comment.