Skip to content

Instantly share code, notes, and snippets.

@dinneo
dinneo / recommended-settings.json
Created December 18, 2021 15:19 — forked from DoctorDerek/recommended-settings.json
Recommended settings.json file for new web developers setting up VS Code according to https://medium.com/p/65aaa5788c0d/ by Dr. Derek Austin 🥳
@dinneo
dinneo / CountryCode.h
Created June 27, 2021 09:02 — forked from theiostream/CountryCode.h
Get a country code from Apple's StoreFront IDs.
// CountryCode.h
// (c) 2013 Bacon Coding Company, LLC.
// Licensed under the MIT License.
// I lost my time scripting this dictionary in Python than I'd have writing it.
// Regardless, it was some fun.
#import <Foundation/Foundation.h>
// Reference: http://www.apple.com/itunes/affiliates/resources/documentation/linking-to-the-itunes-music-store.html#appendix
@dinneo
dinneo / xcode-build-bump.sh
Created June 19, 2021 01:28 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@dinneo
dinneo / README.md
Created June 16, 2021 11:06 — forked from BadPirate/README.md
A utility class for capturing iOS App Will Suspend, and App Did Un-suspend events

Summary

iOS doesn't report when an app will be suspended (placed from background into a non-processing state) nor does it seem to fire a notification once the app has resumed. There is some confusion about this as there is a notification when the app becomes "active" or will resign the "active" state, however this is not always the right value needed. iOS Apps have a number of states:

  1. Active: App is in the foreground (frontmost) and there are no notifications or menu's pulled over it. Pulling a menu down or getting an external notification or text message will cause the app to "resign" active, and resume active once the alert has been dealt with.
  2. Background: App is not in the foreground but still processing. This happens briefly before suspend if there are no background tasks running, or can be a permanent state if there is a long running background mode (audio, location, etc) running.
//
// Setting a launch argument or environment variable can be done from Xcode in the Arguments tab in scheme edition.
//
// Launch arguments have only one input field and need a `-` at the start, e.g. `-aLaunchArgument`.
// Environment variables have instead two fields, one for the name and one for the value.
//
// More information can be found on NSHipster: http://nshipster.com/launch-arguments-and-environment-variables/
//
// Read an environment variable
@dinneo
dinneo / UITestOther
Created June 1, 2021 16:26 — forked from alecsechechel/UITestOther
UI Testing button, textField, allert, navigation bar
func testOther() {
let app = XCUIApplication() //create app
XCTAssertTrue(app.navigationBars.staticTexts["Title"].exists) //check navigation bar title
XCTAssertTrue(app.buttons["Test"].exists) //check button with title Test
app.buttons["Test"].tap() //tap button
XCTAssertTrue(app.alerts["Error"].exists) //check allert with title Error
app.alerts["Error"].buttons.elementBoundByIndex(0).tap()//tap first button on allert
let textField = app.textFields["nameTextField"] //choose textFields with idenificator nameTextField
textField.tap()// tap on text fields
textField.typeText("correct")// write text to textFields
@dinneo
dinneo / AppDelegate.swift
Created June 1, 2021 13:31 — forked from jonathan-beebe/AppDelegate.swift
Detect if a Swift iOS app delegate is running unit tests
import UIKit
// Detect if the app is running unit tests.
// Note this only detects unit tests, not UI tests.
func isRunningUnitTests() -> Bool {
let env = NSProcessInfo.processInfo().environment
if let injectBundle = env["XCInjectBundle"] {
return NSString(string: injectBundle).pathExtension == "xctest"
}
return false
@dinneo
dinneo / TableViewController+Sort.swift
Created May 31, 2021 17:59 — forked from kayoslab/TableViewController+Sort.swift
Reorder UITableViewCells and modify the underlying CoreData Model
class TableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
navigationItem.rightBarButtonItem = editButtonItem
}
@dinneo
dinneo / SwiftUI_Ad_Interstitial.swift
Created April 29, 2021 08:58 — forked from MichaelBarney/SwiftUI_Ad_Interstitial.swift
A google AdMob Interstitial implementation in SwiftUI
import SwiftUI
import GoogleMobileAds
import UIKit
final class Interstitial:NSObject, GADInterstitialDelegate{
var interstitial:GADInterstitial = GADInterstitial(adUnitID: interstitialID)
override init() {
super.init()
LoadInterstitial()
@dinneo
dinneo / SwiftUI_Ad_Banner.swift
Created April 29, 2021 08:54 — forked from MichaelBarney/SwiftUI_Ad_Banner.swift
A google AdMob Banner implementation in SwiftUI
import SwiftUI
import GoogleMobileAds
import UIKit
final private class BannerVC: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
let view = GADBannerView(adSize: kGADAdSizeBanner)
let viewController = UIViewController()