Skip to content

Instantly share code, notes, and snippets.

View byaruhaf's full-sized avatar
🏄
Surfing Xcode

Franklin Byaruhanga byaruhaf

🏄
Surfing Xcode
View GitHub Profile
@byaruhaf
byaruhaf / WebViewWithActivityIndicator.swift
Created January 4, 2020 03:32 — forked from david-hosier/WebViewWithActivityIndicator.swift
Shows a ViewController that contains a WKWebView and UIActivityIndicatorView. This is a pruned down snippet from working code that may or may not work exactly as-is, but should give the basic idea of how to show/hide an activity indicator while a WKWebView is navigating to a URL. The original project this was adapted from was done in XCode 8, an…
import Foundation
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate, WKUIDelegate {
var webView: WKWebView!
var activityIndicator: UIActivityIndicatorView!
@IBOutlet var webViewContainer: UIView!
import Foundation
protocol JSONEncodable: Encodable { }
extension JSONEncodable {
func toJSON() throws -> String? {
try String(data: JSONEncoder().encode(self), encoding: .utf8)
}
}
@byaruhaf
byaruhaf / Demo.swift
Created February 11, 2020 12:20 — forked from AliSoftware/Demo.swift
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@byaruhaf
byaruhaf / Demo.swift
Created February 11, 2020 12:20 — forked from AliSoftware/Demo.swift
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {

DISABLING AUTOMATIC PASTEBOARD SYNC

defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false

EXTEND APP/TEST LAUNCH TIMEOUT

xcrun simctl spawn <device UUID> defaults write com.apple.springboard FBLaunchWatchdogScale 2

//: ## Demo
struct User: CustomStringConvertible {
let name: String
let age: Int
var description: String { "\(name) (\(age))" }
}
let users = [
User(name: "Bob", age: 22),
@byaruhaf
byaruhaf / Breakpoints_v2.xcbkptlist
Created March 5, 2020 01:47 — forked from Ashton-W/Breakpoints_v2.xcbkptlist
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
class Person {
var id: Int
var items: [String: Float]
init(id: Int, items: [String: Float]) {
self.id = id
self.items = items
}
}
@byaruhaf
byaruhaf / RemoveATSExceptions.sh
Created June 30, 2020 02:35 — forked from Ashton-W/RemoveATSExceptions.sh
Xcode Build Phase Script to remove NSAppTransportSecurity from the Info.plist based on the custom REMOVE_ATS_EXCEPTIONS build setting.
#!/usr/bin/env bash
# Build Phase Script for removing NSAppTransportSecurity exceptions from Info.plist
# https://gist.github.com/Ashton-W/07654259322e43a2b6a50bb289e72627
set -o errexit
set -o nounset
if [[ -z "${REMOVE_ATS_EXCEPTIONS+SET}" ]]; then
echo "error: User Defined Build Setting REMOVE_ATS_EXCEPTIONS must be set"
exit 1
@byaruhaf
byaruhaf / SubscriptedTextView
Created July 18, 2020 07:01
A SwiftUI View used to display strings with subscripted text
import SwiftUI
struct SubscriptedTextView: View {
// MARK: Properties
let abbreviation: String
var body: some View {
subscriptedText()