Swiftpack.co -  Q42/Q42Stats as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Q42/Q42Stats
Project to gather some statistics around how platform features are used
.package(url: "https://github.com/Q42/Q42Stats.git", from: "v1.0.1")

Q42Stats

Collect stats for Q42 internal usage, shared accross multiple iOS projects.

Instalation

  1. Use SPM or CocoaPods to add Q42Stats into your iOS project
  2. Implement your configuration and a SHA256 implementation (see reference implementations below)
  3. Include stats collection & submission in your AppDelegate/WindowSceneDelegate like so:
Q42Stats(options: .all)
  .collect(window: window, completion: Q42Stats.submit(configuration: .myApp, sha256: sha256))

Note: Make sure you have the correct consent from the user before you call .collect().

CocoaPods

Add to your Podfile the following line:

pod 'Q42Stats', git: 'https://github.com/Q42/Q42Stats.git'

Also make sure you require iOS 11 or higher as the minimum target using: platform :ios, '11.0'

Swift Package Manager

Add this repo as a dependency through Xcode: https://github.com/Q42/Q42Stats.git

Reference implementations

Example configuration implementation

extension Q42Stats.Configuration {
  static let myApp = Q42Stats.Configuration(
    firebaseProject: "theproject",
    firebaseCollection: "somecollection",
    minimumSubmitInterval: 60*60*24*7.5,
    sharedSecret: "random-string-used-for-creating-a-checksum"
  )
}

SHA256 using CommonCrypto

Note that this implementation needs a bridging header that contains: #import <CommonCrypto/CommonCrypto.h>

func sha256(string: String) -> String {
  let data = string.data(using: .utf8)!
  var hash = [UInt8](https://raw.github.com/Q42/Q42Stats/master/repeating: 0,  count: Int(CC_SHA256_DIGEST_LENGTH))
  data.withUnsafeBytes {
    _ = CC_SHA256($0.baseAddress, CC_LONG(data.count), &hash)
  }
  return Data(hash).map { String(format: "%02hhx", $0) }.joined()
}

GitHub

link
Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

v1.0.2
1 week ago

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