Dylib_Runner
Simple swift file that can run an on-disk dylib.
Leveraged code samples at https://stackoverflow.com/questions/34669958/swift-how-to-call-a-c-function-loaded-from-a-dylib.
Steps:
- In RunDylib.swift edit the
myhandle
variable to include the path to the dylib you want to run. - In RunDylib.swift edit the
x
variable to include the name of the function you want to invoke - Note: I have a sleep(3) entry in the RunDylib.swift file that I added to ensure the program had enough time to complete before closing out…feel free to edit that as needed (or remove altogether if preferred)
- Save and build with:
swiftc -o [binary_name] RunDylib.swift
- Run:
./[binary_name]