swiftc main.swift -emit-module-path main.swiftmodule -emit-executable -enable-private-imports -Xfrontend -enable-implicit-dynamic
./main
-> printsFrom original bar()
swiftc -emit-library inject.swift -o inject.dylib -I . -Xlinker -undefined -Xlinker suppress -Xlinker -flat_namespace -Xfrontend -disable-access-control
DYLD_INSERT_LIBRARIES=inject.dylib ./main
-> printsFrom replacement bar()
- Passing
-Xfrontend -enable-implicit-dynamic
removes you from having to adddynamic
to everything you want to be replacable