swift-mixin | An intuitive library for hooking functions in Swift
kandi X-RAY | swift-mixin Summary
kandi X-RAY | swift-mixin Summary
swift-mixin is a Swift library. swift-mixin has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.
SwiftMixin provides all of the functionality required to overwrite functions and methods at runtime. It also allows you to create backups of functions before you overwrite them so that you can still use the original function. This package was made for a Swift plugin system (Delta Plugin API), but was abandoned because it was decided that it was better if plugins were restricted to only using the public API so that are more stable. Only x86_64 is supported and ARM64 support probably won't be added any time soon.
SwiftMixin provides all of the functionality required to overwrite functions and methods at runtime. It also allows you to create backups of functions before you overwrite them so that you can still use the original function. This package was made for a Swift plugin system (Delta Plugin API), but was abandoned because it was decided that it was better if plugins were restricted to only using the public API so that are more stable. Only x86_64 is supported and ARM64 support probably won't be added any time soon.
Support
Quality
Security
License
Reuse
Support
swift-mixin has a low active ecosystem.
It has 10 star(s) with 0 fork(s). There are 1 watchers for this library.
It had no major release in the last 6 months.
swift-mixin has no issues reported. There are no pull requests.
It has a neutral sentiment in the developer community.
The latest version of swift-mixin is current.
Quality
swift-mixin has no bugs reported.
Security
swift-mixin has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
License
swift-mixin does not have a standard license declared.
Check the repository for any license declaration and review the terms closely.
Without a license, all rights are reserved, and you cannot use the library in your applications.
Reuse
swift-mixin releases are not available. You will need to build from source code and install.
Installation instructions, examples and code snippets are available.
Top functions reviewed by kandi - BETA
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of swift-mixin
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of swift-mixin
swift-mixin Key Features
No Key Features are available at this moment for swift-mixin.
swift-mixin Examples and Code Snippets
No Code Snippets are available at this moment for swift-mixin.
Community Discussions
No Community Discussions are available at this moment for swift-mixin.Refer to stack overflow page for discussions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install swift-mixin
Using this library in your project requires that you have capstone installed on your system. Capstone can be installed using homebrew with the following command;. The next few steps depend on what sort of project you have. Installation is different for Swift Package Manager projects and Xcode projects.
Below is an example Package.swift with SwiftMixin as a dependency;.
Add this package as a dependency in your Package.swift.
Optional: Run swift package generate-xcodeproj because using an xcodeproj makes your life easier later on.
Navigate to File > Swift Packages > Add Package Dependency....
Enter https://github.com/stackotter/swift-mixin as the url.
On the next screen choose branch rule and leave the default value (it should be 'main').
Click next. Once it finishes loading, choose your package in the Add to Target column and click done.
In more recent versions of macOS, Apple changed the default maxProt level of the text segment of MachO executables to be 5 (it used to be 7). In short; we need to change this value back to 7 otherwise we can't write to the memory that contains functions. I don't know which macOS version the change was made in so it's safest just to do the following steps anyway.
Add a run script phase to your project containing the following;. This will patch the binary correctly everytime you build your project.
If you have a swift package manager project and don't use a .xcodeproj then there are two options (both are not that good, it's not too late to run swift package generate-xcodeproj). Option 1: Run printf '\x07' | dd of=./path/to/compiled/binary bs=1 seek=160 count=1 conv=notrunc everytime you build your project (an example build and run script is listed below). Option 2: Or, each time you want to build and run your project; First build and run it (you will get an error), and then run it again and it should work. Your executable will automatically patch itself, but it requires a restart of the program for the changes to take effect. This autopatching requires that your program calls Mixin.setup() when it starts up.
Each time your app starts it should check that it's memory protection bit it correctly patched. This sounds scary but SwiftMixin makes it easy. Just add the following line to your app's startup;. This will automatically check your executable's text segment's maximum protection level (should be 7 but is 5 by default). If the protection level is not set correctly the executable will patch itself and Mixin.setup() will throw an error. The next time the executable is run it should work properly.
Below is an example Package.swift with SwiftMixin as a dependency;.
Add this package as a dependency in your Package.swift.
Optional: Run swift package generate-xcodeproj because using an xcodeproj makes your life easier later on.
Navigate to File > Swift Packages > Add Package Dependency....
Enter https://github.com/stackotter/swift-mixin as the url.
On the next screen choose branch rule and leave the default value (it should be 'main').
Click next. Once it finishes loading, choose your package in the Add to Target column and click done.
In more recent versions of macOS, Apple changed the default maxProt level of the text segment of MachO executables to be 5 (it used to be 7). In short; we need to change this value back to 7 otherwise we can't write to the memory that contains functions. I don't know which macOS version the change was made in so it's safest just to do the following steps anyway.
Add a run script phase to your project containing the following;. This will patch the binary correctly everytime you build your project.
If you have a swift package manager project and don't use a .xcodeproj then there are two options (both are not that good, it's not too late to run swift package generate-xcodeproj). Option 1: Run printf '\x07' | dd of=./path/to/compiled/binary bs=1 seek=160 count=1 conv=notrunc everytime you build your project (an example build and run script is listed below). Option 2: Or, each time you want to build and run your project; First build and run it (you will get an error), and then run it again and it should work. Your executable will automatically patch itself, but it requires a restart of the program for the changes to take effect. This autopatching requires that your program calls Mixin.setup() when it starts up.
Each time your app starts it should check that it's memory protection bit it correctly patched. This sounds scary but SwiftMixin makes it easy. Just add the following line to your app's startup;. This will automatically check your executable's text segment's maximum protection level (should be 7 but is 5 by default). If the protection level is not set correctly the executable will patch itself and Mixin.setup() will throw an error. The next time the executable is run it should work properly.
Support
For any new features, suggestions and bugs create an issue on GitHub.
If you have any questions check and ask questions on community page Stack Overflow .
Find more information at:
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page