Voltar ao ranking

rockbruno/swiftshield

Swiftswiftrocks.com

🔒 Swift Obfuscator that protects iOS apps against reverse engineering attacks.

swiftobfuscationiosobjcsourcekitobjective-c
Crescimento de estrelas
Estrelas
2.5k
Forks
284
Crescimento semanal
Issues
0
1k2k
jan. de 2023mar. de 2024mai. de 2025jul. de 2026
README
SwiftShield logo
struct fjiovh4894bvic: XbuinvcxoDHFh3fjid {
  let VNfhnfn3219d: Vnahfi5n34djga
  func cxncjnx8fh83FDJSDd() -> Lghbna2gf0gmh3d {
    return vPAOSNdcbif372hFKF(VNfhnfn3219d.Gjanbfpgi3jfg())
  }
}

SwiftShield: Swift Obfuscator

Don't use this tool for production apps. I gave up on keeping this tool updated because every Swift release breaks SourceKit in a different way. It's probably really broken and is only useful as a way for you to learn more about obfuscation and SourceKit.

GitHub release

SwiftShield is a tool that generates random and irreversible encrypted names for your iOS project's types and methods (including third-party libraries). It uses Apple's SourceKit to mimick Xcode's indexing behavior, revealing a complete map of your project that is used to safely rename parts of your project.

Reverse engineering iOS apps is relatively simple due to the fact that almost every single type and method name is exposed in the app's binary. This allows jailbreak tools like class-dump and Cycript to extract this information and use it to change the behavior of your app in runtime.

Obfuscating code in iOS makes the usage of these tools difficult, while also making it tougher for jailbreak developers to create tweaks for your app as SwiftShield's obfuscation changes every time you run it.

Limitations

The capabilities of SwiftShield are directly related to the capabilities of SourceKit, which unfortunately has its share of bugs. However, although SwiftShield can't obfuscate everything, it can obfuscate just enough to make reverse engineering very hard. Check this document to see its capabilities in detail.

Requirements

  • You should not have logic based on hardcoded names (like loading MyClass.json because String(describing: type(of:self)) is 'MyClass'). SwiftShield does not obfuscate things like file names and hardcoded strings -- only the types themselves.
  • No Objective-C classes that call Swift methods (but Swift classes calling Objective-C code are fine).
  • Your project should be 100% written in View Code. Older versions of SwiftShield did support obfuscating Storyboards/XIBs, but it was extremely hard to maintain. This parts from the principle that if you have a project big or important enough to be obfuscated, you probably shouldn't be using Storyboards in the first place.
  • Your project should not be using Xcode's Legacy Build System setting.
  • Make sure your project doesn't suffer from one of SourceKit's bugs. Although the bugs won't prevent the project from being obfuscated, some of them might require you to manually fix the resulting code as it will not be able to compile.

Usage

Check this repo's example project to see it in action! You can run it by executing make swiftshield in your terminal.

Downloading SwiftShield

You can get a SwiftShield binary from the releases page.

Modify scripts that can affect SwiftShield

If your project uses a framework that also modifies your files like SwiftGen, you need to prevent them from running alongside SwiftShield. This can be done by checking for the $SWIFTSHIELDED Xcode variable that is added by SwiftShield after your project is obfuscated.

For example, my SwiftGen Xcode Run Script:

$PODS_ROOT/SwiftGen/bin/swiftgen images --output $SRCROOT/Asset.swift $SRCROOT/Assets.xcassets

...should be changed to:

if [ "$SWIFTSHIELDED" != "true" ]; then
    $PODS_ROOT/SwiftGen/bin/swiftgen images --output $SRCROOT/Asset.swift $SRCROOT/Assets.xcassets
fi

Unlock Sources

If you're using a dependency manager like CocoaPods, you need to make sure that the sources are unlocked. If they aren't, SwiftShield will fail saying that it failed to overwrite the files. To unlock your project, execute:

chmod -R 774 PATHTOPROJECTFOLDER

Running SwiftInfo

USAGE: swiftshield obfuscate --project-file <project-file> --scheme <scheme> [--ignore-public] [--ignore-targets] [--verbose] [--dry-run] [--print-sourcekit]

OPTIONS:
  -p, --project-file <project-file>
                          The path to your app's main .xcodeproj/.xcworkspace
                          file. 
  -s, --scheme <scheme>   The main scheme from the project to build. 
  --ignore-public         Don't obfuscate content that is 'public' or 'open'
                          (a.k.a 'SDK Mode'). 
  -i, --ignore-targets    A list of targets, separated by a comma, that should
                          NOT be obfuscated. 
  -v, --verbose           Prints additional information. 
  -d, --dry-run           Does not actually overwrite the files. 
  --print-sourcekit       Prints SourceKit queries. Note that they are huge, so
                          use this only for bug reports and development! 
  -h, --help              Show help information.

Deobfuscating crash logs

A successful run of SwiftShield generates a swiftshield-output/conversionMap.txt file that contains all changes made to your project:

//
//  SwiftShield
//  Conversion Map
//  Automatic mode for MyApp 2.0 153, 2018-09-24 10.23.48
//

Data:

ViewController ===> YytSIcFnBAqTAyR
AppDelegate ===> uJXJkhVbwdQGNhh
SuperImportantClassThatShouldBeHidden ===> GDqKGsHjJsWQzdq

Make sure to store this file when you publish a release, as it can be used to deobfuscate crash logs from the app that generated it through SwiftShield's deobfuscate subcommand.

USAGE: swiftshield deobfuscate --crash-file <crash-file> --conversion-map <conversion-map>

OPTIONS:
  -c, --crash-file <crash-file>
                          The path to the crash file. 
  -m, --conversion-map <conversion-map>
                          The path to the previously generated conversion map. 
  -h, --help              Show help information.
SwiftShield logo
Repositórios relacionados
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
serhii-londar/open-source-mac-os-apps

🚀 Awesome list of open source applications for macOS. https://t.me/s/opensourcemacosapps

Creative Commons Zero v1.0 Universalmacosmac
49.7k2.6k
iina/iina

The modern video player for macOS.

SwiftGNU General Public License v3.0macosvideo-player
iina.io
45.7k2.9k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
xitu/gold-miner

🥇掘金翻译计划,可能是世界最大最好的英译中技术社区,最懂读者和译者的翻译平台:

androidtranslation
juejin.cn/tag/%E6%8E%98%E9%87%91%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92
34.3k5k
MonitorControl/MonitorControl

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

SwiftMIT Licensemacoskeyboard
monitorcontrol.app
33.8k983
shadowsocks/ShadowsocksX-NG

Next Generation of ShadowsocksX

SwiftGNU General Public License v3.0shadowsocksswift
32.9k7.8k
kodecocodes/swift-algorithm-club

Algorithms and data structures in Swift, with explanations!

SwiftMIT Licenseswiftdata-structures
29.1k5k
jordanbaird/Ice

Powerful menu bar manager for macOS

SwiftGNU General Public License v3.0macosmenubar
icemenubar.app
29k824
airbnb/lottie-ios

An iOS library to natively render After Effects vector animations

SwiftApache License 2.0animationbodymovin
lottie.airbnb.tech
26.8k3.8k