Swiftpack.co -  ITzTravelInTime/TINURecovery as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ITzTravelInTime/TINURecovery
Library with the Recovery Mode, Sandbox and User detection functions used by TINU
.package(url: "https://github.com/ITzTravelInTime/TINURecovery.git", from: "3.7.6")

TINURecovery

Library with the Recovery Mode, SIP, Sandbox and User detection functions used by TINU

Features and usage

SimulatableDetectable:

  • A protocol for objects that needs to have simulated debug states.

    Example usage:


import TINURecovery

class Foo: SimulatableDetectable{

    ///if this property is nil the `actualStatus` property will be returned by the `status` propert, otherwise that will return the value of this property
    static var simulatedStatus: Bool? = nil
    
    ///Returns the actual status
    static var actualStatus: Bool{
        return false
    }
    
    ///Initializer for compliance with the protocol
    public required init(){  }
    
}

print("Testing Foo status: ")

print("Foo status: \(Foo.status)") //returns false
print("Foo actual status: \(Foo.actualStatus)") //returns false


print("Simulating a new status")
Foo.simulatedStatus = true

print("Foo status: \(Foo.status)") //returns true
print("Foo actual status: \(Foo.actualStatus)") //returns false

print("Foo testing is complete")

Recovery:

WARNING: Requires sandboxing to be disabled.

  • [Available only on macOS] detects if the current program is running inside a macOS Installer/Recovery OS and allows for debugabbility inside a normal macOS by creating a subclass and overriding the 'simulatedStatus' value.

    Basic example usage:


import TINURecovery

print("Is this program running on a macOS Recovery/Installer OS? \((Recovery.status ? "Yes" : "No"))")

SIP:

WARNING: Requires sandboxing to be disabled.

  • [Available only on macOS] detects the status of macOS's SIP (System Integrity Protection) and allows for debugabbility reguardless of the actual status of it on the computer by creating a subclass and overriding the 'simulatedStatus' propery.

    Basic example usage:


import TINURecovery

if let status = SIP.status.resultsEnabled {
    print("Is SIP activated? \(status ? "Yes" : "No")")
}else{
    print("SIP status is unknown")
}

print("Does SIP use a custom configuration? \(SIP.status.usesCustomConfiguration ? "Yes" : "No")")

Sandbox:

  • [Available only on macOS] Used to detect if the current app is running with the app Sandbox enabled or not.

    Example usage:


import TINURecovery

print("Is this app sandboxed? \(Sandbox.isEnabled ? "Yes" : "No")")

User:

  • [Available only on macOS] Just a more convenenint way of getting the current user's logon name and if it's the Root user.

    Example usage:


import TINURecovery

print("Is this user Root? \(CurrentUser.isRoot ? "Yes" : "No")")
print("What's the user name? \(CurrentUser.name)")

NVRAM:

WARNING: Requires sandboxing to be disabled.

  • [Available only on macOS] A simple way to read and write NVRAM values

    Example usage:


import TINURecovery

if let args = NVRAM.getString(name: "boot-args") {
    print("Current boot args: \(args)")
}

Who should use this Library?

This library should be used by swift apps/programs that requires to obtain particular info about the system, things like the SIP status, or particular info about the app/program itself like the if sandboxing is enabled.

This code is intended for macOS only, it might also work on other Apple's OSes for the non-macOS-specific features but it's untested.

About the project

This code was created as part of my TINU project (https://github.com/ITzTravelInTime/TINU) and has been separated and made into it's own library to make the main project's source less complex and more focused on it's aim.

Also having it as it's own library allows for code to be updated separately and so various versions of the main TINU app will be able to be compiled all with the latest version of this library.

Libraries used

Credits

Contacts

Copyright

Copyright (C) 2021 Pietro Caruso

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

GitHub

link
Stars: 0
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

3.7.6
4 weeks ago
  • Added SIP.SIPStatus.resultsFullyDisabled to detect if SIP is actually fully disabled
  • Improved some comments and descriptions
  • Updated the demo playground
  • Bug fix

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics