-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from rockbruno/method-names
Method Names and more
- Loading branch information
Showing
18 changed files
with
435 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Current SourceKit issues that prevent SwiftShield from working automatically | ||
# Current known SourceKit issues that prevent SwiftShield from obfuscating *everything* | ||
|
||
- Issues with constrained protocols (`extension Foo where RawValue: Bar`) | ||
- Issues with explicit generics (`[MyClass]` is fine, `Swift.Array<MyClass>` isn't) | ||
- Typealiases issues | ||
- Rare cases where references don't get indexed | ||
- Typealiases: Not always indexed (`typealias Foo = UIImage | extension Foo {}` - Foo is indexed as UIImage) | ||
- Enum names: Explicit types don't get indexed (`case MyEnum.myCase` - MyEnum isn't indexed) | ||
- Enum cases: Although they are correctly indexed, `CodingKeys` are not meant to be changed. | ||
- Operator overloading: Operators only get indexed if they are declared in a global scope. Since most people use `public static func`, methods with names shorter than four characters don't get obfuscated. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Foundation | ||
|
||
struct DynamicLinkLibrary { | ||
let path: String | ||
let handle: UnsafeMutableRawPointer | ||
|
||
func load<T>(symbol: String) -> T { | ||
if let sym = dlsym(handle, symbol) { | ||
return unsafeBitCast(sym, to: T.self) | ||
} | ||
let errorString = String(validatingUTF8: dlerror()) ?? "" | ||
fatalError("Finding symbol \(symbol) failed: \(errorString)") | ||
} | ||
} | ||
|
||
func appsIn( dir: String, matcher: (_ name: String) -> Bool ) -> [String] { | ||
return (try! FileManager.default.contentsOfDirectory(atPath: dir)) | ||
.filter( matcher ).sorted().reversed().map { "\(dir)/\($0)" } | ||
} | ||
|
||
#if os(Linux) | ||
let toolchainLoader = Loader(searchPaths: [linuxSourceKitLibPath]) | ||
#else | ||
let toolchainLoader = Loader(searchPaths: (["/Applications/Xcode.app"] + | ||
appsIn( dir: "/Applications", matcher: { $0.hasPrefix("Xcode") } ) ) | ||
.map { $0+"/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/" } ) | ||
#endif | ||
|
||
struct Loader { | ||
let searchPaths: [String] | ||
|
||
func load(path: String) -> DynamicLinkLibrary { | ||
let fullPaths = searchPaths.map { $0.appending(path) } | ||
|
||
// try all fullPaths that contains target file, | ||
// then try loading with simple path that depends resolving to DYLD | ||
for fullPath in fullPaths + [path] { | ||
if let handle = dlopen(fullPath, RTLD_LAZY) { | ||
return DynamicLinkLibrary(path: path, handle: handle) | ||
} | ||
} | ||
|
||
fatalError("Loading \(path) from \(searchPaths)") | ||
} | ||
} | ||
|
||
#if os(Linux) | ||
private let path = "libsourcekitdInProc.so" | ||
#else | ||
private let path = "sourcekitd.framework/Versions/A/sourcekitd" | ||
#endif | ||
let library = toolchainLoader.load(path: path) |
Oops, something went wrong.