Skip to content

Instantly share code, notes, and snippets.

View andr3a88's full-sized avatar

Andrea Stevanato andr3a88

View GitHub Profile
import Foundation
import RealmSwift
protocol CascadingDeletable {
var cascadingDeletions: [AnyObject?] { get }
}
extension Realm {
func delete<T: AnyObject>(_ objects: List<T>, cascade: Bool = true) where T: CascadingDeletable {
@andr3a88
andr3a88 / build-binary-universal-framework.sh
Created July 24, 2019 08:43 — forked from quangDecember/build-binary-universal-framework.sh
Build Binary framework script for iOS, included fix for Xcode 10.2 headers, originally by DJ110
# Xcode 10.2
# please use within Xcode environment (Build Phases -> Run Script or Scheme -> Post Actions)
xcodebuild -version
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
env > env.txt
# Step 1. Build Device and Simulator versions
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@andr3a88
andr3a88 / CountdownTests.swift
Created November 30, 2022 11:58 — forked from JonnyBeeGod/CountdownTests.swift
This code allows for testing UNNotificationCenter and UNNotificationSettings
func testNotifications() {
// map all authorizationStatus with expected Result
let authorizationStatusMap: [UNAuthorizationStatus: Int] = [.authorized: 1, .denied: 0, .notDetermined: 0, .provisional: 1]
UNNotificationSettings.swizzleAuthorizationStatus()
authorizationStatusMap.forEach { (key: UNAuthorizationStatus, value: Int) in
UNNotificationSettings.fakeAuthorizationStatus = key
let mockCenter = UserNotificationCenterMock()
let mockCoder = MockNSCoder()