A simple utility allowing to detect Swift version at runtime.

Overview

SwiftVersionDetector

SwiftVersionDetector allows you to detect Swift version at runtime.

Note that detecting the Swift version of the machine on which your app is being executed is extremely different from Swift conditional compilation which allows to get Swift version only at compile-time.

Usage

let version = try SwiftVersionDetector.detectRuntimeSwiftVersion()
print(version.major) // Prints "5"
print(version.minor) // Prints "3"
print(version) // Prints "Swift version 5.3"

Installation

Xcode Projects

Select File -> Add Packages... -> search for https://github.com/Ventus218/SwiftVersionDetector -> Add Package -> Add Package

Swift Package Manager Projects

You can add SwiftVersionDetector as a package dependency in your Package.swift file:

Remember to check for an updated version :)

let package = Package(
    //...
    dependencies: [
        .package(url: "https://github.com/Ventus218/SwiftVersionDetector", from: "1.0.0"),
    ],
    //...
)

From there, refer to the SwiftVersionDetector "product" delivered by the SwiftVersionDetector "package" inside of any of your project's target dependencies:

targets: [
    .target(
        name: "YourAppName",
        dependencies: [
            .product(
                name: "SwiftVersionDetector",
                package: "SwiftVersionDetector"
            ),
        ],
        ...
    ),
    ...
]

Then simply import SwiftVersionDetector wherever you’d like to use it.

Contributing

Contributions to SwiftVersionDetector are most welcome. Check out some of the issue templates for more info.

License

SwiftVersionDetector is available under the MIT license. See the LICENSE file for more info.

You might also like...
Simple utility for only executing code every so often.

Rate Limit Simple utility for only executing code every so often. This will only execute the block passed for a given name if the last time it was cal

Prueba versión Swift

🚀 APOD-SoyYO-Swift 🚀 Prueba técnica Dependencias: Cocoapods ¿Como correr el App? Descarga el proyecto usando git git clone https://github.com/hd3vC0

A utility that reminds your iPhone app's users to review the app written in pure Swift.
A utility that reminds your iPhone app's users to review the app written in pure Swift.

SwiftRater SwiftRater is a class that you can drop into any iPhone app that will help remind your users to review your app on the App Store/in your ap

A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Super powerful remote config utility written in Swift (iOS, watchOS, tvOS, OSX)
Super powerful remote config utility written in Swift (iOS, watchOS, tvOS, OSX)

Mission Control Super powerful remote config utility written in Swift (iOS, watchOS, tvOS, OSX) Brought to you by Have you ever wished you could chang

Recreating a fully functional version of iOS 4 in SwiftUI.
Recreating a fully functional version of iOS 4 in SwiftUI.

Updates: Version 1.0 is currently available 🎉 While I work on fixing an issue in Xcode 12.5+ with LazyVGrid, I recommend you build using Xcode 12.4 a

Checks if there is a newer version of your app in the AppStore and alerts the user to update.
Checks if there is a newer version of your app in the AppStore and alerts the user to update.

YiAppUpdater Checks if there is a newer version of your app in the AppStore and alerts the user to update. Installation YiAppUpdater is available thro

Monitor iOS app version easily.

AppVersionMonitor Monitor iOS app version easily. You can get previous version and installation history. Usage To run the example project, clone the r

A way to easily add Cocoapod licenses and App Version to your iOS App using the Settings Bundle
A way to easily add Cocoapod licenses and App Version to your iOS App using the Settings Bundle

EasyAbout Requirements: cocoapods version 1.4.0 or above. Why you should use Well, it is always nice to give credit to the ones who helped you 😃 Bonu

Comments
  • Added CI tests on Ubuntu and MacOS

    Added CI tests on Ubuntu and MacOS

    Added tests for every Swift version from 5.1 to latest on Ubuntu and tests with default Swift version on macOS from 10.15 to latest.

    This closes #1 and closes #2

    enhancement 
    opened by Ventus218 0
Releases(1.1.0)
  • 1.1.0(May 23, 2022)

    What's Changed

    • Forcing compilation error if not on macOS or Linux d37b8bb71bfffe2521974ad7ecd2d5a9eaff0309 This workaround allows at least to give a suggestion about building on the right platform as it is not possible through spm.

    Full Changelog: https://github.com/Ventus218/SwiftVersionDetector/compare/1.0.2...1.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Alessandro Venturini
Software-Engineering student 😆
Alessandro Venturini
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift.

Easy way to detect device environment: Device model and version Screen resolution Interface orientation iOS version Battery state Environment Helps to

Anatoliy Voropay 582 Dec 25, 2022
Swift Server Implementation - RESTful APIs, AWS Lambda Serverless For Swift Runtime amazonlinux: AWS Lambda + API Gateway

Swift Server Implementation - RESTful APIs, AWS Lambda Serverless For Swift Runtime amazonlinux: AWS Lambda + API Gateway deployed on Graviton arm64 build swift:5.6.2-amazonlinux2-docker image

Furqan 2 Aug 16, 2022
I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it.

Inactivity I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it. Usage Important: You must set the Principal class of your app to In

Helio Tejedor 16 Dec 19, 2022
💡 A light Swift wrapper around Objective-C Runtime

A light wrapper around Objective-C Runtime. What exactly is lumos? lumos as mentioned is a light wrapper around objective-c runtime functions to allow

Suyash Shekhar 139 Dec 19, 2022
Swift-friendly API for a set of powerful Objective C runtime functions.

ObjectiveKit ObjectiveKit provides a Swift friendly API for a set of powerful Objective C runtime functions. Usage To use ObjectiveKit: Import Objecti

Roy Marmelstein 850 Oct 25, 2022
Plugin and runtime library for using protobuf with Swift

Swift Protobuf Welcome to Swift Protobuf! Apple's Swift programming language is a perfect complement to Google's Protocol Buffer ("protobuf") serializ

Apple 4.1k Dec 28, 2022
Simple and Lightweight App Version Tracking for iOS written in Swift

AEAppVersion Simple and lightweight iOS App Version Tracking written in Swift I made this for personal use, but feel free to use it or contribute. For

Marko Tadić 12 Nov 11, 2022
A simple Swift utility for producing pseudolocalized strings.

Build your App UI to adapt and respond to translations, and find localization bugs!

Reece Como 2 Sep 28, 2021
Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image

Change menu bar color in macOS Big Sur Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wal

Igor Kulman 876 Jan 5, 2023
A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar.

bose-macos-utility A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar. Why Have you e

Łukasz Zalewski 11 Aug 26, 2022