This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Endpoint: URLRequestConvertible { | |
case one | |
case two | |
case three | |
var baseUrl: String { | |
return "https://www.example.com" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension FileManager { | |
static var documentsDirectory: URL { | |
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) | |
return paths[0] | |
} | |
enum ObjectStorageError: Error { | |
case objectDoesNotExist | |
case objectHasWrongType | |
case couldNotEncodeObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ImageCache: NSCache<NSString, UIImage> { | |
static let shared = ImageCache() | |
subscript(key: String) -> UIImage? { | |
get { | |
return object(forKey: NSString(string: key)) | |
} | |
set { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIWindow { | |
func setRootViewController(_ viewController: UIViewController) { | |
DispatchQueue.main.async { | |
self.rootViewController = viewController | |
self.makeKeyAndVisible() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol URLRequestConvertible { | |
var baseUrl: String { get } | |
var path: String? { get } | |
var httpMethod: String { get } | |
var httpBody: Data? { get } | |
var allHTTPHeaderFields: [String: String] { get } | |
var url: URL? { get } | |
var urlRequest: URLRequest? { get } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func showViewController(withIdentifier identifier: String, storyboardName: String = "Main") { | |
DispatchQueue.main.async { | |
let storyboard = UIStoryboard(name: storyboardName, bundle: nil) | |
let viewController = storyboard.instantiateViewController(withIdentifier: identifier) | |
self.view.window?.setRootViewController(viewController) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/* Example Usage: | |
Get | |
---------------------------- | |
let token = Keychain[.token] | |
Set | |
---------------------------- | |
Keychain[.token] = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ipa -> "Path/to/app.ipa" | |
ipa=$1 | |
# provisioning_profile -> "Path/to/profile.mobileprovision" | |
provisioning_profile=$2 | |
# signing_identity -> Example: "iPhone Distribution: Team Name (ABCDEFGHIJK)" | |
signing_identity=$3 | |
# bundle_id -> Example: "com.org.app" | |
bundle_id=$4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# 1. Copy the script into a text editor and save it with no extension | |
# 2. Make it executable like so: chmod +x path/to/script | |
# 3. Run it from the Terminal in one of two ways: | |
# * path/to/script ipa_path="path/to/ipa" archive_path="path/to/xcarchive" | |
# * path/to/script ipa_path="path/to/ipa" toolchain_path="path/to/toolchain" |