Swiftpack.co - SwiftCommon/DataKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SwiftCommon.
SwiftCommon/DataKit 1.1.0
Swift µframework for common Data + String operations
⭐️ 7
🕓 2 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/SwiftCommon/DataKit.git", from: "1.1.0")

DataKit

Swift 5.0+ license Build Status codecov Carthage Compatible

Swift µframework for Data operations.

Getting started

On first checkout you best run: $ script/setup and when you're a regular user just: $ script/update. These scripts are also available through GNUMake: $ make setup & $ make update. For more info on the scripts checkout script/README.md

** Note: these scripts may update the Xcode project file and resolve the Package.resolved dependencies. You can also do this by running:
$ bundle install && bundle exec fastlane gen_xcodeproj

Features

Data+Base64

  • Base64 encode data blob
let data = Data(bytes: [0xc3, 0x98, 0x61, 0x62, 0x63, 0x64])
let base64encoded = Base64.standard.encode(data: data)
  • Base64 (URL and File safe) encode data
let data = Data(bytes: [0xc3, 0x98, 0x61, 0x62, 0x63, 0x64])
let urlSafeEncoded = Base64.urlSafe.encode(data: data, padding: .none)
  • Base64 decode data blob
let base64 = Data(bytes: [0x75, 0xF7, 0xAB, 0xE7, 0xAE, 0x9F, 0x14, 0x38, 0x63, 0x7C, 0x50, 0xD2, 0xB2, 0xCC, 0x2B, 0xAF, 0x0C, 0x30])
let data = try Base64.decode(data: base64) // Base64 decoded data or error
  • Base64 decode string
let base64 = "dfer566fFDhjfFDSsswrrwwwwsd"
let data = try Base64.decode(string: base64) // Base64 decoded data or error

Data+String

  • Convert Data to UTF-8 or ASCII String
let data = Data(bytes: [0xc3, 0x98, 0x61, 0x62, 0x63, 0x64])
data.utf8string // -> "Øabcd"
data.asciiString // -> nil
  • Map Data to Hexidecimal String
let data = Data(bytes: [0xc3, 0x98, 0x61, 0x62, 0x63, 0x64])
data.hexString() // -> "C39861626364
  • Initialize Data with Hex String
let hexString = "C39861626364"
Data(hex: hexString) // -> [0xc3, 0x98, 0x61, 0x62, 0x63, 0x64]

Installation

Carthage

Put this in your Cartfile:

  github "SwiftCommon/DataKit" ~> 1.0

SwiftPM

Put this in your Package.swift:

   ...
   dependencies: [
      .package(url: "https://github.com/SwiftCommon/DataKit", "0.0.1" ..< "1.0.0")
   ],
   targets: [
      .target(
         name: "YourAwesomeApp",
         dependencies: ["DataKit"]
      )
   ]

Documentation

To create the documentation run: bundle exec fastlane gen_docs and open ./docs/index.html

Contributing

Feel free to check the TODO list and/or add your favourite missing Data related feature through a Pull request.

License

Licensed under the MIT license.

GitHub

link
Stars: 7
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.1.0 - Long overdue maintenance
2 years ago

Thanks to @mfiebig and @dennishahn for making this release possible and keeping DataKit alive 🎉

  • [Tools] Add support for xcframeworks with Carthage for supporting all apple architectures with Carthage (@dennishahn)
  • [Migration] Change Fastlane to version v2.187 to be able to use Carthage with xcframeworks (@dennishahn)
  • [Migration] Change Danger to version v8.3.1 to solve underlying dependency conflicts of Fastlane version v2.187 (@dennishahn)
  • [Migration] Change Nimble to version v9.2.0 so that there are no conflicts with our other dependencies :) (@dennishahn)
  • [Migration] Add BUILD_LIBRARY_FOR_DISTRIBUTION: true to be able to have diffing swift versions (@dennishahn)
  • [Migration] Change iOS minimal version support to iOS v9 (which is minimal supported version for Xcode12) (@dennishahn)
  • [Fix] Buffer underrun (@mfiebig)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics