Tools and helpers to make building apps faster and safer.

Related tags

Utility swift ios
Overview

UBFoundation

The UBFoundation framework provides a set of useful tools and helpers to make building apps faster and safer.

Requirments

  • iOS 11.0+ / Mac OS X 10.12+ / tvOS 12.0+ / watchOS 5.0+
  • Xcode 10.0+
  • Swift 4.2+

Installation

Use Swift Package Manager

Contribution

If you want to contribute to the framework, please check the contribution guide.

Documentation

The framework is fully documented and easy to navigate on your own. You can consult the online documentation. Or build it yourself by checking out the project and running the fastlane command fastlane documentation. You can aslo find plenty of guides under the Documentation folder in the project.

UBLocation

A UBLocationManager facilitates asking for the required authorization level for the desired usage (location, significant updates, visits or heading). The location manager forwards the updates to the client's UBLocationManagerDelegate, similar to the CLLocationManagerDelegate.

Usage

class MapViewController: UBLocationManagerDelegate {
    
    // The location manager is a singleton, because multiple location manager instance
    // might interfere (shared state of GPS hardware)
    var locationManager = UBLocationManager.shared
    
    // ... implements delegate methods
}

The monitoring for the desired location services are started and stopped with

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated: animated)
        
        // The location manager can ask for the required location permission,
        // if it has not been granted yet...
        let usage = [.location, .heading]
        locationManager.startLocationMonitoring(for: usage, delegate: self, canAskForPermission: true)
        
        // ...or not, where it is assumed that the user has been asked to grant
        // location permissions at some other point in the application.
        locationManager.startLocationMonitoring(for: usage, delegate: self, canAskForPermission: false)
    }
    
    override func viewDidDisappear(animated: Bool) {
        super.viewDidDisappear(animated: animated)
        locationManager.stopLocationMonitoring(forDelegate: self)
    }
}

UBPush

Handles requesting push permissions and sending the registration to the backend.

Usage

To use push notifications, the library UBFoundationPush needs to be imported.

UBPushManager handles requesting push permissions. Clients should customize the following components specific to the client application:

  • pushRegistrationManager, which handles registration of push tokens on our server
  • pushHandler, which handles incoming pushes

The following calls need to be added to the app delegate:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UBPushRegistrationAppDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let pushHandler = SubclassedPushHandler()
        // Only use this initializer if using default registration API, otherwise
        // also subclass UBPushRegistrationManager
        let registrationManager = UBPushRegistrationManager(registrationURL: someUrl)
        UBPushManager.shared.application(application,
                                         didFinishLaunchingWithOptions: launchOptions,
                                         pushHandler: pushHandler,
                                         pushRegistrationManager: pushRegistrationManager)
    }

    func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        UBPushManager.shared.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
    }

    func application(_: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        UBPushManager.shared.didFailToRegisterForRemoteNotifications(with: error)
    }

The UBPushHandler should be subclassed to implement application-specific behaviour for responding to push notifications while the app is running (in showInAppPushAlert(withTitle:proposedMessage:notification:)) and after the app is started when the user responded to a push (in showInAppPushDetails(for:)).

The UBPushRegistrationManager can either be created with a registrationUrl":

let registrationManager = UBPushRegistrationManager(registrationUrl: registrationUrl)

or subclassed, if a custom pushRegistrationRequest is needed.

License

Copyright (c) 2019-present Ubique Innovation AG

Comments
  • fixes user defaults bool decoding

    fixes user defaults bool decoding

    If a UserDefault value is passed via launchArgument for XCUITest it is always passed as a string therefore we try to interpret the string as a fallback. https://github.com/admin-ch/CovidCertificate-App-iOS/blob/main/CovidCertificate/SharedUI/Helpers/UBUserDefault/UBUserDefault.swift#L63-L89

    opened by stmitt 2
  • SwiftUI Popup

    SwiftUI Popup

    This PR shows a possible implementation of a SwiftUI popup API:

    • The new View modifier .ub_popup() works in the same way as most other presentation modifiers (e.g. .sheet()): it takes a Binding that can be set to true or false to control whether the popup is shown or not. For the modifier to work, the view that it's applied on needs to be wrapped inside a UBPopupWrapper view.
    opened by ubfelix 2
  • Print errorCode from UBCodedError

    Print errorCode from UBCodedError

    If an error happens within the UBNetworking machinery (e.g. adding request modifiers) we can throw any errors, specifically UBCodedError which provides an error description.

    Currently, this error description was discarded in favour of NSError.code which makes it impossible to propagate multiple inner errors.

    In this PR the otherNSUrlError is renamed to otherError. Further, in errorCode getter, the NSError is checked for conformance to the UBCodedError protocol. If so, the inner error is displayed.

    opened by ubamrein 2
  • Add region monitoring to UBLocationManager

    Add region monitoring to UBLocationManager

    This PR adds the option to monitor regions to UBLocationManager. It wraps the existing region monitoring functionality of CLLocationManager (https://developer.apple.com/documentation/corelocation/monitoring_the_user_s_proximity_to_geographic_regions).

    Since this is the first type of usage that requires passing arguments (a set of CLRegion objects), I refactored the LocationMonitoringUsage type from an OptionSet to an enum. The downside of this is that now some methods need two versions (one with a single LocationMonitoringUsage and one with an array) in order not to break existing code. Apart from that, the change should not be breaking (unless someone used the LocationMonitoringUsage OptionSet type somewhere in an unexpected fashion).

    opened by ubfelix 2
  • TOPO-1959: Expose UBURLDataTask.countOfBytesReceived

    TOPO-1959: Expose UBURLDataTask.countOfBytesReceived

    Use case:

    We would like to guard against files that are too large. We first check the content-length using a head request. Because this content length might not be set or wrong, we want to check the countOfReceivedBytes in a progress observer:

    downloadTask?.addProgressObserver { [weak self] task, _ in
              if task.countOfBytesReceived > Self.maxFileSizeBytes {
                  task.cancel()
                  self?.showError(error: TourDownloadError.fileSizeTooLarge, message: "Datei zu gross")
              }
          }
    
    opened by zenokoller 1
  • Implement Cache-Reset if Language Accept Header changes

    Implement Cache-Reset if Language Accept Header changes

    Test fails: userInfo-Dictionary doens’t seem to be cached.

    See also: https://stackoverflow.com/questions/70957803/ios-15-urlcache-cachedurlresponse-userinfo-is-always-nil

    Fixes #17

    opened by maerki 1
  • New SPM product: UBQRScanner

    New SPM product: UBQRScanner

    This PR adds a new product UBQRScanner to the UBKit library. The core of this product is a class QRScannerView, a UIView subclass that provides functionality related to the scanning of QR codes and other supported formats. Internally, it uses an AVCaptureSession.

    Successfully scanned codes (as Strings) and errors are received via the QRScannerViewDelegate methods.

    opened by ubfelix 1
  • Cached response is not invalidated when issuing a request with a different HTTP method

    Cached response is not invalidated when issuing a request with a different HTTP method

    Example: Sending a head request and a subsequent GET request to the same URL yields an empty response body for the GET request, because the cached contents of the HEAD request are returned.

    opened by zenokoller 0
  • CLLocationManager.locationServicesEnabled() on mainThread

    CLLocationManager.locationServicesEnabled() on mainThread

    This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.

    → Used by UBLocation.startLocationMonitoring.

    opened by maerki 0
  • WIP: UBSecureStorage

    WIP: UBSecureStorage

    UBSecureStorage is a drop in replacement for the iOS Keychain. Instead of saving each value individually on the keychain only the key is stored there. The actual encrypted data is stored in the documents directory

    opened by stmitt 3
  • delete nullability for data-parsers

    delete nullability for data-parsers

    We currently have a quite a few networking special cases because we distinguish between null-Data and empty-Data for successful requests. Even though both cases might exist, I argue that the have pretty much the same semantics. Therefore I suggest we just replace a (success) null-Data response with an empty-Data instance.

    opened by maerki 2
Releases(1.6.1)
  • 1.6.1(Oct 14, 2022)

    What's Changed

    • Fix NavBar appearance by @ubfelix in https://github.com/UbiqueInnovation/ubkit-ios/pull/38
    • fixes user defaults bool decoding by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/39

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.6.0...1.6.1

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Oct 14, 2022)

    What's Changed

    • Add region monitoring to UBLocationManager by @ubfelix in https://github.com/UbiqueInnovation/ubkit-ios/pull/31
    • Print errorCode from UBCodedError by @ubamrein in https://github.com/UbiqueInnovation/ubkit-ios/pull/35
    • Add DevTools by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/37

    New Contributors

    • @ubamrein made their first contribution in https://github.com/UbiqueInnovation/ubkit-ios/pull/35

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.5.0...1.6.0

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Aug 10, 2022)

    What's Changed

    • UBKit: Adds the possibility to set query parameters as percent-encoded query parameters by @choli in https://github.com/UbiqueInnovation/ubkit-ios/pull/28
    • Evaluate all QR codes not only the first one (changed API) by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/33

    New Contributors

    • @choli made their first contribution in https://github.com/UbiqueInnovation/ubkit-ios/pull/28

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.4.1...1.5.0

    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(May 27, 2022)

    What's Changed

    • UBPushRegistrationManager: Add possibility to modify data task by @ubfelix in https://github.com/UbiqueInnovation/ubkit-ios/pull/16
    • TOPO-1959: Expose UBURLDataTask.countOfBytesReceived by @zenokoller in https://github.com/UbiqueInnovation/ubkit-ios/pull/19
    • TOPO-1958: Update label type by @zenokoller in https://github.com/UbiqueInnovation/ubkit-ios/pull/21
    • TOPO-1959: Don't return cached response if http method is different by @zenokoller in https://github.com/UbiqueInnovation/ubkit-ios/pull/25
    • Implement Cache-Reset if Language Accept Header changes by @maerki in https://github.com/UbiqueInnovation/ubkit-ios/pull/18
    • Add ub_setHidden by @zenokoller in https://github.com/UbiqueInnovation/ubkit-ios/pull/22

    New Contributors

    • @zenokoller made their first contribution in https://github.com/UbiqueInnovation/ubkit-ios/pull/19

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.4.0...1.4.1

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Feb 18, 2022)

    What's Changed

    • GitHub actions by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/10
    • adds UBLoggerListener by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/12
    • New SPM product: UBQRScanner by @ubfelix in https://github.com/UbiqueInnovation/ubkit-ios/pull/13

    New Contributors

    • @ubfelix made their first contribution in https://github.com/UbiqueInnovation/ubkit-ios/pull/13

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.3.2...1.4.0

    Source code(tar.gz)
    Source code(zip)
  • 1.3.2(Dec 20, 2021)

    What's Changed

    • Streamline keychain implementations by @stmitt in https://github.com/UbiqueInnovation/ubkit-ios/pull/8

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.3.1...1.3.2

    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Dec 7, 2021)

    What's Changed

    • fix request interceptor on watchOS by @maerki in https://github.com/UbiqueInnovation/ubkit-ios/pull/6

    Full Changelog: https://github.com/UbiqueInnovation/ubkit-ios/compare/1.3.0...1.3.1

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Dec 3, 2021)

  • 1.1.1(Nov 9, 2021)

Owner
Ubique
Ubique
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.

Features • Classes and Extensions Compatibility • Requirements • Communication • Contributing • Installing and Usage • Documentation • Changelog • Exa

Fabrizio Brancati 992 Dec 2, 2022
BFKit is a collection of useful classes and categories to develop Apps faster.

Swift Version • What does it do • Language support • Requirements • Communication • Contributing • Installing and Usage • Documentation • Changelog •

Fabrizio Brancati 806 Dec 2, 2022
Shared repository for architecture and other iOS helpers.

ArchKit A shared package for all the infrastructure required to support the Architecture styles I use in my own apps. Very shortly, this architecture

Rachel Brindle 0 Jan 8, 2022
SwiftExtensionKit - SwiftExtensionKit is to contain generic extension helpers for UIKit and Foundation

RichAppz PureSwiftExtensionKit SwiftExtensionKit is to contain generic extension

Rich Mucha 0 Jan 31, 2022
🏈 Cache CocoaPods for faster rebuild and indexing Xcode project.

?? Cache CocoaPods for faster rebuild and indexing Xcode project.

Vyacheslav Khorkov 489 Jan 6, 2023
IOS-Bootcamp-Examples - Learn to Swift while building apps - With IOS Development Bootcamp

IOS-Bootcamp-Examples Learn to Swift while building apps - With IOS Development

Bilge Çakar 9 Dec 21, 2022
Vaccine is a framework that aims to make your apps immune to recompile-disease.

Vaccine Description Vaccine is a framework that aims to make your apps immune to recompile-disease. Vaccine provides a straightforward way to make you

Christoffer Winterkvist 298 Dec 23, 2022
A collection of common tools and commands used throughout the development process, customized for Kipple projects.

KippleTools A collection of common tools and commands used throughout the development process, customized for Kipple projects. ⚠️ The code in this lib

Kipple 10 Sep 2, 2022
FeatureFlags.swift - Tools for easily defining feature flags for your projects

FeatureFlags.swift Tools for easily defining feature flags for your projects Int

Eric Rabil 1 Jan 31, 2022
Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Apple 2k Dec 28, 2022
A result builder that allows to define shape building closures

ShapeBuilder A result builder implementation that allows to define shape building closures and variables. Problem In SwiftUI, you can end up in a situ

Daniel Peter 47 Dec 2, 2022
Make trains of constraints with a clean style!

Constren ?? . ?? . ?? Make trains of constraints with style! button.constren.centerY() .lead(spacing: 16) .trail(image.l

Doruk Çoban 4 Dec 19, 2021
Enzyme is a spm package for the make easier development on iOS

Enzyme Enzyme is a spm package for the make easier development on iOS. Installation For the installation you just need to add the url of the project t

Ebubekir 2 Jan 20, 2022
A Collection of useful Swift property wrappers to make coding easier

Swift Property Wrappers A Collection of useful Swift property wrappers to make c

Gordan Glavaš 2 Jan 28, 2022
DGPreview - Make UIKit project enable preview feature of SwiftUI

DGPreview Make UIKit project enable preview feature of SwiftUI Requirements iOS

donggyu 5 Feb 14, 2022
An open source Instapaper clone that features apps and extensions that use native UI Components for Mac and iOS.

TODO: Screenshot outdated Hipstapaper - iOS and Mac Reading List App A macOS, iOS, and iPadOS app written 100% in SwiftUI. Hipstapaper is an app that

Jeffrey Bergier 51 Nov 15, 2022
Message passing between iOS apps and extensions.

MMWormhole MMWormhole creates a bridge between an iOS or OS X extension and its containing application. The wormhole is meant to be used to pass data

Mutual Mobile 3.9k Dec 28, 2022
Updeto is a simple package that help update checker for iOS Apps

Updeto is a simple package that will help you to check if the currently installed version is the same as the latest one available on App Store.

Manuel Sánchez 8 Jul 8, 2022
Command line apps for hacking on baseball stats

Thes are some swift command line apps I use to hack on my roto baseball league. No warranty or claim of usability what-so-ever. This represents work I

Jaim Zuber 0 Nov 4, 2021