Swiftlet Utilities provides several useful functions that are common across many apps written in SwiftUI and Xcode. These include features such as testing to see if an app can connect to the internet, etc.
NOTE: Swiftlet Utilities is a replacement for our Action Utilities library specifically designed to work with SwiftUI. Several other features have been modernized and improved as well.
Additionally, many built-in types (such as Color
, String
and Data
) have been extended with useful features such as converting a color to and from a hex string and moving images easily between Data
and String
types to support Swift's Codable
protocol.
Swiftlet Utilities are support on iOS, tvOS, watchOS and macOS.
Swift Package Manager (Xcode 11 and above)
https://github.com/Appracatappra/SwiftletUtilities.git
in the dialog box.Why not CocoaPods, or Carthage, or blank?
Supporting multiple dependency managers makes maintaining a library exponentially more complicated and time consuming.
Since, the Swift Package Manager is integrated with Xcode 11 (and greater), it's the easiest choice to support going further.
General Utilities provide several, general utility classes to handle thing such as network connectivity.
The following extensions are provided:
Hardware Utilities provide commonly used information about the device an app is running on such as the device type (for example iPhoneX
), the OS version (for example iOS 11.1
) and if the app can connect to the internet.
The following extensions are provided:
iPhone10,3
) to a human readable form (such as iPhoneX
). This enum works with the HardwareInformation
class to get the type of device the app is running on.iPhone10,3
), getting the device type (iPhoneX
), getting the OS version (iOS 11.1
), the current device orientation and internet connection state:
true
if the app is running on an iPhone, else returns false
.true
if the app is running on an iPad, else returns false
.true
if the app is running on an Apple TV, else returns false
.true
if the app is running on a CarPlay connected device, else returns false
.true
if the app is running on an Apple Watch, else returns false
.true
if the app is running on a Mac laptop or desktop, else returns false
.iPhone10,3
or iPhone10,6
for the iPhone X
.iPhoneX
) or unknown
if the type cannot be discovered.iOS 11.1
) of the OS installed on the device that the app is running on.Swiftlet Extensions provide several useful features to common, built-in SwiftUI and Swift data types such as converting Color
to/from hex strings (for example #FF0000
), creating Image
instances from Base64 encoded strings stored in Data
objects and encoding Images
as Base64 strings or Data
objects.
// Assign a color from a string
let color: Color ~= "#FF0000"
// Initialize a color from a hex string
let green = Color(fromHex: "00FF00")
// Convert color to a hex string
let white = Color.white.toHex()
The following extensions are provided:
Color
to support the Action Data controls and adds convenience methods for working with colors in a Codable
, Encodable
or Decodable
class.Data
to support the Action Data controls and adds convenience methods for working with data properties in a Codable
, Encodable
or Decodable
class.Image
to support the Action Data controls and adds convenience methods for working with image properties in a Codable
, Encodable
or Decodable
class.String
to support the Action Data controls and adds convenience methods for working with Image
and Color
properties in a Codable
, Encodable
or Decodable
class.Array
with new functions for working with collections.Double
with several useful features.Int
with several useful features.@Published
and allows them to be Codable
with Encode
and Decode
conformance.link |
Stars: 3 |
Last commit: 6 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics