UAParserSwift is a Swift-based library to parse User Agent string; it’s a port of ua-parser-js by Faisal Salman created to be mainly used in Swift Server Side applications (Kitura, Vapor etc.).
You can however use it on client side, all Apple’s platforms are supported (iOS, macOS, tvOS and watchOS).
This library aims to identify detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model, entirely from user-agent string with a relatively small footprint.
❤️ Your Support
Hi fellow developer! You know, maintaing and developing tools consumes resources and time. While I enjoy making them your support is foundamental to allow me continue its development.
If you are using SwiftLocation or any other of my creations please consider the following options:
Usage of UAParserSwift is pretty simple; just allocate an UAParser object along with the User-Agent string you want to parse.
let parser = UAParser(agent: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7")
// Then call properties you want to read.
// Parsed data are cached and evaluated lazily in order to
// get the best performances.
let identified_os = parser.os
let identified_device = parser.device
let identified_engine = parser.engine
let identified_os = parser.os
let identified_cpu = parser.cpu
Now you can call one of these properties to get parsed data (all properties are lazy created in order to keep parser lightweight):
.browser: return a Browser object with the browser’s properties: name, version
.device: return a Device object with device’s informations: vendor,type,model
.engine: return an Engine object with information about browser’s engine: name,version
.os: return an OS object with the information about host operation system: name,version
.cpu: return a CPU object with the informations about host’s device architecture: identifier
Unit Tests are available under the Tests directory; actually they are the same tests available for ua-parser-js and all are passed successfully.
Installation
This library is written for Swift 4.x.
Swift Package Manager (Vapor or any server side framework)
Meow requires Swift 4.0 or greater to work.
This is the official way to install packages for Swift Server Side.
In your Package.swift, add the following to your dependencies array:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
User-Agent Parser based upon ua-parser.js
UAParserSwift is a Swift-based library to parse User Agent string; it’s a port of ua-parser-js by Faisal Salman created to be mainly used in Swift Server Side applications (Kitura, Vapor etc.). You can however use it on client side, all Apple’s platforms are supported (iOS, macOS, tvOS and watchOS).
This library aims to identify detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model, entirely from user-agent string with a relatively small footprint.
❤️ Your Support
Hi fellow developer!
You know, maintaing and developing tools consumes resources and time. While I enjoy making them your support is foundamental to allow me continue its development.
If you are using SwiftLocation or any other of my creations please consider the following options:
Make a donation with PayPal
Become a Sponsor
Follow Me
How it works
Introduction
Supported Browsers
Supported Devices
Supported Engines
Supported OSs
Supported Architectures
Unit Tests
Installation
License
Introduction
Usage of UAParserSwift is pretty simple; just allocate an
UAParser
object along with theUser-Agent
string you want to parse.Now you can call one of these properties to get parsed data (all properties are lazy created in order to keep parser lightweight):
.browser
: return aBrowser
object with the browser’s properties:name
,version
.device
: return aDevice
object with device’s informations:vendor
,type
,model
.engine
: return anEngine
object with information about browser’s engine:name
,version
.os
: return anOS
object with the information about host operation system:name
,version
.cpu
: return aCPU
object with the informations about host’s device architecture:identifier
Supported Browsers
Name:
Version: Determined dynamically
Supported Devices
Type:
Vendor:
Model: Determined dinamically
Supported Engines
Engine:
Engine Version: Determined dinamically
Supported OSs
Name:
Version: Determined dinamically
Supported Architectures
Identifier:
Unit Tests
Unit Tests are available under the
Tests
directory; actually they are the same tests available for ua-parser-js and all are passed successfully.Installation
This library is written for Swift 4.x.
Swift Package Manager (Vapor or any server side framework)
Meow requires Swift 4.0 or greater to work. This is the official way to install packages for Swift Server Side. In your Package.swift, add the following to your dependencies array:
To your target, add the “UAParserSwift” dependency.
CocoaPods
UAParserSwift
to your Podfile.Run
pod install
from Terminal, then open your app’s.xcworkspace
file to launch Xcode.Contributing
License
Dual licensed under GPLv2 & MIT
Copyright © 2017 Daniele Margutti hello@danielemargutti.com Original ua-parser-js Copyright: Copyright © 2012-2016 Faisal Salman fyzlman@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
This software is licensed under MIT License.
Consider ❤️ support the development of this library!
Follow me on: