Swiftpack.co - ITzTravelInTime/TINURecovery as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ITzTravelInTime.
ITzTravelInTime/TINURecovery 5.0.2
macOS Swift library, from TINU, to detect: Recovery Mode, SIP, Sandbox and Current User. Also providing NVRAM functions.
⭐️ 5
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/ITzTravelInTime/TINURecovery.git", from: "5.0.2")

TINURecovery

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

Features and usage

SimpleReachability:

  • Provvides a simple way to check if network conenction is available.

Basic example usage


import TINURecovery

print("Is the computer connected to the network? \(SimpleReachability.status ? "Yes" : "No")")

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(forKey: "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

Legal info

TINURecovery: Library with the Recovery Mode, SIP, Sandbox, User detection, nvram and network detection functions used by TINU. Copyright (C) 2021-2022 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: 5
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Version 5.0.2
1 year ago
  • Limited the availability of SimpleReachability to fix some building issues on some platforms.

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