Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
973a913
Fix build errors
amsam0 Jan 20, 2023
6a5a5b4
fix webviews and allow for better logging in terminal (#2)
amsam0 Feb 2, 2023
09c0b47
add minimuxer_ready and many other changes (#4)
amsam0 Feb 20, 2023
2da7581
Change comment about memory leak
amsam0 Feb 20, 2023
87cf45b
Prebuild (#6)
amsam0 Feb 23, 2023
2274822
general logging/error handling improvements and code cleanup
amsam0 Feb 24, 2023
808fc7e
add some empty lines of logging to the ready test
amsam0 Feb 24, 2023
2fe6ebb
use Errors::Success in minimuxer_c_start and include STARTED in minim…
amsam0 Feb 24, 2023
1be43fe
logs will now include target
amsam0 Feb 28, 2023
894bdbb
Update makefile and ghaction for xcframework
JoeMatt Mar 1, 2023
50b29b3
Fix type-o in makefile
JoeMatt Mar 1, 2023
f2f530d
Simplify build
JoeMatt Mar 1, 2023
d9e2698
Fix type-o in Makefile
JoeMatt Mar 1, 2023
f4e8d7f
Makefile build really works this time
JoeMatt Mar 1, 2023
3dc5034
Make xcframework with modulemap so import works
JoeMatt Mar 1, 2023
bc6988e
Fix duplicate modulemap when using with em_proxy
JoeMatt Mar 1, 2023
12ff413
[build]
JoeMatt Mar 2, 2023
62ef168
Update README.md
JoeMatt Mar 2, 2023
7a25ba3
improve dependency versions
amsam0 Mar 3, 2023
44653f1
[build] Add minimuxer_fetch_udid and code cleanup
amsam0 Mar 3, 2023
f56d695
Add minimuxer_attach_debugger (needs more testing, not sure if it works)
amsam0 Mar 4, 2023
36329a2
clippy fixes
amsam0 Mar 4, 2023
55c4a44
remove extra whitespace from Makefile
amsam0 Mar 4, 2023
e8d6d87
[build] temporary fix for SideStore build failing
amsam0 Mar 4, 2023
d5ddcd2
add assert_eq to attach_debugger test, improve ready test
amsam0 Mar 4, 2023
c058490
initial swift-bridge refactor
amsam0 Mar 11, 2023
d0d6757
Update README.md
JoeMatt Mar 20, 2023
0ddd2e4
see commit description
amsam0 Mar 23, 2023
4850423
[build] update github actions
amsam0 Mar 23, 2023
9ad7aba
[build] small fix
amsam0 Mar 23, 2023
bbec1e5
[build] add -ios
amsam0 Mar 23, 2023
4d40837
[build] another fix
amsam0 Mar 23, 2023
46d1412
[build] actually fix it this time
amsam0 Mar 23, 2023
61adb18
see commit description
amsam0 Apr 1, 2023
2c8a590
clippy and fix dump_profiles
amsam0 Apr 1, 2023
78fb029
Update Cargo.lock
amsam0 Apr 1, 2023
95ac2ce
[build]
amsam0 Apr 1, 2023
a4f7899
build: use constants
amsam0 Apr 9, 2023
7d80475
feat(afc_file_manager): update to work with Swift
amsam0 Apr 9, 2023
06e8790
feat(provision): make dump_profiles return the directory
amsam0 Apr 9, 2023
0bd6bb6
feat(lib): add describe_error for future usage and log in set_debug
amsam0 Apr 9, 2023
652d2c1
fix(install): clone because libplist will crash if we don't
amsam0 Apr 9, 2023
f549dff
docs(README): format and include libi debug logging info
amsam0 Apr 9, 2023
2d5657b
feat: add WIP, currently disabled app signing
amsam0 Apr 9, 2023
31d57d5
project: update Cargo.lock
amsam0 Apr 9, 2023
0919177
[build]
amsam0 Apr 9, 2023
19e0173
project: remove Cargo.lock since it doesn't help with build speed
amsam0 Apr 9, 2023
87ba32f
[build] fix: comment AppleCodesign error
amsam0 Apr 9, 2023
119941d
docs: correct comment
amsam0 Apr 22, 2023
6ae7bb2
[build] Add Simulate Location
SoY0ung May 10, 2023
81064a3
[build] Add API token
SoY0ung May 10, 2023
9df791d
Revert build.yml to default
SoY0ung May 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build minimuxer

on: [push]

jobs:
build:
name: Build minimuxer
if: startsWith(github.event.head_commit.message, '[build]')
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
runs-on: macos-12

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Install rust targets for iOS
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios

- name: Cache rust
uses: Swatinem/rust-cache@v2

- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1.4.1
with:
xcode-version: 14.2

- name: Build
run: make zip

- name: Upload to release
uses: IsaacShelton/update-existing-release@v1.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
release: "Build"
tag: "build"
files: |
minimuxer.xcframework.zip
generated.zip
target/libminimuxer-ios.a
target/libminimuxer-sim.a
body: |
Commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/target
/Cargo.lock
minimuxer.h
Cargo.lock

/minimuxer.xcframework
/minimuxer.xcframework.zip
/include

/generated.zip
/generated/*
!/generated/minimuxer-Bridging-Header.h
!/generated/minimuxer-helpers.swift
32 changes: 21 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rusty_libimobiledevice = { version = "0.1.6", features = ["dynamic"], default-features = false }
plist_plus = { version = "0.2.*", features = ["dynamic"] }
rusty_libimobiledevice = { version = "0.1", features = ["dynamic"], default-features = false }
plist_plus = { version = "0.2", features = ["dynamic"] }
plist = "1"
swift-bridge = { git = "https://github.com/naturecodevoid/swift-bridge" } # TODO: change to official repo once https://github.com/chinedufn/swift-bridge/pull/209 is merged

libc = { version = "0.2.132" }
simplelog = { version = "*" }
log = { version = "*" }
log = "*"
simplelog = "0.12"

reqwest = { version = "0.11.12", features = ["blocking"] }
serde = { version = "1.0.147" }
serde_json = { version = "1.0.87" }
zip = { version = "0.6.3" }
serde = "1.0"
serde_json = "1.0"

# apple-codesign-wrapper = { git = "https://github.com/SideStore/apple-private-apis" }
# p12 = "0.6"
# der = { version = "0.7", features = ["pem"] }

reqwest = { version = "0.11", features = ["blocking"] }
zip = "0.6"
chrono = "0.4"

[build-dependencies]
cbindgen = "0.20.0"
swift-bridge-build = { git = "https://github.com/naturecodevoid/swift-bridge" } # TODO: change to official repo once https://github.com/chinedufn/swift-bridge/pull/209 is merged

[profile.release]
panic = "abort"

[lib]
crate-type = ["staticlib", "rlib"]
crate-type = ["staticlib", "rlib"]
147 changes: 147 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
SIDESTORE_REPO ?= ../SideStore
SKIP_SIM ?= false
TARGET="minimuxer"

add_targets:
@echo "add_targets"
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios

build:
@echo "build aarch64-apple-ios"
@cargo build --release --target aarch64-apple-ios
@cp target/aarch64-apple-ios/release/lib$(TARGET).a target/lib$(TARGET)-ios.a

ifeq ($(SKIP_SIM),false)
@echo "build aarch64-apple-ios-sim"
@cargo build --release --target aarch64-apple-ios-sim

@echo "build x86_64-apple-ios"
@cargo build --release --target x86_64-apple-ios

@echo "lipo"
@lipo -create \
-output target/lib$(TARGET)-sim.a \
target/aarch64-apple-ios-sim/release/lib$(TARGET).a \
target/x86_64-apple-ios/release/lib$(TARGET).a
else
@echo "skipping sim builds"
endif

# TODO: remove/update once SPM gets merged
copy: build
@echo "SIDESTORE_REPO: $(SIDESTORE_REPO)"

@echo "copying libraries"
@cp target/libminimuxer-ios.a "$(SIDESTORE_REPO)/Dependencies/minimuxer"
@cp target/libminimuxer-sim.a "$(SIDESTORE_REPO)/Dependencies/minimuxer"

@echo "copying generated"
@cp generated/* "$(SIDESTORE_REPO)/Dependencies/minimuxer"

@touch "$(SIDESTORE_REPO)/Dependencies/.skip-prebuilt-fetch-minimuxer"

clean:
@echo "clean"
@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -r include; \
fi
@if [ -d "target" ]; then \
echo "cleaning target"; \
rm -r target; \
fi
@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -r $(TARGET).xcframework; \
fi
@if [ -f "$(TARGET).xcframework.zip" ]; then \
echo "cleaning $(TARGET).xcframework.zip"; \
rm $(TARGET).xcframework.zip; \
fi

xcframework: build
@echo "xcframework"

@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -rf include; \
fi
@mkdir include
@mkdir include/$(TARGET)/
@cp generated/*.h include/$(TARGET)/
@cp module.modulemap include/$(TARGET)/

@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -rf $(TARGET).xcframework; \
fi

@xcodebuild \
-create-xcframework \
-library target/lib$(TARGET)-ios.a \
-headers include/ \
-library target/lib$(TARGET)-sim.a \
-headers include/ \
-output $(TARGET).xcframework

xcframework_frameworks: build
@echo "xcframework_frameworks"

@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -rf include; \
fi
@mkdir include
@mkdir include/$(TARGET)
@cp generated/*.h include/$(TARGET)
@cp module.modulemap include/$(TARGET)

@if [ -d "target/ios" ]; then \
echo "cleaning target/ios"; \
rm -rf target/ios; \
fi
@mkdir target/ios
@mkdir target/ios/$(TARGET).framework
@mkdir target/ios/$(TARGET).framework/Headers

@if [ -d "target/sim" ]; then \
echo "cleaning target/sim"; \
rm -rf target/sim; \
fi
@mkdir target/sim
@mkdir target/sim/$(TARGET).framework
@mkdir target/sim/$(TARGET).framework/Headers

@cp include/*.* target/ios/$(TARGET).framework/Headers
@libtool -static \
-o target/ios/$(TARGET).framework/$(TARGET) \
target/lib$(TARGET)-ios.a

@cp include/*.* target/sim/$(TARGET).framework/Headers
@xcrun \
-sdk iphonesimulator \
libtool -static \
-o target/sim/$(TARGET).framework/$(TARGET) \
target/lib$(TARGET)-sim.a

@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -rf $(TARGET).xcframework; \
fi
@xcodebuild -create-xcframework \
-library target/sim/$(TARGET).framework \
-headers include/ \
-library target/ios/$(TARGET).framework \
-headers include/ \
-output $(TARGET).xcframework

zip: xcframework
@echo "zip xcframework"
@if [ -f "$(TARGET).xcframework.zip" ]; then \
echo "cleaning $(TARGET).xcframework.zip"; \
rm $(TARGET).xcframework.zip; \
fi
zip -r $(TARGET).xcframework.zip $(TARGET).xcframework

@echo "zip generated"
@zip -r generated.zip generated/
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# minimuxer

minimuxer is the lockdown muxer used by [SideStore](https://github.com/SideStore/SideStore). It runs on device through [em_proxy](https://github.com/SideStore/em_proxy).

![Alt](https://repobeats.axiom.co/api/embed/95df7af50adae86935e34bc1f59083f1db326c24.svg "Repobeats analytics image")

## Building

```bash
make build # builds static libs
make xcframework # builds an xcframework
make zip # same as `xcframework`, and zips the final product for upload to GitHub release
```

### Publishing new release

We use a github action to generate a `.xcframework` for use in Swift PM or Xcode.

This overwrites the last build on the tag `Build`.

Either push a commit with `[build]` as the prefix for the commit message or push an empty commit with:

```bash
git commit --allow-empty -m "[build]"
```

## Development

### Off device

While minimuxer is built to run on device, it is recommended to test from your computer through USB to speed up the development process. (Obviously, you should still test on device; see
[On device](#on-device) for more info)

To test off device, open [tests.rs](src/tests.rs) and use the `make_test` macro to make a test (this ensures logging and other things are initialized). You can then use

```bash
cargo test <test function name> -- --nocapture
```

to run it. (`-- --nocapture` allows for logs to be shown, which are essential for debugging and knowing if a test did what it was supposed to do)

Since libimobiledevice logging can be quick verbose, you can filter it to only minimuxer logging with this command:

```bash
cargo test <test function name> -- --nocapture 2>&1 | grep -e minimuxer:: -e tests.rs
```

After implementing your feature, you should also run

```bash
cargo clippy --no-deps
```

to lint your code.

If you want some of the lints to auto fix, you can use

```bash
cargo clippy --no-deps --fix
```

(make sure to commit your changes beforehand).

Note: tests currently don't automatically mount the developer disk image, you must do that yourself with `ideviceimagemounter` or open SideStore on device and let the auto mounter mount it (check
minimuxer logs in View Error Logs to see if it did so successfully).

### On device

SideStore communicates with minimuxer through Swift and C bindings generated by [swift-bridge](https://github.com/chinedufn/swift-bridge). swift-bridge makes it very easy to pass arguments to
functions, especially types like `Vec`, and it also makes returning `Result` very easy.

As of February 20th, minimuxer is included in SideStore as a prebuilt static library, built by GitHub Actions. Previously, it was included in SideStore as an Xcode project using cargo-xcode, but this
made build times very long.

<!-- TODO: outdated -->
<!-- To build minimuxer for iOS and copy it to the SideStore repo, use the Makefile. Example: `make copy SIDESTORE_REPO="../SideStore"` -->

## Developer Notes

Unless otherwise stated, references to AltServer implementations are referring to `AltServer/Devices/ALTDeviceManager.mm`

### Adding a swift-bridge/ffi function

Once you've made your function, added it to the tests and verified that it works, you can add it to swift-bridge/ffi to allow Swift to use it.

1. Import your function in the `ffi imports` section of `lib.rs`
2. In `mod ffi` -> `extern "Rust"`, add your function to the section for the file you added it to.

### Returning a Result from a swift-bridge/ffi function

When making your function, you might have something similar to this:

```rs
pub fn install_provisioning_profile(profile: &[u8]) -> Result<()> { ... }
```

You can `use crate::Res` as a shorthand to `Result<T, crate::Errors>`. (Most files already `use` this)

When exposing your function to the `ffi` module, we unfortunately can't use the `crate::Res` type alias. Instead, do this:
`Result<[the type your function returns. in the case of install_provisioning_profile, it is ()], Errors>`

### `minimuxer_install_provisioning_profile`

AltServer implementation: search `installProvisioningProfiles` and `installProvisioningProfile:(`
Loading