# Verify, rebuild and modify the playback engine

Use your own media and a separate copy of Cinelith. Keep your original installation and its data. No developer certificate or application interface source is required for the library-replacement experiment described below. These instructions do not change system security settings.

## Verify and prepare

First compare the complete ZIP SHA-256 with the value on the official download page. Extract it into a new directory. From the extracted packet root run:

```sh
python3 corresponding-source/build/restore-source-workspace.py --verify-only
python3 corresponding-source/build/restore-source-workspace.py --destination /ABS/cinelith-engine-work
```

The destination must not already exist. Preparation needs Python 3.9 or later, Git and patch. Before writing the workspace, the entry point verifies every payload, both manifests, all 44 archives, 55 patches, 99 notices, allowed patch targets/order and wrapper identity. It rejects symlinks, paths outside the packet, duplicate JSON keys, existing destinations and destinations inside the packet. Hashes establish integrity; they do not replace obtaining the ZIP hash from a trusted channel.

The unchanged preparation program applies 46 upstream patches and 5 original Cinelith patches. The four delivery patches then apply to two VLC and two VLCKit targets in order. The final VLC Git tree is `2f5293b1bed09e2f5edd17a289a8dbda847971be`; wrapper SHA-256 is `a5d0c0d02459e114e9bd16f6bc916776fa1865e83c5973bd9d3d7016b60aabb6`. `SOURCE-DELIVERY-REPLAY.json` records all 45 input rows/44 unique archives and the resulting identities. Preparation does not download, compile, install or upload anything.

## Build

The [tool lock](corresponding-source/build/source-build-tools.json) specifies CMake 3.31.6, Meson 1.5.2, Ninja 1.11.1.4, Bison 3.8.2 and the exact gas-preprocessor source. Install Python tools into the workspace's `.cache/engine-source-delivery/python-tools` directory, using the locked versions and hashes. CMake and Meson executable wrappers must add that installation directory to `sys.path`: contrib invokes them through `env -i`, so relying only on `PYTHONPATH` is insufficient. Build Bison using the VLC `extras/tools` recipe and SHA-512 and place gas-preprocessor, verified against the tool lock, in that tools prefix. You also need Xcode, macOS and iOS SDKs, autoconf, automake, GNU libtool, pkg-config and coreutils. The old wrapper queries the iOS SDK even for a macOS target. No build tool is embedded in Cinelith.

Create an empty workspace directory `.cache/no-system-pkgconfig`. In `/ABS/cinelith-engine-work/.cache/engine-source-delivery/vlckit`, substitute your actual absolute paths:

```sh
PYTHONPATH=/ABS/cinelith-engine-work/.cache/engine-source-delivery/python-tools \
VLC_PATH=/ABS/cinelith-engine-work/.cache/engine-source-delivery/python-tools/bin:/opt/homebrew/bin \
BISON_PKGDATADIR=/ABS/cinelith-engine-work/.cache/engine-source-delivery/vlckit/libvlc/vlc/extras/tools/build/share/bison \
MAKE_JOBS=6 PKG_CONFIG_LIBDIR=/ABS/cinelith-engine-work/.cache/no-system-pkgconfig \
bash buildMobileVLCKit.sh -x -a aarch64 -n -v
```

`-n` preserves the prepared sources; do not use `-k macosx`, which duplicates an SDK suffix in this wrapper. Output is `build/VLCKit.xcframework/macos-arm64/VLCKit.framework`, with its matching dSYM. The complete local build using the locked, already installed tools succeeded. Installing these tools on another machine has not been tested; this document is a recipe, not an independently verified tool installer.

The engine target is arm64/macOS 14.0. Verify no `_pipe2` import, matching binary/dSYM UUID, 224 enabled modules and the intended disabled GPL/LAME/protobuf/zvbi targets. The build summary records 283 static archives and 43 contrib targets. Generated configuration and resources must be produced by the build. Do not overlay historical generated files or reuse an old framework as a rebuild result.

## Modify and use a separate local copy

Modify the prepared library source, rebuild the complete framework and preserve its public API and install name. For a visible test, modify `libvlc/vlc/lib/core.c` so `libvlc_get_version()` returns an identifiable suffix, then rebuild. Do not ship this diagnostic marker as an unmodified engine. Cinelith's local Diagnostics preview reads that version and can trigger a source breakpoint.

Quit Cinelith before copying it. Make a separate local application copy, replace its `Contents/Frameworks/VLCKit.framework` with your rebuilt framework, and give the copy a distinct bundle identifier so it does not share the original container. Remove the copy's stale `_CodeSignature` directories and embedded provisioning profile before signing. Use `codesign --sign -` to sign the new framework, then sign the copied app with hardened runtime and this test-only entitlement plist:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
  <key>com.apple.security.app-sandbox</key><true/>
  <key>com.apple.security.files.user-selected.read-only</key><true/>
  <key>com.apple.security.files.bookmarks.app-scope</key><true/>
  <key>com.apple.security.cs.disable-library-validation</key><true/>
  <key>com.apple.security.get-task-allow</key><true/>
</dict></plist>
```

```sh
codesign --force --sign - --options runtime --timestamp=none /ABS/YourCopy.app/Contents/Frameworks/VLCKit.framework
codesign --force --sign - --options runtime --timestamp=none --entitlements /ABS/test-entitlements.plist /ABS/YourCopy.app
codesign --verify --deep --strict /ABS/YourCopy.app
```

The two extra entitlements apply only to your independently signed copy: library validation permits loading your rebuilt engine, and get-task-allow permits a local debugger to inspect/pause that copy. Keep the original app's permissions unchanged. Open your own media again through the copy's file picker; original bookmarks are not transferable. Verify the actual loaded framework, modified version, playback, subtitles, speed, seeking and normal quit. Use the matching dSYM with LLDB and the prepared `lib/core.c` path for a source breakpoint; after detaching, verify playback continues. Remove the test app when finished, retaining source and diagnostic evidence.

This process was demonstrated locally with a real source edit, complete rebuild, actual library loading, a `lib/core.c:161` breakpoint, modified return value and continuing playback after detach. The same mechanism on an Apple-processed App Store installation remains an explicit platform check. If signing, receipt enforcement or loading prevents it, preserve the error and contact support; do not disable system protections to force success.

## Licenses

VLC and VLCKit modifications retain the applicable LGPL-2.1-or-later terms. mysofa code and data retain their stated BSD/MIT terms. The full license/notice texts and selected alternatives accompany this packet. Application terms do not remove applicable rights to obtain source, modify/replace the covered libraries or reverse engineer for debugging such modifications. These rights apply to the covered components; they do not automatically relicense Cinelith's separate interface source. Apple's standard application EULA includes an open-source-component exception.
