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
| //Inspired by: http://merowing.info/2017/04/using-protocol-compositon-for-dependency-injection/ | |
| //Protocols for objects owning services. Interactors in VIPER, for example. | |
| protocol HasLogService { | |
| var logService: LogService { get } | |
| } | |
| protocol HasLoginService { | |
| var loginService: LoginService { 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
| // swift-tools-version:4.0 | |
| import PackageDescription | |
| let package = Package( | |
| name: "Sasha", | |
| dependencies: [ | |
| .package(url: "https://github.com/artemnovichkov/carting.git", from: "1.0.0"), | |
| ], | |
| targets: [ |
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
| func openAppStore() { | |
| let appID = 1227356223 | |
| let appURLString: String | |
| if #available(iOS 11.0, *) { | |
| appURLString = "itms-apps://itunes.apple.com/us/app/itunes-u/id\(appID)?action=write-review" | |
| } | |
| else { | |
| appURLString = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=\(appID)" | |
| } | |
| UIApplication.shared.openURL(URL(string: appURLString)!) |
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
| # CocoaPods | |
| swift_version = "4.0" | |
| pod "NextLevel", "~> 0.9.0" | |
| # Carthage | |
| github "nextlevel/NextLevel" ~> 0.9.0 | |
| # Swift PM | |
| let package = Package( | |
| dependencies: [ |
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
| func +=<T>(lhs: inout T?, rhs: T) where T: SignedNumeric { | |
| switch lhs { | |
| case .none: | |
| break | |
| case .some(let value): | |
| lhs = .some(value + rhs) | |
| } | |
| } | |
| func -=<T>(lhs: inout T?, rhs: T) where T: SignedNumeric { |
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 | |
| // Get project URL | |
| guard let projectDirRawValue = getenv("PROJECT_DIR"), | |
| let projectDirectoryPath = String(utf8String: projectDirRawValue) else { | |
| exit(1) | |
| } | |
| let projectURL = URL(fileURLWithPath: projectDirectoryPath) | |
| // Get Info.plist path | |
| guard let productSettingsPathRawValue = getenv("PRODUCT_SETTINGS_PATH"), |
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
| guard let enumerator = FileManager.default.enumerator(at: projectURL, includingPropertiesForKeys: nil) else { | |
| exit(1) | |
| } | |
| var swiftFileURLs = enumerator.allObjects | |
| .compactMap { $0 as? URL } | |
| .filter { $0.pathExtension == "swift" } |
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
| var keys: [String] = [] | |
| for url in swiftFileURLs { | |
| let contents = try String(contentsOf: url, encoding: .utf8) | |
| for (pattern, key) in patterns { | |
| if contents.contains(pattern) { | |
| keys.append(key) | |
| } | |
| } | |
| } |
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
| guard let productSettings = NSDictionary(contentsOfFile: productSettingsPath) else { | |
| exit(1) | |
| } | |
| for key in keys { | |
| guard let value = productSettings[key] as? String else { | |
| // Missing key | |
| exit(1) | |
| } | |
| if value.isEmpty { | |
| // Empty description |
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 | |
| // Get project URL | |
| guard let projectDirRawValue = getenv("PROJECT_DIR"), | |
| let projectDirectoryPath = String(utf8String: projectDirRawValue) else { | |
| exit(1) | |
| } | |
| let projectURL = URL(fileURLWithPath: projectDirectoryPath) | |
| // Get Info.plist path | |
| guard let productSettingsPathRawValue = getenv("PRODUCT_SETTINGS_PATH"), |