Exclusions
Exclusions let you prevent specific symbols from being obfuscated. This is essential for symbols that must retain their original names at runtime, such as classes accessed via reflection or Interface Builder outlets.
How Exclusions Work
When you exclude a symbol, Shield preserves its original name in the protected binary. Exclusions apply to symbol renaming and do not affect other protections like string encryption or runtime protections.
Exclusions are configured in the symbol_renaming section of your configuration file using wildcard patterns.
Configuration
Add exclusion patterns to the exclude array in your symbol_renaming configuration:
{
"protections": {
"symbol_renaming": {
"enabled": true,
"exclude": [
"AppDelegate",
"SceneDelegate",
"*Delegate",
"*ViewController",
"*.xib",
"*.storyboard"
]
}
}
}{
"protections": {
"symbol_renaming": {
"enabled": true,
"exclude": [
"AppDelegate",
"SceneDelegate",
"*Delegate",
"*ViewController",
"*.xib",
"*.storyboard"
]
}
}
}Pattern Syntax
Exclusion patterns support wildcards:
| Pattern | Matches |
|---|---|
AppDelegate | Exact match for AppDelegate |
*Delegate | Any symbol ending in Delegate |
My* | Any symbol starting with My |
*View* | Any symbol containing View |
Common Exclusions
Interface Builder
If your application uses Storyboards or XIB files, exclude view controllers and outlets that are referenced by name:
{
"exclude": [
"*ViewController",
"*TableViewCell",
"*CollectionViewCell"
]
}{
"exclude": [
"*ViewController",
"*TableViewCell",
"*CollectionViewCell"
]
}Codable and Serialization
Classes that conform to Codable or use NSCoding need their property names preserved for serialization:
{
"exclude": [
"*Model",
"*Response",
"*Request"
]
}{
"exclude": [
"*Model",
"*Response",
"*Request"
]
}Objective-C Bridging
Symbols accessed from Objective-C via @objc annotations or bridging headers should be excluded:
{
"exclude": [
"*Bridge*",
"*Delegate"
]
}{
"exclude": [
"*Bridge*",
"*Delegate"
]
}Third-Party SDKs
If you use third-party SDKs that reference your classes by name (such as analytics, crash reporting, or deep linking), exclude those entry points:
{
"exclude": [
"AppDelegate",
"SceneDelegate",
"*Handler"
]
}{
"exclude": [
"AppDelegate",
"SceneDelegate",
"*Handler"
]
}Granular Exclusions
You can control which symbol types are renamed independently:
{
"symbol_renaming": {
"enabled": true,
"rename_classes": true,
"rename_methods": true,
"rename_properties": true,
"rename_protocols": false,
"exclude": ["AppDelegate", "SceneDelegate"]
}
}{
"symbol_renaming": {
"enabled": true,
"rename_classes": true,
"rename_methods": true,
"rename_properties": true,
"rename_protocols": false,
"exclude": ["AppDelegate", "SceneDelegate"]
}
}Setting rename_protocols to false preserves all protocol names, which is useful when protocols are referenced by name at runtime.
String Encryption Exclusions
You can also exclude specific strings from encryption:
{
"string_encryption": {
"enabled": true,
"exclude": [
"http://*",
"https://*",
"ftp://*"
]
}
}{
"string_encryption": {
"enabled": true,
"exclude": [
"http://*",
"https://*",
"ftp://*"
]
}
}This is useful for URL strings that need to remain readable for network debugging or analytics tools.
Related
- Symbol Renaming - How symbol renaming works
- Configuration Reference - Full configuration options
- Troubleshooting - Common issues with exclusions