Cephei Framework

repository·main·Indexed 42 days ago

https://github.com/hbang/libcephei

A framework for jailbroken iOS devices (iOS 5.0+) providing convenience features for developers, primarily focusing on settings-related UI and utilities. Includes components like CepheiUI and CepheiPrefs, and provides a command-line interface for reading and writing defaults preferences.

Tokens
1.1K
Snippets
4
Records
6
Agent score
53%

What's inside Cephei

  1. Allow CepheiPrefs usage in non-Settings apps via Info.plist

    main

    By default, CepheiPrefs.framework displays a warning message on app launch if it is used in an application other than Settings or the Watch app. To suppress this warning in your own application, add the HBUsesCepheiPrefs key to your Info.plist and set it to true.

    <key>HBUsesCepheiPrefs</key>
    <true/>
  2. Suppress CepheiPrefs warnings from a tweak

    main

    If you are using CepheiPrefs within a tweak and want to prevent the warning alert from appearing, you can hook HBForceCepheiPrefs and force its method to return YES.

    Important: The hook must be applied before UIApplicationDidFinishLaunchingNotification is posted to effectively suppress the alert.

    %hook HBForceCepheiPrefs
    
    + (BOOL)forceCepheiPrefsWhichIReallyNeedToAccessAndIKnowWhatImDoingISwear {
        return YES;
    }
    
    %end
  3. Use Cephei to read and write defaults preferences

    main

    Cephei provides a command-line interface for interacting with the defaults system to manage read and write preferences for specific identifiers or global settings.

    Command Syntax

    • Read all preferences for an ID: defaults read <id>
    • Read a specific key: defaults read <id> <key>
    • Write a value to a key: defaults write <id> <key> <value>

    Supported Value Types

    When writing values, you should specify the type to ensure correct data representation:

    • String: <value> or -string <value>
    • Integer: -int <value> or -integer <value>
    • Float: -float <value>
    • Boolean: -bool <value> or -boolean <value>

    Note: Dictionary, array, data, and date values are not currently supported for writing through this tool.

    Exit Codes

    • 0: Success
    • 1: Failure to read or write
    • 2: Invalid input
    # Show all preferences for com.apple.springboard
    defaults read com.apple.springboard
    
    # Show the value for a specific key
    defaults read com.apple.springboard SBBacklightLevel2
    
    # Write a global preference
    defaults write -g AppleLocale en_US
    
    # Write a float value to a specific key
    defaults write com.apple.springboard SBBacklightLevel2 -float 0.5
  4. Integrate Cephei into a Theos project

    main

    To use Cephei in a Theos-based tweak project, you must link the framework and declare the dependency in your control file. Theos provides the necessary headers and linkable frameworks automatically.

    Add Cephei to your EXTRA_FRAMEWORKS list in the Makefile. If your project specifically uses CepheiUI or CepheiPrefs, you must add those names to the list as well.

    2. Declare Dependencies

    You must add ws.hbang.common to the Depends: list in your project's control file. It is recommended to specify the minimum version of Cephei required to ensure all features used by your tweak are available on the user's device.

    Note: If ws.hbang.common is not present on the device, your binaries will fail to load.

    # In your Makefile
    MyAwesomeTweak_EXTRA_FRAMEWORKS += Cephei
    
    # If using specific components:
    MyAwesomeTweak_EXTRA_FRAMEWORKS += CepheiUI CepheiPrefs
    # In your control file
    Depends: mobilesubstrate, something-else, some-other-package, ws.hbang.common (>= 2.0)
  5. Preview CepheiPrefs via file copy

    main

    You can preview how CepheiPrefs looks by manually copying the Cephei preference bundle entry to your device's preference loader directory. After copying, quit and relaunch the Settings app.

    Steps:

    1. Copy /Library/PreferenceBundles/Cephei.bundle/entry.plist to /Library/PreferenceLoader/Preferences/Cephei.plist.
    2. Relaunch Settings.