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: about 2 months 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-20T03:06:34.000Z (4 months ago)
- Last Synced: 2026-02-20T07:12:52.260Z (4 months ago)
- Topics: appkit, catalyst, hacktoberfest, ios, ipados, macos, macos-catalyst, simulator, swift, swiftui, tvos, uikit, utility, visionos, watchos
- Language: Swift
- Homepage: https://swiftpackageindex.com/markbattistella/PlatformChecker/documentation
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PlatformChecker



**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.