Swiftpack.co - Package - Q42/Q42Stats

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


Project to gather some statistics around how platform features are used


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


  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().


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()


Stars: 0
Last commit: 35 weeks ago