-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05e4d0d
Showing
9 changed files
with
498 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc | ||
.vscode | ||
.swiftpm |
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,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Bogo Giertler | ||
Copyright (c) 2024 Florent Morin / Morin Innovation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,15 @@ | ||
{ | ||
"originHash" : "046fe0fa237cc929db21eecaee525152d32344d56e7dbf042849661d05769424", | ||
"pins" : [ | ||
{ | ||
"identity" : "swift-argument-parser", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-argument-parser.git", | ||
"state" : { | ||
"revision" : "41982a3656a71c768319979febd796c6fd111d5c", | ||
"version" : "1.5.0" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
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,27 @@ | ||
// swift-tools-version: 5.10 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "silicon-binary-converter", | ||
platforms: [ | ||
.macOS(.v14) | ||
], | ||
products: [ | ||
.executable(name: "silicon-binary-converter", targets: ["silicon-binary-converter"]) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.executableTarget( | ||
name: "silicon-binary-converter", | ||
dependencies: [ | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
] | ||
), | ||
] | ||
) |
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,67 @@ | ||
# silicon-binary-converter | ||
|
||
A lightweight command-line tool for adapting native ARM64 binaries to run on multiple Apple Silicon platforms. | ||
|
||
This tool is a fork of the [arm64-to-sim](https://github.com/bogo/arm64-to-sim) project, with additional adjustments to extend its capabilities. | ||
|
||
## ⚠️ Disclaimer | ||
|
||
This tool allows users to modify binaries for compatibility with multiple platforms. **However**, it is your responsibility to ensure you have the legal right to modify and distribute the binaries in question. | ||
|
||
Unauthorized modification of software can violate intellectual property laws, software licenses, or terms of service. **Always verify that you are permitted to alter a binary according to the relevant legal agreements**. The creator of this tool is not liable for any misuse or legal consequences arising from its use. | ||
|
||
## Building | ||
|
||
To build a universal `silicon-binary-converter` executable, run: | ||
|
||
```bash | ||
swift build -c release --arch arm64 --arch x86_64 | ||
``` | ||
|
||
The resulting executable will be located in the `.build/apple/Products/Release` directory. | ||
|
||
## Usage | ||
|
||
To use `silicon-binary-converter`, run the following command: | ||
|
||
```bash | ||
./silicon-binary-converter --platform <platform> [--min-os-version <min-os-version>] [--sdk-version <sdk-version>] [--binary-type <binary-type>] <source-path> <destination-path> | ||
``` | ||
|
||
### Arguments: | ||
|
||
- `<source-path>`: Path to the source binary | ||
- `<destination-path>`: Path where the modified binary will be saved | ||
|
||
### Options: | ||
|
||
- `-p, --platform <platform>`: Target platform (e.g., `ios`, `ios-simulator`, `macos`, etc.) | ||
- `-m, --min-os-version <min-os-version>`: Minimum OS version (optional) | ||
- `-s, --sdk-version <sdk-version>`: SDK version (optional) | ||
- `-b, --binary-type <binary-type>`: Binary type (`static` or `dynamic`; default: `static`) | ||
- `-h, --help`: Display help information | ||
|
||
> If not provided, the minimum OS version and SDK version default to the latest available. | ||
### Example | ||
|
||
To convert an iOS binary library to a macOS (Apple Silicon) binary version, run: | ||
|
||
```bash | ||
./silicon-binary-converter --platform macos libsomething_ios.a libsomething_macos.a | ||
``` | ||
|
||
### Supported destination platforms | ||
|
||
You can target the following platforms: | ||
|
||
- `ios`: iOS | ||
- `macos`: macOS | ||
- `maccatalyst`: Mac Catalyst | ||
- `tvos`: tvOS | ||
- `visionos`: visionOS | ||
- `watchos`: watchOS | ||
- `ios-simulator`: iOS Simulator | ||
- `tvos-simulator`: tvOS Simulator | ||
- `visionos-simulator`: visionOS Simulator | ||
- `watchos-simulator`: watchOS Simulator |
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,36 @@ | ||
import ArgumentParser | ||
|
||
@main | ||
struct App: ParsableCommand { | ||
@Option(name: [.customShort("p"), .customLong("platform")], help: "Target platform (ios, ios-simulator, ...)") private var platform: Platform | ||
@Option(name: [.customShort("m"), .customLong("min-os-version")], help: "Minimum OS version") private var minOS: UInt32? | ||
@Option(name: [.customShort("s"), .customLong("sdk-version")], help: "SDK version") private var sdk: UInt32? | ||
@Option(name: [.customShort("b"), .customLong("binary-type")], help: "Binary type (static|dynamic)") private var binaryType: BinaryType = .static | ||
@Argument(help: "Path to source binary") private var sourcePath: String | ||
@Argument(help: "Path to destination binary") private var destinationPath: String | ||
|
||
|
||
mutating func run() throws { | ||
let defaultVersion: UInt32 | ||
|
||
switch platform { | ||
case .iOS, .iOSSimulator: | ||
defaultVersion = 17 | ||
case .macOS, .macCatalyst: | ||
defaultVersion = 14 | ||
case .tvOS, .tvOSSimulator: | ||
defaultVersion = 17 | ||
case .visionOS, .visionOSSimulator: | ||
defaultVersion = 1 | ||
case .watchOS, .watchOSSimulator: | ||
defaultVersion = 10 | ||
} | ||
|
||
let minOS = self.minOS ?? defaultVersion | ||
let sdk = self.sdk ?? defaultVersion | ||
Transmogrifier.processBinary(from: sourcePath, to: destinationPath, platform: platform, minos: minOS, sdk: sdk, binaryType: binaryType) | ||
} | ||
} | ||
|
||
extension BinaryType: ExpressibleByArgument { } | ||
extension Platform: ExpressibleByArgument { } |
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,6 @@ | ||
import Foundation | ||
|
||
enum BinaryType: String, Decodable { | ||
case `static` | ||
case `dynamic` | ||
} |
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,40 @@ | ||
import Foundation | ||
import MachO | ||
|
||
enum Platform: String, Decodable { | ||
case iOS = "ios" | ||
case macOS = "macos" | ||
case macCatalyst = "maccatalyst" | ||
case tvOS = "tvos" | ||
case visionOS = "visionos" | ||
case watchOS = "watchos" | ||
case iOSSimulator = "ios-simulator" | ||
case tvOSSimulator = "tvos-simulator" | ||
case visionOSSimulator = "visionos-simulator" | ||
case watchOSSimulator = "watchos-simulator" | ||
|
||
var machOValue: Int32 { | ||
switch self { | ||
case .iOS: | ||
PLATFORM_IOS | ||
case .macOS: | ||
PLATFORM_MACOS | ||
case .tvOS: | ||
PLATFORM_TVOS | ||
case .visionOS: | ||
PLATFORM_VISIONOS | ||
case .watchOS: | ||
PLATFORM_WATCHOS | ||
case .iOSSimulator: | ||
PLATFORM_IOSSIMULATOR | ||
case .tvOSSimulator: | ||
PLATFORM_TVOSSIMULATOR | ||
case .visionOSSimulator: | ||
PLATFORM_VISIONOSSIMULATOR | ||
case .watchOSSimulator: | ||
PLATFORM_WATCHOSSIMULATOR | ||
case .macCatalyst: | ||
PLATFORM_MACCATALYST | ||
} | ||
} | ||
} |
Oops, something went wrong.