Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markbattistella/platformchecker
PlatformKit provides easy-to-use Swift properties for checking device and OS environments across Apple platforms. Ideal for tailoring app behavior in iOS, macOS, tvOS, watchOS, and visionOS.
https://github.com/markbattistella/platformchecker
appkit catalyst hacktoberfest ios ipados macos macos-catalyst simulator swift swiftui tvos uikit utility visionos watchos
Last synced: 7 days ago
JSON representation
PlatformKit provides easy-to-use Swift properties for checking device and OS environments across Apple platforms. Ideal for tailoring app behavior in iOS, macOS, tvOS, watchOS, and visionOS.
- Host: GitHub
- URL: https://github.com/markbattistella/platformchecker
- Owner: markbattistella
- License: mit
- Created: 2024-05-10T03:54:18.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-09-13T07:42:53.000Z (3 months ago)
- Last Synced: 2024-11-17T17:39:54.036Z (about 1 month ago)
- Topics: appkit, catalyst, hacktoberfest, ios, ipados, macos, macos-catalyst, simulator, swift, swiftui, tvos, uikit, utility, visionos, watchos
- Language: Swift
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PlatformChecker
![Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmarkbattistella%2FPlatformChecker%2Fbadge%3Ftype%3Dswift-versions)
![Platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmarkbattistella%2FPlatformChecker%2Fbadge%3Ftype%3Dplatforms)
![Licence](https://img.shields.io/badge/Licence-MIT-white?labelColor=blue&style=flat)
**PlatformChecker** provides a structured and intuitive way to access environment-specific checks across different Apple platforms. It is designed to facilitate the integration of platform-specific functionalities in cross-platform Swift projects.
## Features
- **Platform Checks:** Quickly determine which Apple platform your application is currently running on (iOS, macOS, watchOS, tvOS, visionOS).
- **Device Checks:** Easily identify device types such as iPhone, iPad, and Vision devices.
- **Environment Checks:** Check if your app is running as a Mac Catalyst app, in a simulator, or through TestFlight, and whether it's in debug mode.## Installation
### Swift Package Manager
You can add PlatformChecker to your project via Swift Package Manager. Add the following dependency to your `Package.swift`:
```swift
dependencies: [
.package(
url: "https://github.com/markbattistella/PlatformChecker.git",
from: "1.0.0"
)
]
```## Usage
Import PlatformChecker in the Swift file where you want to use the platform and device checks:
```swift
import PlatformChecker
```### Example Usage
Here are some examples of how you can use PlatformChecker in your project:
```swift
if Platform.isiOS {
print("Running on iOS")
}if Platform.isiPhone {
print("Device is an iPhone")
}if Platform.isDebugMode {
print("Debug mode is enabled")
}
```These checks can be used to conditionally apply logic or configurations based on the operating system, device type, or runtime environment.
## Properties
| Property | Description |
|--------------------|---------------------------------------------------------------------------|
| `Platform.isiOS` | Returns `true` if running on iOS, excluding Mac Catalyst apps. |
| `Platform.isTVOS` | Returns `true` if running on tvOS. |
| `Platform.isMacOS` | Returns `true` if running on macOS, excluding Mac Catalyst apps. |
| `Platform.isWatchOS`| Returns `true` if running on watchOS. |
| `Platform.isVisionOS`| Returns `true` if running on visionOS, specific to Apple's Vision Pro devices. |
| `Platform.isiPhone`| Returns `true` if the device is an iPhone, excluding Mac Catalyst. |
| `Platform.isiPad` | Returns `true` if the device is an iPad, excluding Mac Catalyst. |
| `Platform.isTV` | Returns `true` if the device is identified as a TV. |
| `Platform.isVisionDevice`| Returns `true` if the device is a Vision device, specific to visionOS. |
| `Platform.isMacCatalyst`| Returns `true` if the app is running as a Mac Catalyst app. |
| `Platform.isSimulator`| Returns `true` if the app is running in a simulator. |
| `Platform.isDebugMode`| Returns `true` if the current build configuration is set for debugging. |
| `Platform.isTestFlight`| Returns `true` if the app is running through TestFlight. |## Documentation
Each property in the Platform struct is documented with inline comments that explain what the property checks and its intended use case.
## Contributing
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.
## License
PlatformChecker is released under the MIT license. See [LICENSE](https://raw.githubusercontent.com/markbattistella/PlatformChecker/main/LICENCE) for details.