stephancasas / SymbolicBridge

A wrapper class/protocol for dynamic symbol linking/binding in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SymbolicBridge

SymbolicBridge provides a wrapper class and protocol for dynamically loading undeclared symbols from external frameworks at runtime.

Install

Add the package using Swift Package Manager:

https://github.com/stephancasas/SymbolicBridge

Usage

Define a class which will scope your symbol bindings as static functions/variables. The class should extend SymbolicBridge and implement SymbolicBridgeProvider:

import Foundation;
import SymbolicBridge;

class CGSPrivate: SymbolicBridge, SymbolicBridgeProvider {
    
    static let framework: String = "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics";
    
    /// The main CoreGraphics connection identity.
    ///
    static var mainConnectionID: Int {
        getSymbol(
            named: "CGSMainConnectionID",
            as: (@convention(c) () -> Int).self
        )()
    }
    
}

Contact

Follow Stephan on X

License

MIT

About

A wrapper class/protocol for dynamic symbol linking/binding in Swift.


Languages

Language:Swift 100.0%