Skip to content

Latest commit

 

History

History
77 lines (56 loc) · 2.31 KB

README.md

File metadata and controls

77 lines (56 loc) · 2.31 KB

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.