├── .gitignore ├── .travis.yml ├── Example ├── MLKit.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── MLKit-Example.xcscheme ├── MLKit.xcworkspace │ └── contents.xcworkspacedata ├── MLKit │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── GameScene.sks │ ├── GameScene.swift │ ├── GameViewController.swift │ ├── GeneticOperations.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── PipeDown.imageset │ │ │ ├── Contents.json │ │ │ └── PipeDown.png │ │ ├── PipeUp.imageset │ │ │ ├── Contents.json │ │ │ └── PipeUp.png │ │ ├── land.imageset │ │ │ ├── Contents.json │ │ │ └── land.png │ │ ├── scoreboard.imageset │ │ │ ├── Contents.json │ │ │ └── scoreboard.png │ │ └── sky.imageset │ │ │ ├── Contents.json │ │ │ └── sky.png │ ├── Info.plist │ └── bird.atlas │ │ ├── bird-01.png │ │ ├── bird-02.png │ │ ├── bird-03.png │ │ └── bird-04.png ├── Podfile ├── Podfile.lock ├── Pods │ ├── Local Podspecs │ │ ├── MLKit.podspec.json │ │ └── MachineLearningKit.podspec.json │ ├── Manifest.lock │ ├── Nimble │ │ ├── LICENSE │ │ ├── README.md │ │ └── Sources │ │ │ ├── Lib │ │ │ └── CwlPreconditionTesting │ │ │ │ ├── CwlCatchException │ │ │ │ └── CwlCatchException │ │ │ │ │ ├── CwlCatchException.h │ │ │ │ │ ├── CwlCatchException.m │ │ │ │ │ └── CwlCatchException.swift │ │ │ │ └── CwlPreconditionTesting │ │ │ │ ├── CwlBadInstructionException.swift │ │ │ │ ├── CwlCatchBadInstruction.h │ │ │ │ ├── CwlCatchBadInstruction.m │ │ │ │ ├── CwlCatchBadInstruction.swift │ │ │ │ ├── CwlDarwinDefinitions.swift │ │ │ │ ├── mach_excServer.c │ │ │ │ └── mach_excServer.h │ │ │ ├── Nimble │ │ │ ├── Adapters │ │ │ │ ├── AdapterProtocols.swift │ │ │ │ ├── AssertionDispatcher.swift │ │ │ │ ├── AssertionRecorder.swift │ │ │ │ ├── NMBExpectation.swift │ │ │ │ ├── NMBObjCMatcher.swift │ │ │ │ ├── NimbleEnvironment.swift │ │ │ │ └── NimbleXCTestHandler.swift │ │ │ ├── DSL+Wait.swift │ │ │ ├── DSL.swift │ │ │ ├── Expectation.swift │ │ │ ├── Expression.swift │ │ │ ├── FailureMessage.swift │ │ │ ├── Matchers │ │ │ │ ├── AllPass.swift │ │ │ │ ├── AsyncMatcherWrapper.swift │ │ │ │ ├── BeAKindOf.swift │ │ │ │ ├── BeAnInstanceOf.swift │ │ │ │ ├── BeCloseTo.swift │ │ │ │ ├── BeEmpty.swift │ │ │ │ ├── BeGreaterThan.swift │ │ │ │ ├── BeGreaterThanOrEqualTo.swift │ │ │ │ ├── BeIdenticalTo.swift │ │ │ │ ├── BeLessThan.swift │ │ │ │ ├── BeLessThanOrEqual.swift │ │ │ │ ├── BeLogical.swift │ │ │ │ ├── BeNil.swift │ │ │ │ ├── BeVoid.swift │ │ │ │ ├── BeginWith.swift │ │ │ │ ├── Contain.swift │ │ │ │ ├── ContainElementSatisfying.swift │ │ │ │ ├── EndWith.swift │ │ │ │ ├── Equal.swift │ │ │ │ ├── HaveCount.swift │ │ │ │ ├── Match.swift │ │ │ │ ├── MatchError.swift │ │ │ │ ├── MatcherFunc.swift │ │ │ │ ├── MatcherProtocols.swift │ │ │ │ ├── PostNotification.swift │ │ │ │ ├── RaisesException.swift │ │ │ │ ├── SatisfyAnyOf.swift │ │ │ │ ├── ThrowAssertion.swift │ │ │ │ └── ThrowError.swift │ │ │ ├── Nimble.h │ │ │ └── Utils │ │ │ │ ├── Async.swift │ │ │ │ ├── Errors.swift │ │ │ │ ├── Functional.swift │ │ │ │ ├── SourceLocation.swift │ │ │ │ └── Stringers.swift │ │ │ └── NimbleObjectiveC │ │ │ ├── CurrentTestCaseTracker.h │ │ │ ├── DSL.h │ │ │ ├── DSL.m │ │ │ ├── NMBExceptionCapture.h │ │ │ ├── NMBExceptionCapture.m │ │ │ ├── NMBStringify.h │ │ │ ├── NMBStringify.m │ │ │ └── XCTestObservationCenter+Register.m │ ├── Pods.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── Quick │ │ ├── LICENSE │ │ ├── README.md │ │ └── Sources │ │ │ ├── Quick │ │ │ ├── Callsite.swift │ │ │ ├── Configuration │ │ │ │ └── Configuration.swift │ │ │ ├── DSL │ │ │ │ ├── DSL.swift │ │ │ │ └── World+DSL.swift │ │ │ ├── ErrorUtility.swift │ │ │ ├── Example.swift │ │ │ ├── ExampleGroup.swift │ │ │ ├── ExampleMetadata.swift │ │ │ ├── Filter.swift │ │ │ ├── Hooks │ │ │ │ ├── Closures.swift │ │ │ │ ├── ExampleHooks.swift │ │ │ │ ├── HooksPhase.swift │ │ │ │ └── SuiteHooks.swift │ │ │ ├── NSBundle+CurrentTestBundle.swift │ │ │ ├── NSString+C99ExtendedIdentifier.swift │ │ │ ├── QuickSelectedTestSuiteBuilder.swift │ │ │ ├── QuickTestSuite.swift │ │ │ ├── URL+FileName.swift │ │ │ └── World.swift │ │ │ ├── QuickObjectiveC │ │ │ ├── Configuration │ │ │ │ ├── QuickConfiguration.h │ │ │ │ └── QuickConfiguration.m │ │ │ ├── DSL │ │ │ │ ├── QCKDSL.h │ │ │ │ ├── QCKDSL.m │ │ │ │ └── World+DSL.h │ │ │ ├── Quick.h │ │ │ ├── QuickSpec.h │ │ │ ├── QuickSpec.m │ │ │ ├── World.h │ │ │ └── XCTestSuite+QuickTestSuiteBuilder.m │ │ │ └── QuickSpecBase │ │ │ ├── QuickSpecBase.m │ │ │ └── include │ │ │ └── QuickSpecBase.h │ ├── Target Support Files │ │ ├── MachineLearningKit │ │ │ ├── Info.plist │ │ │ ├── MachineLearningKit-dummy.m │ │ │ ├── MachineLearningKit-prefix.pch │ │ │ ├── MachineLearningKit-umbrella.h │ │ │ ├── MachineLearningKit.modulemap │ │ │ └── MachineLearningKit.xcconfig │ │ ├── Nimble │ │ │ ├── Info.plist │ │ │ ├── Nimble-dummy.m │ │ │ ├── Nimble-prefix.pch │ │ │ ├── Nimble-umbrella.h │ │ │ ├── Nimble.modulemap │ │ │ └── Nimble.xcconfig │ │ ├── Pods-MLKit_Example │ │ │ ├── Info.plist │ │ │ ├── Pods-MLKit_Example-acknowledgements.markdown │ │ │ ├── Pods-MLKit_Example-acknowledgements.plist │ │ │ ├── Pods-MLKit_Example-dummy.m │ │ │ ├── Pods-MLKit_Example-frameworks.sh │ │ │ ├── Pods-MLKit_Example-resources.sh │ │ │ ├── Pods-MLKit_Example-umbrella.h │ │ │ ├── Pods-MLKit_Example.debug.xcconfig │ │ │ ├── Pods-MLKit_Example.modulemap │ │ │ └── Pods-MLKit_Example.release.xcconfig │ │ ├── Pods-MLKit_Tests │ │ │ ├── Info.plist │ │ │ ├── Pods-MLKit_Tests-acknowledgements.markdown │ │ │ ├── Pods-MLKit_Tests-acknowledgements.plist │ │ │ ├── Pods-MLKit_Tests-dummy.m │ │ │ ├── Pods-MLKit_Tests-frameworks.sh │ │ │ ├── Pods-MLKit_Tests-resources.sh │ │ │ ├── Pods-MLKit_Tests-umbrella.h │ │ │ ├── Pods-MLKit_Tests.debug.xcconfig │ │ │ ├── Pods-MLKit_Tests.modulemap │ │ │ └── Pods-MLKit_Tests.release.xcconfig │ │ ├── Quick │ │ │ ├── Info.plist │ │ │ ├── Quick-dummy.m │ │ │ ├── Quick-prefix.pch │ │ │ ├── Quick-umbrella.h │ │ │ ├── Quick.modulemap │ │ │ └── Quick.xcconfig │ │ └── Upsurge │ │ │ ├── Info.plist │ │ │ ├── Upsurge-dummy.m │ │ │ ├── Upsurge-prefix.pch │ │ │ ├── Upsurge-umbrella.h │ │ │ ├── Upsurge.modulemap │ │ │ └── Upsurge.xcconfig │ └── Upsurge │ │ ├── LICENSE │ │ ├── README.md │ │ └── Source │ │ ├── 1D │ │ ├── LinearOperators.swift │ │ ├── LinearType.swift │ │ ├── ValueArray.swift │ │ └── ValueArraySlice.swift │ │ ├── 2D │ │ ├── 2DTensorSlice.swift │ │ ├── Matrix.swift │ │ ├── MatrixArithmetic.swift │ │ ├── MatrixSlice.swift │ │ └── QuadraticType.swift │ │ ├── Complex │ │ ├── Complex.swift │ │ ├── ComplexArithmetic.swift │ │ ├── ComplexArray.swift │ │ ├── ComplexArrayRealSlice.swift │ │ └── ComplexArraySlice.swift │ │ ├── DSP │ │ ├── DSP.swift │ │ └── FFT.swift │ │ ├── ND │ │ ├── Span.swift │ │ ├── Tensor.swift │ │ ├── TensorSlice.swift │ │ └── TensorType.swift │ │ ├── Operations │ │ ├── Arithmetic.swift │ │ ├── Auxiliary.swift │ │ ├── Exponential.swift │ │ ├── Hyperbolic.swift │ │ ├── PointerUtilities.swift │ │ └── Trigonometric.swift │ │ └── Types │ │ ├── Interval.swift │ │ ├── Real.swift │ │ └── Value.swift └── Tests │ ├── CSVReader.swift │ ├── GeneticSpec.swift │ ├── Info.plist │ ├── LassoRegressionSpec.swift │ ├── MLDataManagerSpec.swift │ ├── NeuralNetworkSpec.swift │ ├── PolynomialRegressionSpec.swift │ ├── RidgeRegressionSpec.swift │ ├── SimpleLinearRegressionSpec.swift │ └── kc_house_data.csv ├── LICENSE ├── MLKit-PlayGround.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ └── contents.xcworkspacedata └── timeline.xctimeline ├── MLKit ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── ANN │ ├── ActivationFunctionType.swift │ ├── InputDataType.swift │ ├── Layer.swift │ └── NeuralNetwork.swift │ ├── CSVReader.swift │ ├── Genetic Algorithms │ ├── BiologicalProcessManager.swift │ ├── Genome.swift │ └── Population.swift │ ├── Helper Classes & Extensions │ ├── DataManager.swift │ ├── Extensions.swift │ └── MachineLeanringErrorEnum.swift │ ├── K Means Clustering │ └── KMeans.swift │ ├── MLKit.h │ └── Regression │ ├── LassoRegression.swift │ ├── PolynomialRegression.swift │ ├── RidgeRegression.swift │ └── SimpleLinearRegression.swift ├── MLKitLogo2.png ├── MLKitSmallerLogo.png ├── MachineLearningKit.podspec ├── README.md ├── _Pods.xcodeproj └── flappybirdai.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | Carthage 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | # Note: if you ignore the Pods directory, make sure to uncomment 31 | # `pod install` in .travis.yml 32 | # 33 | # Pods/ 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -workspace Example/MLKit.xcworkspace -scheme MLKit-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/MLKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/MLKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/MLKit/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MLKit 4 | // 5 | // Created by Guled Ahmed on 02/20/2017. 6 | // Copyright (c) 2017 Guled Ahmed. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | func applicationWillResignActive(_ application: UIApplication) { 22 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 23 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 24 | } 25 | 26 | func applicationDidEnterBackground(_ application: UIApplication) { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | func applicationWillEnterForeground(_ application: UIApplication) { 32 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 33 | } 34 | 35 | func applicationDidBecomeActive(_ application: UIApplication) { 36 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 37 | } 38 | 39 | func applicationWillTerminate(_ application: UIApplication) { 40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Example/MLKit/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Example/MLKit/GameScene.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/GameScene.sks -------------------------------------------------------------------------------- /Example/MLKit/GeneticOperations.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GeneticOperations.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/7/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import MachineLearningKit 11 | import Upsurge 12 | 13 | /// The GeneticOperations class manages encoding genes into weights for the neural network and decoding neural network weights into genes. These methods are not provided in the framework itself, rather it was for the game example. 14 | 15 | final class GeneticOperations { 16 | /** 17 | The encode method converts a NueralNetwork object to an array of floats by taking the weights of each layer and placing them into an array. 18 | 19 | - parameter network: A NeuralNet Object. 20 | 21 | - returns: An array of Float values. 22 | */ 23 | public static func encode(network: NeuralNetwork) -> [Float] { 24 | 25 | var genotypeRepresentation: [Float] = [] 26 | 27 | for layer in network.layers { 28 | 29 | genotypeRepresentation += Array(layer.weights!.elements) 30 | } 31 | 32 | for layer in network.layers { 33 | genotypeRepresentation += Array(layer.bias!.elements) 34 | } 35 | 36 | return genotypeRepresentation 37 | } 38 | 39 | /** 40 | The decode method converts a genotype back to a NeuralNet object by taking each value from the genotype and mapping them to a neuron in a particular layer. 41 | 42 | - parameter network: A NeuralNet Object. 43 | 44 | - returns: An array of Float values. 45 | */ 46 | public static func decode(genotype: [Float]) -> NeuralNetwork { 47 | 48 | // Create a new NueralNet 49 | let brain = NeuralNetwork(size: (6, 1)) 50 | brain.addLayer(layer: Layer(size: (6, 12), activationType: .siglog)) 51 | brain.addLayer(layer: Layer(size: (12, 1), activationType: .siglog)) 52 | 53 | brain.layers[0].weights = Matrix(rows: 12, columns: 6, elements: ValueArray(Array(genotype[0...71]))) 54 | brain.layers[0].bias = Matrix(rows: 12, columns: 1, elements: ValueArray(Array(genotype[72...83]))) 55 | brain.layers[1].weights = Matrix(rows: 1, columns: 12, elements: ValueArray(Array(genotype[84...95]))) 56 | brain.layers[1].bias = Matrix(rows: 1, columns: 1, elements: ValueArray([genotype[96]])) 57 | 58 | return brain 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/PipeDown.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "PipeDown.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/PipeDown.imageset/PipeDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/Images.xcassets/PipeDown.imageset/PipeDown.png -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/PipeUp.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "PipeUp.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/PipeUp.imageset/PipeUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/Images.xcassets/PipeUp.imageset/PipeUp.png -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/land.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "land.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/land.imageset/land.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/Images.xcassets/land.imageset/land.png -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/scoreboard.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "scoreboard.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/scoreboard.imageset/scoreboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/Images.xcassets/scoreboard.imageset/scoreboard.png -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/sky.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sky.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/MLKit/Images.xcassets/sky.imageset/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/Images.xcassets/sky.imageset/sky.png -------------------------------------------------------------------------------- /Example/MLKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/MLKit/bird.atlas/bird-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/bird.atlas/bird-01.png -------------------------------------------------------------------------------- /Example/MLKit/bird.atlas/bird-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/bird.atlas/bird-02.png -------------------------------------------------------------------------------- /Example/MLKit/bird.atlas/bird-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/bird.atlas/bird-03.png -------------------------------------------------------------------------------- /Example/MLKit/bird.atlas/bird-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/Example/MLKit/bird.atlas/bird-04.png -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'MLKit_Example' do 4 | pod 'MachineLearningKit', :path => '../' 5 | pod 'Upsurge' 6 | 7 | target 'MLKit_Tests' do 8 | inherit! :search_paths 9 | pod 'Quick' 10 | pod 'Nimble' 11 | end 12 | 13 | post_install do |installer| 14 | installer.pods_project.targets.each do |target| 15 | target.build_configurations.each do |config| 16 | config.build_settings['SWIFT_VERSION'] = '3.0' 17 | end 18 | end 19 | end 20 | 21 | end 22 | 23 | 24 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MachineLearningKit (0.1.7): 3 | - Upsurge 4 | - Nimble (6.0.1) 5 | - Quick (1.1.0) 6 | - Upsurge (0.8.0) 7 | 8 | DEPENDENCIES: 9 | - MachineLearningKit (from `../`) 10 | - Nimble 11 | - Quick 12 | - Upsurge 13 | 14 | EXTERNAL SOURCES: 15 | MachineLearningKit: 16 | :path: ../ 17 | 18 | SPEC CHECKSUMS: 19 | MachineLearningKit: 040457b6d6afce606454c16008b954f3952a0d32 20 | Nimble: 1527fd1bd2b4cf0636251a36bc8ab37e81da8347 21 | Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d 22 | Upsurge: 614412863a3b5470b31636a004654b6ef3a34f47 23 | 24 | PODFILE CHECKSUM: 6efa57e13fa4fabb331b61a3a84a43c047bb3113 25 | 26 | COCOAPODS: 1.2.0 27 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/MLKit.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MLKit", 3 | "version": "0.1.0", 4 | "summary": "A simple machine learning framework written in Swift 🤖", 5 | "description": "MLKit is a simple machine learning framework written in Swift. Currently MLKit features machine learning algorithms that deal with the topic of regression, but the framework will expand over time with topics such as classification, clustering, recommender systems, and deep learning. The vision and goal of this framework is to provide developers with a toolkit to create products that can learn from data. MLKit is a side project of mine in order to make it easier for developers to implement machine learning algorithms on the go, and to familiarlize myself with machine learning concepts.", 6 | "homepage": "https://github.com/Somnibyte/MLKit", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "Guled Ahmed": "guledahmed777@gmail.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/Somnibyte/MLKit.git", 16 | "tag": "0.1.0" 17 | }, 18 | "platforms": { 19 | "ios": "9.0", 20 | "watchos": "3.1", 21 | "tvos": "10.1" 22 | }, 23 | "source_files": "MLKit/Classes/**/*", 24 | "frameworks": [ 25 | "UIKit", 26 | "MapKit" 27 | ], 28 | "dependencies": { 29 | "Upsurge": [ 30 | 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/MachineLearningKit.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MachineLearningKit", 3 | "version": "0.1.7", 4 | "summary": "A simple machine learning framework written in Swift 🤖", 5 | "description": "MLKit is a simple machine learning framework written in Swift. Currently MLKit features machine learning algorithms that deal with the topic of regression, but the framework will expand over time with topics such as classification, clustering, recommender systems, and deep learning. The vision and goal of this framework is to provide developers with a toolkit to create products that can learn from data. MLKit is a side project of mine in order to make it easier for developers to implement machine learning algorithms on the go, and to familiarlize myself with machine learning concepts.", 6 | "homepage": "https://github.com/Somnibyte/MLKit", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "Guled Ahmed": "guledahmed777@gmail.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/Somnibyte/MLKit.git", 16 | "tag": "0.1.7" 17 | }, 18 | "platforms": { 19 | "ios": "9.0", 20 | "tvos": "10.1" 21 | }, 22 | "source_files": "MLKit/Classes/**/*", 23 | "frameworks": [ 24 | "UIKit", 25 | "MapKit" 26 | ], 27 | "dependencies": { 28 | "Upsurge": [ 29 | 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MachineLearningKit (0.1.7): 3 | - Upsurge 4 | - Nimble (6.0.1) 5 | - Quick (1.1.0) 6 | - Upsurge (0.8.0) 7 | 8 | DEPENDENCIES: 9 | - MachineLearningKit (from `../`) 10 | - Nimble 11 | - Quick 12 | - Upsurge 13 | 14 | EXTERNAL SOURCES: 15 | MachineLearningKit: 16 | :path: ../ 17 | 18 | SPEC CHECKSUMS: 19 | MachineLearningKit: 040457b6d6afce606454c16008b954f3952a0d32 20 | Nimble: 1527fd1bd2b4cf0636251a36bc8ab37e81da8347 21 | Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d 22 | Upsurge: 614412863a3b5470b31636a004654b6ef3a34f47 23 | 24 | PODFILE CHECKSUM: 6efa57e13fa4fabb331b61a3a84a43c047bb3113 25 | 26 | COCOAPODS: 1.2.0 27 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.h 3 | // CwlCatchException 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | //! Project version number for CwlCatchException. 24 | FOUNDATION_EXPORT double CwlCatchExceptionVersionNumber; 25 | 26 | //! Project version string for CwlCatchException. 27 | FOUNDATION_EXPORT const unsigned char CwlCatchExceptionVersionString[]; 28 | 29 | __attribute__((visibility("hidden"))) 30 | NSException* __nullable catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()); 31 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.m 3 | // CwlAssertionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import "CwlCatchException.h" 22 | 23 | __attribute__((visibility("hidden"))) 24 | NSException* catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()) { 25 | @try { 26 | inBlock(); 27 | } @catch (NSException *exception) { 28 | if ([exception isKindOfClass:type]) { 29 | return exception; 30 | } else { 31 | @throw; 32 | } 33 | } 34 | return nil; 35 | } 36 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.swift 3 | // CwlAssertionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Foundation 22 | 23 | // We can't simply cast to Self? in the catchInBlock method so we need this generic function wrapper to do the conversion for us. Mildly annoying. 24 | private func catchReturnTypeConverter(_ type: T.Type, block: () -> Void) -> T? { 25 | return catchExceptionOfKind(type, block) as? T 26 | } 27 | 28 | extension NSException { 29 | public static func catchException(in block: () -> Void) -> Self? { 30 | return catchReturnTypeConverter(self, block: block) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlBadInstructionException.swift 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Foundation 22 | 23 | private func raiseBadInstructionException() { 24 | BadInstructionException().raise() 25 | } 26 | 27 | /// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type. 28 | @objc public class BadInstructionException: NSException { 29 | static var name: String = "com.cocoawithlove.BadInstruction" 30 | 31 | init() { 32 | super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) 33 | } 34 | 35 | required public init?(coder aDecoder: NSCoder) { 36 | super.init(coder: aDecoder) 37 | } 38 | 39 | /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack. 40 | public class func catch_mach_exception_raise_state(_ exception_port: mach_port_t, exception: exception_type_t, code: UnsafePointer, codeCnt: mach_msg_type_number_t, flavor: UnsafeMutablePointer, old_state: UnsafePointer, old_stateCnt: mach_msg_type_number_t, new_state: thread_state_t, new_stateCnt: UnsafeMutablePointer) -> kern_return_t { 41 | 42 | #if arch(x86_64) 43 | // Make sure we've been given enough memory 44 | if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT { 45 | return KERN_INVALID_ARGUMENT 46 | } 47 | 48 | // Read the old thread state 49 | var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee } 50 | 51 | // 1. Decrement the stack pointer 52 | state.__rsp -= __uint64_t(MemoryLayout.size) 53 | 54 | // 2. Save the old Instruction Pointer to the stack. 55 | if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) { 56 | pointer.pointee = state.__rip 57 | } else { 58 | return KERN_INVALID_ARGUMENT 59 | } 60 | 61 | // 3. Set the Instruction Pointer to the new function's address 62 | var f: @convention(c) () -> Void = raiseBadInstructionException 63 | withUnsafePointer(to: &f) { 64 | state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee } 65 | } 66 | 67 | // Write the new thread state 68 | new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state } 69 | new_stateCnt.pointee = x86_THREAD_STATE64_COUNT 70 | 71 | return KERN_SUCCESS 72 | #else 73 | fatalError("Unavailable for this CPU architecture") 74 | #endif 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchBadInstruction.h 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #if defined(__x86_64__) 22 | 23 | #import 24 | #import 25 | 26 | NS_ASSUME_NONNULL_BEGIN 27 | 28 | // The request_mach_exception_raise_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. 29 | typedef struct 30 | { 31 | mach_msg_header_t Head; 32 | /* start of the kernel processed data */ 33 | mach_msg_body_t msgh_body; 34 | mach_msg_port_descriptor_t thread; 35 | mach_msg_port_descriptor_t task; 36 | /* end of the kernel processed data */ 37 | NDR_record_t NDR; 38 | exception_type_t exception; 39 | mach_msg_type_number_t codeCnt; 40 | int64_t code[2]; 41 | int flavor; 42 | mach_msg_type_number_t old_stateCnt; 43 | natural_t old_state[224]; 44 | } request_mach_exception_raise_t; 45 | 46 | // The reply_mach_exception_raise_state_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. 47 | typedef struct 48 | { 49 | mach_msg_header_t Head; 50 | NDR_record_t NDR; 51 | kern_return_t RetCode; 52 | int flavor; 53 | mach_msg_type_number_t new_stateCnt; 54 | natural_t new_state[224]; 55 | } reply_mach_exception_raise_state_t; 56 | 57 | extern boolean_t mach_exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); 58 | 59 | NS_ASSUME_NONNULL_END 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchBadInstruction.m 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #if defined(__x86_64__) 22 | 23 | #import "CwlCatchBadInstruction.h" 24 | 25 | // Assuming the "PRODUCT_NAME" macro is defined, this will create the name of the Swift generated header file 26 | #define STRINGIZE_NO_EXPANSION(A) #A 27 | #define STRINGIZE_WITH_EXPANSION(A) STRINGIZE_NO_EXPANSION(A) 28 | #define SWIFT_INCLUDE STRINGIZE_WITH_EXPANSION(PRODUCT_NAME-Swift.h) 29 | 30 | // Include the Swift generated header file 31 | #import SWIFT_INCLUDE 32 | 33 | /// A basic function that receives callbacks from mach_exc_server and relays them to the Swift implemented BadInstructionException.catch_mach_exception_raise_state. 34 | kern_return_t catch_mach_exception_raise_state(mach_port_t exception_port, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { 35 | return [BadInstructionException catch_mach_exception_raise_state:exception_port exception:exception code:code codeCnt:codeCnt flavor:flavor old_state:old_state old_stateCnt:old_stateCnt new_state:new_state new_stateCnt:new_stateCnt]; 36 | } 37 | 38 | // The mach port should be configured so that this function is never used. 39 | kern_return_t catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) { 40 | assert(false); 41 | return KERN_FAILURE; 42 | } 43 | 44 | // The mach port should be configured so that this function is never used. 45 | kern_return_t catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { 46 | assert(false); 47 | return KERN_FAILURE; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlDarwinDefinitions.swift 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Darwin 22 | 23 | #if arch(x86_64) 24 | 25 | // From /usr/include/mach/port.h 26 | // #define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) 27 | let MACH_PORT_RIGHT_RECEIVE: mach_port_right_t = 1 28 | 29 | // From /usr/include/mach/message.h 30 | // #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ 31 | // #define MACH_MSGH_BITS_REMOTE(bits) \ 32 | // ((bits) & MACH_MSGH_BITS_REMOTE_MASK) 33 | // #define MACH_MSGH_BITS(remote, local) /* legacy */ \ 34 | // ((remote) | ((local) << 8)) 35 | let MACH_MSG_TYPE_MAKE_SEND: UInt32 = 20 36 | func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32 { return bits & UInt32(MACH_MSGH_BITS_REMOTE_MASK) } 37 | func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32 { return ((remote) | ((local) << 8)) } 38 | 39 | // From /usr/include/mach/exception_types.h 40 | // #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ 41 | // #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) 42 | // #define EXCEPTION_DEFAULT 1 43 | let EXC_BAD_INSTRUCTION: UInt32 = 2 44 | let EXC_MASK_BAD_INSTRUCTION: UInt32 = 1 << EXC_BAD_INSTRUCTION 45 | let EXCEPTION_DEFAULT: Int32 = 1 46 | 47 | // From /usr/include/mach/i386/thread_status.h 48 | // #define THREAD_STATE_NONE 13 49 | // #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ 50 | // ( sizeof (x86_thread_state64_t) / sizeof (int) )) 51 | let THREAD_STATE_NONE: Int32 = 13 52 | let x86_THREAD_STATE64_COUNT = UInt32(MemoryLayout.size / MemoryLayout.size) 53 | 54 | let EXC_TYPES_COUNT = 14 55 | struct execTypesCountTuple { 56 | // From /usr/include/mach/i386/exception.h 57 | // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ 58 | var value: (T, T, T, T, T, T, T, T, T, T, T, T, T, T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 59 | init() { 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/AdapterProtocols.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Protocol for the assertion handler that Nimble uses for all expectations. 4 | public protocol AssertionHandler { 5 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) 6 | } 7 | 8 | /// Global backing interface for assertions that Nimble creates. 9 | /// Defaults to a private test handler that passes through to XCTest. 10 | /// 11 | /// If XCTest is not available, you must assign your own assertion handler 12 | /// before using any matchers, otherwise Nimble will abort the program. 13 | /// 14 | /// @see AssertionHandler 15 | public var NimbleAssertionHandler: AssertionHandler = { () -> AssertionHandler in 16 | return isXCTestAvailable() ? NimbleXCTestHandler() : NimbleXCTestUnavailableHandler() 17 | }() 18 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift: -------------------------------------------------------------------------------- 1 | /// AssertionDispatcher allows multiple AssertionHandlers to receive 2 | /// assertion messages. 3 | /// 4 | /// @warning Does not fully dispatch if one of the handlers raises an exception. 5 | /// This is possible with XCTest-based assertion handlers. 6 | /// 7 | public class AssertionDispatcher: AssertionHandler { 8 | let handlers: [AssertionHandler] 9 | 10 | public init(handlers: [AssertionHandler]) { 11 | self.handlers = handlers 12 | } 13 | 14 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 15 | for handler in handlers { 16 | handler.assert(assertion, message: message, location: location) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) -> Bool 6 | public typealias FullMatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) -> Bool 7 | 8 | public class NMBObjCMatcher: NSObject, NMBMatcher { 9 | let _match: MatcherBlock 10 | let _doesNotMatch: MatcherBlock 11 | let canMatchNil: Bool 12 | 13 | public init(canMatchNil: Bool, matcher: @escaping MatcherBlock, notMatcher: @escaping MatcherBlock) { 14 | self.canMatchNil = canMatchNil 15 | self._match = matcher 16 | self._doesNotMatch = notMatcher 17 | } 18 | 19 | public convenience init(matcher: @escaping MatcherBlock) { 20 | self.init(canMatchNil: true, matcher: matcher) 21 | } 22 | 23 | public convenience init(canMatchNil: Bool, matcher: @escaping MatcherBlock) { 24 | self.init(canMatchNil: canMatchNil, matcher: matcher, notMatcher: ({ actualExpression, failureMessage in 25 | return !matcher(actualExpression, failureMessage) 26 | })) 27 | } 28 | 29 | public convenience init(matcher: @escaping FullMatcherBlock) { 30 | self.init(canMatchNil: true, matcher: matcher) 31 | } 32 | 33 | public convenience init(canMatchNil: Bool, matcher: @escaping FullMatcherBlock) { 34 | self.init(canMatchNil: canMatchNil, matcher: ({ actualExpression, failureMessage in 35 | return matcher(actualExpression, failureMessage, false) 36 | }), notMatcher: ({ actualExpression, failureMessage in 37 | return matcher(actualExpression, failureMessage, true) 38 | })) 39 | } 40 | 41 | private func canMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 42 | do { 43 | if !canMatchNil { 44 | if try actualExpression.evaluate() == nil { 45 | failureMessage.postfixActual = " (use beNil() to match nils)" 46 | return false 47 | } 48 | } 49 | } catch let error { 50 | failureMessage.actualValue = "an unexpected error thrown: \(error)" 51 | return false 52 | } 53 | return true 54 | } 55 | 56 | public func matches(_ actualBlock: @escaping () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 57 | let expr = Expression(expression: actualBlock, location: location) 58 | let result = _match( 59 | expr, 60 | failureMessage) 61 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 62 | return result 63 | } else { 64 | return false 65 | } 66 | } 67 | 68 | public func doesNotMatch(_ actualBlock: @escaping () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 69 | let expr = Expression(expression: actualBlock, location: location) 70 | let result = _doesNotMatch( 71 | expr, 72 | failureMessage) 73 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 74 | return result 75 | } else { 76 | return false 77 | } 78 | } 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift: -------------------------------------------------------------------------------- 1 | import Dispatch 2 | import Foundation 3 | 4 | /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this 5 | /// class' existance 6 | internal class NimbleEnvironment { 7 | static var activeInstance: NimbleEnvironment { 8 | get { 9 | let env = Thread.current.threadDictionary["NimbleEnvironment"] 10 | if let env = env as? NimbleEnvironment { 11 | return env 12 | } else { 13 | let newEnv = NimbleEnvironment() 14 | self.activeInstance = newEnv 15 | return newEnv 16 | } 17 | } 18 | set { 19 | Thread.current.threadDictionary["NimbleEnvironment"] = newValue 20 | } 21 | } 22 | 23 | // TODO: eventually migrate the global to this environment value 24 | var assertionHandler: AssertionHandler { 25 | get { return NimbleAssertionHandler } 26 | set { NimbleAssertionHandler = newValue } 27 | } 28 | 29 | var suppressTVOSAssertionWarning: Bool = false 30 | var awaiter: Awaiter 31 | 32 | init() { 33 | let timeoutQueue: DispatchQueue 34 | if #available(OSX 10.10, *) { 35 | timeoutQueue = DispatchQueue.global(qos: .userInitiated) 36 | } else { 37 | timeoutQueue = DispatchQueue.global(priority: .high) 38 | } 39 | 40 | awaiter = Awaiter( 41 | waitLock: AssertionWaitLock(), 42 | asyncQueue: .main, 43 | timeoutQueue: timeoutQueue) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import XCTest 3 | 4 | /// Default handler for Nimble. This assertion handler passes failures along to 5 | /// XCTest. 6 | public class NimbleXCTestHandler: AssertionHandler { 7 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 8 | if !assertion { 9 | recordFailure("\(message.stringValue)\n", location: location) 10 | } 11 | } 12 | } 13 | 14 | /// Alternative handler for Nimble. This assertion handler passes failures along 15 | /// to XCTest by attempting to reduce the failure message size. 16 | public class NimbleShortXCTestHandler: AssertionHandler { 17 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 18 | if !assertion { 19 | let msg: String 20 | if let actual = message.actualValue { 21 | msg = "got: \(actual) \(message.postfixActual)" 22 | } else { 23 | msg = "expected \(message.to) \(message.postfixMessage)" 24 | } 25 | recordFailure("\(msg)\n", location: location) 26 | } 27 | } 28 | } 29 | 30 | /// Fallback handler in case XCTest is unavailable. This assertion handler will abort 31 | /// the program if it is invoked. 32 | class NimbleXCTestUnavailableHandler: AssertionHandler { 33 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 34 | fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.") 35 | } 36 | } 37 | 38 | #if !SWIFT_PACKAGE 39 | /// Helper class providing access to the currently executing XCTestCase instance, if any 40 | @objc final internal class CurrentTestCaseTracker: NSObject, XCTestObservation { 41 | @objc static let sharedInstance = CurrentTestCaseTracker() 42 | 43 | private(set) var currentTestCase: XCTestCase? 44 | 45 | @objc func testCaseWillStart(_ testCase: XCTestCase) { 46 | currentTestCase = testCase 47 | } 48 | 49 | @objc func testCaseDidFinish(_ testCase: XCTestCase) { 50 | currentTestCase = nil 51 | } 52 | } 53 | #endif 54 | 55 | func isXCTestAvailable() -> Bool { 56 | #if _runtime(_ObjC) 57 | // XCTest is weakly linked and so may not be present 58 | return NSClassFromString("XCTestCase") != nil 59 | #else 60 | return true 61 | #endif 62 | } 63 | 64 | private func recordFailure(_ message: String, location: SourceLocation) { 65 | #if SWIFT_PACKAGE 66 | XCTFail("\(message)", file: location.file, line: location.line) 67 | #else 68 | if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase { 69 | testCase.recordFailure(withDescription: message, inFile: location.file, atLine: location.line, expected: true) 70 | } else { 71 | let msg = "Attempted to report a test failure to XCTest while no test case was running. " + 72 | "The failure was:\n\"\(message)\"\nIt occurred at: \(location.file):\(location.line)" 73 | NSException(name: .internalInconsistencyException, reason: msg, userInfo: nil).raise() 74 | } 75 | #endif 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/DSL.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Make an expectation on a given actual value. The value given is lazily evaluated. 4 | public func expect(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation { 5 | return Expectation( 6 | expression: Expression( 7 | expression: expression, 8 | location: SourceLocation(file: file, line: line), 9 | isClosure: true)) 10 | } 11 | 12 | /// Make an expectation on a given actual value. The closure is lazily invoked. 13 | public func expect(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation { 14 | return Expectation( 15 | expression: Expression( 16 | expression: expression, 17 | location: SourceLocation(file: file, line: line), 18 | isClosure: true)) 19 | } 20 | 21 | /// Always fails the test with a message and a specified location. 22 | public func fail(_ message: String, location: SourceLocation) { 23 | let handler = NimbleEnvironment.activeInstance.assertionHandler 24 | handler.assert(false, message: FailureMessage(stringValue: message), location: location) 25 | } 26 | 27 | /// Always fails the test with a message. 28 | public func fail(_ message: String, file: FileString = #file, line: UInt = #line) { 29 | fail(message, location: SourceLocation(file: file, line: line)) 30 | } 31 | 32 | /// Always fails the test. 33 | public func fail(_ file: FileString = #file, line: UInt = #line) { 34 | fail("fail() always fails", file: file, line: line) 35 | } 36 | 37 | /// Like Swift's precondition(), but raises NSExceptions instead of sigaborts 38 | internal func nimblePrecondition( 39 | _ expr: @autoclosure() -> Bool, 40 | _ name: @autoclosure() -> String, 41 | _ message: @autoclosure() -> String, 42 | file: StaticString = #file, 43 | line: UInt = #line) { 44 | let result = expr() 45 | if !result { 46 | #if _runtime(_ObjC) 47 | let e = NSException( 48 | name: NSExceptionName(name()), 49 | reason: message(), 50 | userInfo: nil) 51 | e.raise() 52 | #else 53 | preconditionFailure("\(name()) - \(message())", file: file, line: line) 54 | #endif 55 | } 56 | } 57 | 58 | internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never { 59 | fatalError( 60 | "Nimble Bug Found: \(msg) at \(file):\(line).\n" + 61 | "Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the " + 62 | "code snippet that caused this error." 63 | ) 64 | } 65 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Expectation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func expressionMatches(_ expression: Expression, matcher: U, to: String, description: String?) -> (Bool, FailureMessage) 4 | where U: Matcher, U.ValueType == T { 5 | let msg = FailureMessage() 6 | msg.userDescription = description 7 | msg.to = to 8 | do { 9 | let pass = try matcher.matches(expression, failureMessage: msg) 10 | if msg.actualValue == "" { 11 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 12 | } 13 | return (pass, msg) 14 | } catch let error { 15 | msg.actualValue = "an unexpected error thrown: <\(error)>" 16 | return (false, msg) 17 | } 18 | } 19 | 20 | internal func expressionDoesNotMatch(_ expression: Expression, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage) 21 | where U: Matcher, U.ValueType == T { 22 | let msg = FailureMessage() 23 | msg.userDescription = description 24 | msg.to = toNot 25 | do { 26 | let pass = try matcher.doesNotMatch(expression, failureMessage: msg) 27 | if msg.actualValue == "" { 28 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 29 | } 30 | return (pass, msg) 31 | } catch let error { 32 | msg.actualValue = "an unexpected error thrown: <\(error)>" 33 | return (false, msg) 34 | } 35 | } 36 | 37 | public struct Expectation { 38 | 39 | public let expression: Expression 40 | 41 | public func verify(_ pass: Bool, _ message: FailureMessage) { 42 | let handler = NimbleEnvironment.activeInstance.assertionHandler 43 | handler.assert(pass, message: message, location: expression.location) 44 | } 45 | 46 | /// Tests the actual value using a matcher to match. 47 | public func to(_ matcher: U, description: String? = nil) 48 | where U: Matcher, U.ValueType == T { 49 | let (pass, msg) = expressionMatches(expression, matcher: matcher, to: "to", description: description) 50 | verify(pass, msg) 51 | } 52 | 53 | /// Tests the actual value using a matcher to not match. 54 | public func toNot(_ matcher: U, description: String? = nil) 55 | where U: Matcher, U.ValueType == T { 56 | let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) 57 | verify(pass, msg) 58 | } 59 | 60 | /// Tests the actual value using a matcher to not match. 61 | /// 62 | /// Alias to toNot(). 63 | public func notTo(_ matcher: U, description: String? = nil) 64 | where U: Matcher, U.ValueType == T { 65 | toNot(matcher, description: description) 66 | } 67 | 68 | // see: 69 | // - AsyncMatcherWrapper for extension 70 | // - NMBExpectation for Objective-C interface 71 | } 72 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/FailureMessage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Encapsulates the failure message that matchers can report to the end user. 4 | /// 5 | /// This is shared state between Nimble and matchers that mutate this value. 6 | public class FailureMessage: NSObject { 7 | public var expected: String = "expected" 8 | public var actualValue: String? = "" // empty string -> use default; nil -> exclude 9 | public var to: String = "to" 10 | public var postfixMessage: String = "match" 11 | public var postfixActual: String = "" 12 | /// An optional message that will be appended as a new line and provides additional details 13 | /// about the failure. This message will only be visible in the issue navigator / in logs but 14 | /// not directly in the source editor since only a single line is presented there. 15 | public var extendedMessage: String? = nil 16 | public var userDescription: String? = nil 17 | 18 | public var stringValue: String { 19 | get { 20 | if let value = _stringValueOverride { 21 | return value 22 | } else { 23 | return computeStringValue() 24 | } 25 | } 26 | set { 27 | _stringValueOverride = newValue 28 | } 29 | } 30 | 31 | internal var _stringValueOverride: String? 32 | 33 | public override init() { 34 | } 35 | 36 | public init(stringValue: String) { 37 | _stringValueOverride = stringValue 38 | } 39 | 40 | internal func stripNewlines(_ str: String) -> String { 41 | let whitespaces = CharacterSet.whitespacesAndNewlines 42 | return str 43 | .components(separatedBy: "\n") 44 | .map { line in line.trimmingCharacters(in: whitespaces) } 45 | .joined(separator: "") 46 | } 47 | 48 | internal func computeStringValue() -> String { 49 | var value = "\(expected) \(to) \(postfixMessage)" 50 | if let actualValue = actualValue { 51 | value = "\(expected) \(to) \(postfixMessage), got \(actualValue)\(postfixActual)" 52 | } 53 | value = stripNewlines(value) 54 | 55 | if let extendedMessage = extendedMessage { 56 | value += "\n\(stripNewlines(extendedMessage))" 57 | } 58 | 59 | if let userDescription = userDescription { 60 | return "\(userDescription)\n\(value)" 61 | } 62 | 63 | return value 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 4 | public func beAKindOf(_ expectedType: T.Type) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc {actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be a kind of \(String(describing: expectedType))" 7 | let instance = try actualExpression.evaluate() 8 | guard let validInstance = instance else { 9 | failureMessage.actualValue = "" 10 | return false 11 | } 12 | 13 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 14 | 15 | guard validInstance is T else { 16 | return false 17 | } 18 | 19 | return true 20 | } 21 | } 22 | 23 | #if _runtime(_ObjC) 24 | 25 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 26 | /// @see beAnInstanceOf if you want to match against the exact class 27 | public func beAKindOf(_ expectedClass: AnyClass) -> NonNilMatcherFunc { 28 | return NonNilMatcherFunc { actualExpression, failureMessage in 29 | let instance = try actualExpression.evaluate() 30 | if let validInstance = instance { 31 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 32 | } else { 33 | failureMessage.actualValue = "" 34 | } 35 | failureMessage.postfixMessage = "be a kind of \(String(describing: expectedClass))" 36 | return instance != nil && instance!.isKind(of: expectedClass) 37 | } 38 | } 39 | 40 | extension NMBObjCMatcher { 41 | public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher { 42 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 43 | return try! beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage) 44 | } 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class. 4 | public func beAnInstanceOf(_ expectedType: T.Type) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc {actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be an instance of \(String(describing: expectedType))" 7 | let instance = try actualExpression.evaluate() 8 | guard let validInstance = instance else { 9 | failureMessage.actualValue = "" 10 | return false 11 | } 12 | 13 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 14 | 15 | if type(of: validInstance) == expectedType { 16 | return true 17 | } 18 | 19 | return false 20 | } 21 | } 22 | 23 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 24 | /// @see beAKindOf if you want to match against subclasses 25 | public func beAnInstanceOf(_ expectedClass: AnyClass) -> NonNilMatcherFunc { 26 | return NonNilMatcherFunc { actualExpression, failureMessage in 27 | let instance = try actualExpression.evaluate() 28 | if let validInstance = instance { 29 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 30 | } else { 31 | failureMessage.actualValue = "" 32 | } 33 | failureMessage.postfixMessage = "be an instance of \(String(describing: expectedClass))" 34 | #if _runtime(_ObjC) 35 | return instance != nil && instance!.isMember(of: expectedClass) 36 | #else 37 | return instance != nil && type(of: instance!) == expectedClass 38 | #endif 39 | } 40 | } 41 | 42 | #if _runtime(_ObjC) 43 | extension NMBObjCMatcher { 44 | public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher { 45 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 46 | return try! beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage) 47 | } 48 | } 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 4 | public func beGreaterThan(_ expectedValue: T?) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 8 | return actual > expected 9 | } 10 | return false 11 | } 12 | } 13 | 14 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 15 | public func beGreaterThan(_ expectedValue: NMBComparable?) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 18 | let actualValue = try actualExpression.evaluate() 19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedDescending 20 | return matches 21 | } 22 | } 23 | 24 | public func >(lhs: Expectation, rhs: T) { 25 | lhs.to(beGreaterThan(rhs)) 26 | } 27 | 28 | public func > (lhs: Expectation, rhs: NMBComparable?) { 29 | lhs.to(beGreaterThan(rhs)) 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | let expr = actualExpression.cast { $0 as? NMBComparable } 37 | return try! beGreaterThan(expected).matches(expr, failureMessage: failureMessage) 38 | } 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is greater than 4 | /// or equal to the expected value. 5 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 8 | let actualValue = try actualExpression.evaluate() 9 | if let actual = actualValue, let expected = expectedValue { 10 | return actual >= expected 11 | } 12 | return false 13 | } 14 | } 15 | 16 | /// A Nimble matcher that succeeds when the actual value is greater than 17 | /// or equal to the expected value. 18 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 19 | return NonNilMatcherFunc { actualExpression, failureMessage in 20 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 21 | let actualValue = try actualExpression.evaluate() 22 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedAscending 23 | return matches 24 | } 25 | } 26 | 27 | public func >=(lhs: Expectation, rhs: T) { 28 | lhs.to(beGreaterThanOrEqualTo(rhs)) 29 | } 30 | 31 | public func >=(lhs: Expectation, rhs: T) { 32 | lhs.to(beGreaterThanOrEqualTo(rhs)) 33 | } 34 | 35 | #if _runtime(_ObjC) 36 | extension NMBObjCMatcher { 37 | public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 38 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 39 | let expr = actualExpression.cast { $0 as? NMBComparable } 40 | return try! beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 41 | } 42 | } 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is the same instance 4 | /// as the expected instance. 5 | public func beIdenticalTo(_ expected: Any?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | #if os(Linux) 8 | let actual = try actualExpression.evaluate() as? AnyObject 9 | #else 10 | let actual = try actualExpression.evaluate() as AnyObject? 11 | #endif 12 | failureMessage.actualValue = "\(identityAsString(actual))" 13 | failureMessage.postfixMessage = "be identical to \(identityAsString(expected))" 14 | #if os(Linux) 15 | return actual === (expected as? AnyObject) && actual !== nil 16 | #else 17 | return actual === (expected as AnyObject?) && actual !== nil 18 | #endif 19 | } 20 | } 21 | 22 | public func === (lhs: Expectation, rhs: Any?) { 23 | lhs.to(beIdenticalTo(rhs)) 24 | } 25 | public func !== (lhs: Expectation, rhs: Any?) { 26 | lhs.toNot(beIdenticalTo(rhs)) 27 | } 28 | 29 | /// A Nimble matcher that succeeds when the actual value is the same instance 30 | /// as the expected instance. 31 | /// 32 | /// Alias for "beIdenticalTo". 33 | public func be(_ expected: Any?) -> NonNilMatcherFunc { 34 | return beIdenticalTo(expected) 35 | } 36 | 37 | #if _runtime(_ObjC) 38 | extension NMBObjCMatcher { 39 | public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBObjCMatcher { 40 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 41 | let aExpr = actualExpression.cast { $0 as Any? } 42 | return try! beIdenticalTo(expected).matches(aExpr, failureMessage: failureMessage) 43 | } 44 | } 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 4 | public func beLessThan(_ expectedValue: T?) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 8 | return actual < expected 9 | } 10 | return false 11 | } 12 | } 13 | 14 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 15 | public func beLessThan(_ expectedValue: NMBComparable?) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 18 | let actualValue = try actualExpression.evaluate() 19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedAscending 20 | return matches 21 | } 22 | } 23 | 24 | public func <(lhs: Expectation, rhs: T) { 25 | lhs.to(beLessThan(rhs)) 26 | } 27 | 28 | public func < (lhs: Expectation, rhs: NMBComparable?) { 29 | lhs.to(beLessThan(rhs)) 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | let expr = actualExpression.cast { $0 as? NMBComparable } 37 | return try! beLessThan(expected).matches(expr, failureMessage: failureMessage) 38 | } 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThanOrEqual.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than 4 | /// or equal to the expected value. 5 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 8 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 9 | return actual <= expected 10 | } 11 | return false 12 | } 13 | } 14 | 15 | /// A Nimble matcher that succeeds when the actual value is less than 16 | /// or equal to the expected value. 17 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 20 | let actualValue = try actualExpression.evaluate() 21 | return actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedDescending 22 | } 23 | } 24 | 25 | public func <=(lhs: Expectation, rhs: T) { 26 | lhs.to(beLessThanOrEqualTo(rhs)) 27 | } 28 | 29 | public func <=(lhs: Expectation, rhs: T) { 30 | lhs.to(beLessThanOrEqualTo(rhs)) 31 | } 32 | 33 | #if _runtime(_ObjC) 34 | extension NMBObjCMatcher { 35 | public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 36 | return NMBObjCMatcher(canMatchNil:false) { actualExpression, failureMessage in 37 | let expr = actualExpression.cast { $0 as? NMBComparable } 38 | return try! beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 39 | } 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeNil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is nil. 4 | public func beNil() -> MatcherFunc { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be nil" 7 | let actualValue = try actualExpression.evaluate() 8 | return actualValue == nil 9 | } 10 | } 11 | 12 | #if _runtime(_ObjC) 13 | extension NMBObjCMatcher { 14 | public class func beNilMatcher() -> NMBObjCMatcher { 15 | return NMBObjCMatcher { actualExpression, failureMessage in 16 | return try! beNil().matches(actualExpression, failureMessage: failureMessage) 17 | } 18 | } 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeVoid.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is Void. 4 | public func beVoid() -> MatcherFunc<()> { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be void" 7 | let actualValue: ()? = try actualExpression.evaluate() 8 | return actualValue != nil 9 | } 10 | } 11 | 12 | public func == (lhs: Expectation<()>, rhs: ()) { 13 | lhs.to(beVoid()) 14 | } 15 | 16 | public func != (lhs: Expectation<()>, rhs: ()) { 17 | lhs.toNot(beVoid()) 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeginWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual sequence's first element 4 | /// is equal to the expected value. 5 | public func beginWith(_ startingElement: T) -> NonNilMatcherFunc 6 | where S.Iterator.Element == T { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 9 | if let actualValue = try actualExpression.evaluate() { 10 | var actualGenerator = actualValue.makeIterator() 11 | return actualGenerator.next() == startingElement 12 | } 13 | return false 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual collection's first element 18 | /// is equal to the expected object. 19 | public func beginWith(_ startingElement: Any) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 22 | guard let collection = try actualExpression.evaluate() else { return false } 23 | guard collection.count > 0 else { return false } 24 | #if os(Linux) 25 | guard let collectionValue = collection.object(at: 0) as? NSObject else { 26 | return false 27 | } 28 | #else 29 | let collectionValue = collection.object(at: 0) as AnyObject 30 | #endif 31 | return collectionValue.isEqual(startingElement) 32 | } 33 | } 34 | 35 | /// A Nimble matcher that succeeds when the actual string contains expected substring 36 | /// where the expected substring's location is zero. 37 | public func beginWith(_ startingSubstring: String) -> NonNilMatcherFunc { 38 | return NonNilMatcherFunc { actualExpression, failureMessage in 39 | failureMessage.postfixMessage = "begin with <\(startingSubstring)>" 40 | if let actual = try actualExpression.evaluate() { 41 | let range = actual.range(of: startingSubstring) 42 | return range != nil && range!.lowerBound == actual.startIndex 43 | } 44 | return false 45 | } 46 | } 47 | 48 | #if _runtime(_ObjC) 49 | extension NMBObjCMatcher { 50 | public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher { 51 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 52 | let actual = try! actualExpression.evaluate() 53 | if let _ = actual as? String { 54 | let expr = actualExpression.cast { $0 as? String } 55 | return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage) 56 | } else { 57 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 58 | return try! beginWith(expected).matches(expr, failureMessage: failureMessage) 59 | } 60 | } 61 | } 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public func containElementSatisfying(_ predicate: @escaping ((T) -> Bool), _ predicateDescription: String = "") -> NonNilMatcherFunc where S.Iterator.Element == T { 4 | 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.actualValue = nil 7 | 8 | if predicateDescription == "" { 9 | failureMessage.postfixMessage = "find object in collection that satisfies predicate" 10 | } else { 11 | failureMessage.postfixMessage = "find object in collection \(predicateDescription)" 12 | } 13 | 14 | if let sequence = try actualExpression.evaluate() { 15 | for object in sequence { 16 | if predicate(object) { 17 | return true 18 | } 19 | } 20 | 21 | return false 22 | } 23 | 24 | return false 25 | } 26 | } 27 | 28 | #if _runtime(_ObjC) 29 | extension NMBObjCMatcher { 30 | public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBObjCMatcher { 31 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 32 | let value = try! actualExpression.evaluate() 33 | guard let enumeration = value as? NSFastEnumeration else { 34 | failureMessage.postfixMessage = "containElementSatisfying must be provided an NSFastEnumeration object" 35 | failureMessage.actualValue = nil 36 | failureMessage.expected = "" 37 | failureMessage.to = "" 38 | return false 39 | } 40 | 41 | let iterator = NSFastEnumerationIterator(enumeration) 42 | while let item = iterator.next() { 43 | guard let object = item as? NSObject else { 44 | continue 45 | } 46 | 47 | if predicate(object) { 48 | return true 49 | } 50 | } 51 | 52 | failureMessage.actualValue = nil 53 | failureMessage.postfixMessage = "" 54 | failureMessage.to = "to find object in collection that satisfies predicate" 55 | return false 56 | } 57 | } 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/EndWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual sequence's last element 4 | /// is equal to the expected value. 5 | public func endWith(_ endingElement: T) -> NonNilMatcherFunc 6 | where S.Iterator.Element == T { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "end with <\(endingElement)>" 9 | 10 | if let actualValue = try actualExpression.evaluate() { 11 | var actualGenerator = actualValue.makeIterator() 12 | var lastItem: T? 13 | var item: T? 14 | repeat { 15 | lastItem = item 16 | item = actualGenerator.next() 17 | } while(item != nil) 18 | 19 | return lastItem == endingElement 20 | } 21 | return false 22 | } 23 | } 24 | 25 | /// A Nimble matcher that succeeds when the actual collection's last element 26 | /// is equal to the expected object. 27 | public func endWith(_ endingElement: Any) -> NonNilMatcherFunc { 28 | return NonNilMatcherFunc { actualExpression, failureMessage in 29 | failureMessage.postfixMessage = "end with <\(endingElement)>" 30 | guard let collection = try actualExpression.evaluate() else { return false } 31 | guard collection.count > 0 else { return false } 32 | #if os(Linux) 33 | guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else { 34 | return false 35 | } 36 | #else 37 | let collectionValue = collection.object(at: collection.count - 1) as AnyObject 38 | #endif 39 | 40 | return collectionValue.isEqual(endingElement) 41 | } 42 | } 43 | 44 | /// A Nimble matcher that succeeds when the actual string contains the expected substring 45 | /// where the expected substring's location is the actual string's length minus the 46 | /// expected substring's length. 47 | public func endWith(_ endingSubstring: String) -> NonNilMatcherFunc { 48 | return NonNilMatcherFunc { actualExpression, failureMessage in 49 | failureMessage.postfixMessage = "end with <\(endingSubstring)>" 50 | if let collection = try actualExpression.evaluate() { 51 | return collection.hasSuffix(endingSubstring) 52 | } 53 | return false 54 | } 55 | } 56 | 57 | #if _runtime(_ObjC) 58 | extension NMBObjCMatcher { 59 | public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher { 60 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 61 | let actual = try! actualExpression.evaluate() 62 | if let _ = actual as? String { 63 | let expr = actualExpression.cast { $0 as? String } 64 | return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage) 65 | } else { 66 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 67 | return try! endWith(expected).matches(expr, failureMessage: failureMessage) 68 | } 69 | } 70 | } 71 | } 72 | #endif 73 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/HaveCount.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // The `haveCount` matchers do not print the full string representation of the collection value, 4 | // instead they only print the type name and the expected count. This makes it easier to understand 5 | // the reason for failed expectations. See: https://github.com/Quick/Nimble/issues/308. 6 | // The representation of the collection content is provided in a new line as an `extendedMessage`. 7 | 8 | /// A Nimble matcher that succeeds when the actual Collection's count equals 9 | /// the expected value 10 | public func haveCount(_ expectedValue: T.IndexDistance) -> NonNilMatcherFunc { 11 | return NonNilMatcherFunc { actualExpression, failureMessage in 12 | if let actualValue = try actualExpression.evaluate() { 13 | failureMessage.postfixMessage = "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))" 14 | let result = expectedValue == actualValue.count 15 | failureMessage.actualValue = "\(actualValue.count)" 16 | failureMessage.extendedMessage = "Actual Value: \(stringify(actualValue))" 17 | return result 18 | } else { 19 | return false 20 | } 21 | } 22 | } 23 | 24 | /// A Nimble matcher that succeeds when the actual collection's count equals 25 | /// the expected value 26 | public func haveCount(_ expectedValue: Int) -> MatcherFunc { 27 | return MatcherFunc { actualExpression, failureMessage in 28 | if let actualValue = try actualExpression.evaluate() { 29 | failureMessage.postfixMessage = "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))" 30 | let result = expectedValue == actualValue.count 31 | failureMessage.actualValue = "\(actualValue.count)" 32 | failureMessage.extendedMessage = "Actual Value: \(stringify(actualValue))" 33 | return result 34 | } else { 35 | return false 36 | } 37 | } 38 | } 39 | 40 | #if _runtime(_ObjC) 41 | extension NMBObjCMatcher { 42 | public class func haveCountMatcher(_ expected: NSNumber) -> NMBObjCMatcher { 43 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 44 | let location = actualExpression.location 45 | let actualValue = try! actualExpression.evaluate() 46 | if let value = actualValue as? NMBCollection { 47 | let expr = Expression(expression: ({ value as NMBCollection}), location: location) 48 | return try! haveCount(expected.intValue).matches(expr, failureMessage: failureMessage) 49 | } else if let actualValue = actualValue { 50 | failureMessage.postfixMessage = "get type of NSArray, NSSet, NSDictionary, or NSHashTable" 51 | failureMessage.actualValue = "\(String(describing: type(of: actualValue)))" 52 | } 53 | return false 54 | } 55 | } 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/Match.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression 4 | /// described by the expected string. 5 | public func match(_ expectedValue: String?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" 8 | 9 | if let actual = try actualExpression.evaluate() { 10 | if let regexp = expectedValue { 11 | return actual.range(of: regexp, options: .regularExpression) != nil 12 | } 13 | } 14 | 15 | return false 16 | } 17 | } 18 | 19 | #if _runtime(_ObjC) 20 | 21 | extension NMBObjCMatcher { 22 | public class func matchMatcher(_ expected: NSString) -> NMBMatcher { 23 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 24 | let actual = actualExpression.cast { $0 as? String } 25 | return try! match(expected.description).matches(actual, failureMessage: failureMessage) 26 | } 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/MatchError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 4 | /// error from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | public func matchError(_ error: T) -> NonNilMatcherFunc { 9 | return NonNilMatcherFunc { actualExpression, failureMessage in 10 | let actualError: Error? = try actualExpression.evaluate() 11 | 12 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, error: error) 13 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error) 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 18 | /// error of the specified type 19 | public func matchError(_ errorType: T.Type) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | let actualError: Error? = try actualExpression.evaluate() 22 | 23 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, errorType: errorType) 24 | return errorMatchesNonNilFieldsOrClosure(actualError, errorType: errorType) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/MatcherFunc.swift: -------------------------------------------------------------------------------- 1 | /// A convenience API to build matchers that don't need special negation 2 | /// behavior. The toNot() behavior is the negation of to(). 3 | /// 4 | /// @see NonNilMatcherFunc if you prefer to have this matcher fail when nil 5 | /// values are recieved in an expectation. 6 | /// 7 | /// You may use this when implementing your own custom matchers. 8 | /// 9 | /// Use the Matcher protocol instead of this type to accept custom matchers as 10 | /// input parameters. 11 | /// @see allPass for an example that uses accepts other matchers as input. 12 | public struct MatcherFunc: Matcher { 13 | public let matcher: (Expression, FailureMessage) throws -> Bool 14 | 15 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { 16 | self.matcher = matcher 17 | } 18 | 19 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 20 | return try matcher(actualExpression, failureMessage) 21 | } 22 | 23 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 24 | return try !matcher(actualExpression, failureMessage) 25 | } 26 | } 27 | 28 | /// A convenience API to build matchers that don't need special negation 29 | /// behavior. The toNot() behavior is the negation of to(). 30 | /// 31 | /// Unlike MatcherFunc, this will always fail if an expectation contains nil. 32 | /// This applies regardless of using to() or toNot(). 33 | /// 34 | /// You may use this when implementing your own custom matchers. 35 | /// 36 | /// Use the Matcher protocol instead of this type to accept custom matchers as 37 | /// input parameters. 38 | /// @see allPass for an example that uses accepts other matchers as input. 39 | public struct NonNilMatcherFunc: Matcher { 40 | public let matcher: (Expression, FailureMessage) throws -> Bool 41 | 42 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { 43 | self.matcher = matcher 44 | } 45 | 46 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 47 | let pass = try matcher(actualExpression, failureMessage) 48 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 49 | return false 50 | } 51 | return pass 52 | } 53 | 54 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 55 | let pass = try !matcher(actualExpression, failureMessage) 56 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 57 | return false 58 | } 59 | return pass 60 | } 61 | 62 | internal func attachNilErrorIfNeeded(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 63 | if try actualExpression.evaluate() == nil { 64 | failureMessage.postfixActual = " (use beNil() to match nils)" 65 | return true 66 | } 67 | return false 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/PostNotification.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal class NotificationCollector { 4 | private(set) var observedNotifications: [Notification] 5 | private let notificationCenter: NotificationCenter 6 | #if _runtime(_ObjC) 7 | private var token: AnyObject? 8 | #else 9 | private var token: NSObjectProtocol? 10 | #endif 11 | 12 | required init(notificationCenter: NotificationCenter) { 13 | self.notificationCenter = notificationCenter 14 | self.observedNotifications = [] 15 | } 16 | 17 | func startObserving() { 18 | self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { [weak self] n in 19 | // linux-swift gets confused by .append(n) 20 | self?.observedNotifications.append(n) 21 | } 22 | } 23 | 24 | deinit { 25 | #if _runtime(_ObjC) 26 | if let token = self.token { 27 | self.notificationCenter.removeObserver(token) 28 | } 29 | #else 30 | if let token = self.token as? AnyObject { 31 | self.notificationCenter.removeObserver(token) 32 | } 33 | #endif 34 | } 35 | } 36 | 37 | private let mainThread = pthread_self() 38 | 39 | let notificationCenterDefault = NotificationCenter.default 40 | 41 | public func postNotifications( 42 | _ notificationsMatcher: T, 43 | fromNotificationCenter center: NotificationCenter = notificationCenterDefault) 44 | -> MatcherFunc 45 | where T: Matcher, T.ValueType == [Notification] 46 | { 47 | let _ = mainThread // Force lazy-loading of this value 48 | let collector = NotificationCollector(notificationCenter: center) 49 | collector.startObserving() 50 | var once: Bool = false 51 | return MatcherFunc { actualExpression, failureMessage in 52 | let collectorNotificationsExpression = Expression(memoizedExpression: { _ in 53 | return collector.observedNotifications 54 | }, location: actualExpression.location, withoutCaching: true) 55 | 56 | assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.") 57 | if !once { 58 | once = true 59 | _ = try actualExpression.evaluate() 60 | } 61 | 62 | let match = try notificationsMatcher.matches(collectorNotificationsExpression, failureMessage: failureMessage) 63 | if collector.observedNotifications.isEmpty { 64 | failureMessage.actualValue = "no notifications" 65 | } else { 66 | failureMessage.actualValue = "<\(stringify(collector.observedNotifications))>" 67 | } 68 | return match 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value matches with any of the matchers 4 | /// provided in the variable list of matchers. 5 | public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc 6 | where U: Matcher, U.ValueType == T { 7 | return satisfyAnyOf(matchers) 8 | } 9 | 10 | internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc 11 | where U: Matcher, U.ValueType == T { 12 | return NonNilMatcherFunc { actualExpression, failureMessage in 13 | let postfixMessages = NSMutableArray() 14 | var matches = false 15 | for matcher in matchers { 16 | if try matcher.matches(actualExpression, failureMessage: failureMessage) { 17 | matches = true 18 | } 19 | postfixMessages.add(NSString(string: "{\(failureMessage.postfixMessage)}")) 20 | } 21 | 22 | failureMessage.postfixMessage = "match one of: " + postfixMessages.componentsJoined(by: ", or ") 23 | if let actualValue = try actualExpression.evaluate() { 24 | failureMessage.actualValue = "\(actualValue)" 25 | } 26 | 27 | return matches 28 | } 29 | } 30 | 31 | public func || (left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> NonNilMatcherFunc { 32 | return satisfyAnyOf(left, right) 33 | } 34 | 35 | public func || (left: MatcherFunc, right: MatcherFunc) -> NonNilMatcherFunc { 36 | return satisfyAnyOf(left, right) 37 | } 38 | 39 | #if _runtime(_ObjC) 40 | extension NMBObjCMatcher { 41 | public class func satisfyAnyOfMatcher(_ matchers: [NMBObjCMatcher]) -> NMBObjCMatcher { 42 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 43 | if matchers.isEmpty { 44 | failureMessage.stringValue = "satisfyAnyOf must be called with at least one matcher" 45 | return false 46 | } 47 | 48 | var elementEvaluators = [NonNilMatcherFunc]() 49 | for matcher in matchers { 50 | let elementEvaluator: (Expression, FailureMessage) -> Bool = { 51 | expression, failureMessage in 52 | return matcher.matches({try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) 53 | } 54 | 55 | elementEvaluators.append(NonNilMatcherFunc(elementEvaluator)) 56 | } 57 | 58 | return try! satisfyAnyOf(elementEvaluators).matches(actualExpression, failureMessage: failureMessage) 59 | } 60 | } 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public func throwAssertion() -> MatcherFunc { 4 | return MatcherFunc { actualExpression, failureMessage in 5 | #if arch(x86_64) && _runtime(_ObjC) && !SWIFT_PACKAGE 6 | failureMessage.postfixMessage = "throw an assertion" 7 | failureMessage.actualValue = nil 8 | 9 | var succeeded = true 10 | 11 | let caughtException: BadInstructionException? = catchBadInstruction { 12 | #if os(tvOS) 13 | if !NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning { 14 | print() 15 | print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " + 16 | "fatal error while using throwAssertion(), please disable 'Debug Executable' " + 17 | "in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " + 18 | "'Debug Executable'. If you've already done that, suppress this warning " + 19 | "by setting `NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true`. " + 20 | "This is required because the standard methods of catching assertions " + 21 | "(mach APIs) are unavailable for tvOS. Instead, the same mechanism the " + 22 | "debugger uses is the fallback method for tvOS." 23 | ) 24 | print() 25 | NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true 26 | } 27 | #endif 28 | do { 29 | try actualExpression.evaluate() 30 | } catch let error { 31 | succeeded = false 32 | failureMessage.postfixMessage += "; threw error instead <\(error)>" 33 | } 34 | } 35 | 36 | if !succeeded { 37 | return false 38 | } 39 | 40 | if caughtException == nil { 41 | return false 42 | } 43 | 44 | return true 45 | #elseif SWIFT_PACKAGE 46 | fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." + 47 | " You can silence this error by placing the test case inside an #if !SWIFT_PACKAGE" + 48 | " conditional statement") 49 | #else 50 | fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " + 51 | "Objective-C (e.g. Mac, iPhone 5s or later simulators). You can silence this error " + 52 | "by placing the test case inside an #if arch(x86_64) or _runtime(_ObjC) conditional statement") 53 | #endif 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression throws an 4 | /// error of the specified type or from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | /// 9 | /// Alternatively, you can pass a closure to do any arbitrary custom matching 10 | /// to the thrown error. The closure only gets called when an error was thrown. 11 | /// 12 | /// nil arguments indicates that the matcher should not attempt to match against 13 | /// that parameter. 14 | public func throwError( 15 | _ error: T? = nil, 16 | errorType: T.Type? = nil, 17 | closure: ((T) -> Void)? = nil) -> MatcherFunc { 18 | return MatcherFunc { actualExpression, failureMessage in 19 | 20 | var actualError: Error? 21 | do { 22 | _ = try actualExpression.evaluate() 23 | } catch let catchedError { 24 | actualError = catchedError 25 | } 26 | 27 | setFailureMessageForError(failureMessage, actualError: actualError, error: error, errorType: errorType, closure: closure) 28 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error, errorType: errorType, closure: closure) 29 | } 30 | } 31 | 32 | /// A Nimble matcher that succeeds when the actual expression throws any 33 | /// error or when the passed closures' arbitrary custom matching succeeds. 34 | /// 35 | /// This duplication to it's generic adequate is required to allow to receive 36 | /// values of the existential type `Error` in the closure. 37 | /// 38 | /// The closure only gets called when an error was thrown. 39 | public func throwError( 40 | closure: ((Error) -> Void)? = nil) -> MatcherFunc { 41 | return MatcherFunc { actualExpression, failureMessage in 42 | 43 | var actualError: Error? 44 | do { 45 | _ = try actualExpression.evaluate() 46 | } catch let catchedError { 47 | actualError = catchedError 48 | } 49 | 50 | setFailureMessageForError(failureMessage, actualError: actualError, closure: closure) 51 | return errorMatchesNonNilFieldsOrClosure(actualError, closure: closure) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Nimble.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NMBExceptionCapture.h" 3 | #import "NMBStringify.h" 4 | #import "DSL.h" 5 | 6 | #import "CwlCatchException.h" 7 | #import "CwlCatchBadInstruction.h" 8 | 9 | #if !TARGET_OS_TV 10 | #import "mach_excServer.h" 11 | #endif 12 | 13 | FOUNDATION_EXPORT double NimbleVersionNumber; 14 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 15 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Utils/Functional.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Sequence { 4 | internal func all(_ fn: (Iterator.Element) -> Bool) -> Bool { 5 | for item in self { 6 | if !fn(item) { 7 | return false 8 | } 9 | } 10 | return true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Utils/SourceLocation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Ideally we would always use `StaticString` as the type for tracking the file name 4 | // that expectations originate from, for consistency with `assert` etc. from the 5 | // stdlib, and because recent versions of the XCTest overlay require `StaticString` 6 | // when calling `XCTFail`. Under the Objective-C runtime (i.e. building on Mac), we 7 | // have to use `String` instead because StaticString can't be generated from Objective-C 8 | #if SWIFT_PACKAGE 9 | public typealias FileString = StaticString 10 | #else 11 | public typealias FileString = String 12 | #endif 13 | 14 | public final class SourceLocation: NSObject { 15 | public let file: FileString 16 | public let line: UInt 17 | 18 | override init() { 19 | file = "Unknown File" 20 | line = 0 21 | } 22 | 23 | init(file: FileString, line: UInt) { 24 | self.file = file 25 | self.line = line 26 | } 27 | 28 | override public var description: String { 29 | return "\(file):\(line)" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/CurrentTestCaseTracker.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | SWIFT_CLASS("_TtC6Nimble22CurrentTestCaseTracker") 5 | @interface CurrentTestCaseTracker : NSObject 6 | + (CurrentTestCaseTracker *)sharedInstance; 7 | @end 8 | 9 | @interface CurrentTestCaseTracker (Register) @end 10 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NMBExceptionCapture : NSObject 5 | 6 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally; 7 | - (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)())unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); 8 | 9 | @end 10 | 11 | typedef void(^NMBSourceCallbackBlock)(BOOL successful); 12 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m: -------------------------------------------------------------------------------- 1 | #import "NMBExceptionCapture.h" 2 | 3 | @interface NMBExceptionCapture () 4 | @property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable); 5 | @property (nonatomic, copy) void(^ _Nullable finally)(); 6 | @end 7 | 8 | @implementation NMBExceptionCapture 9 | 10 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally { 11 | self = [super init]; 12 | if (self) { 13 | self.handler = handler; 14 | self.finally = finally; 15 | } 16 | return self; 17 | } 18 | 19 | - (void)tryBlock:(void(^ _Nonnull)())unsafeBlock { 20 | @try { 21 | unsafeBlock(); 22 | } 23 | @catch (NSException *exception) { 24 | if (self.handler) { 25 | self.handler(exception); 26 | } 27 | } 28 | @finally { 29 | if (self.finally) { 30 | self.finally(); 31 | } 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.h: -------------------------------------------------------------------------------- 1 | @class NSString; 2 | 3 | /** 4 | * Returns a string appropriate for displaying in test output 5 | * from the provided value. 6 | * 7 | * @param value A value that will show up in a test's output. 8 | * 9 | * @return The string that is returned can be 10 | * customized per type by conforming a type to the `TestOutputStringConvertible` 11 | * protocol. When stringifying a non-`TestOutputStringConvertible` type, this 12 | * function will return the value's debug description and then its 13 | * normal description if available and in that order. Otherwise it 14 | * will return the result of constructing a string from the value. 15 | * 16 | * @see `TestOutputStringConvertible` 17 | */ 18 | extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result)); 19 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.m: -------------------------------------------------------------------------------- 1 | #import "NMBStringify.h" 2 | #import 3 | 4 | NSString *_Nonnull NMBStringify(id _Nullable anyObject) { 5 | return [NMBStringer stringify:anyObject]; 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/XCTestObservationCenter+Register.m: -------------------------------------------------------------------------------- 1 | #import "CurrentTestCaseTracker.h" 2 | #import 3 | #import 4 | 5 | #pragma mark - Method Swizzling 6 | 7 | /// Swaps the implementations between two instance methods. 8 | /// 9 | /// @param class The class containing `originalSelector`. 10 | /// @param originalSelector Original method to replace. 11 | /// @param replacementSelector Replacement method. 12 | void swizzleSelectors(Class class, SEL originalSelector, SEL replacementSelector) { 13 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 14 | Method replacementMethod = class_getInstanceMethod(class, replacementSelector); 15 | 16 | BOOL didAddMethod = 17 | class_addMethod(class, 18 | originalSelector, 19 | method_getImplementation(replacementMethod), 20 | method_getTypeEncoding(replacementMethod)); 21 | 22 | if (didAddMethod) { 23 | class_replaceMethod(class, 24 | replacementSelector, 25 | method_getImplementation(originalMethod), 26 | method_getTypeEncoding(originalMethod)); 27 | } else { 28 | method_exchangeImplementations(originalMethod, replacementMethod); 29 | } 30 | } 31 | 32 | #pragma mark - Private 33 | 34 | @interface XCTestObservationCenter (Private) 35 | - (void)_addLegacyTestObserver:(id)observer; 36 | @end 37 | 38 | @implementation XCTestObservationCenter (Register) 39 | 40 | /// Uses objc method swizzling to register `CurrentTestCaseTracker` as a test observer. This is necessary 41 | /// because Xcode 7.3 introduced timing issues where if a custom `XCTestObservation` is registered too early 42 | /// it suppresses all console output (generated by `XCTestLog`), breaking any tools that depend on this output. 43 | /// This approach waits to register our custom test observer until XCTest adds its first "legacy" observer, 44 | /// falling back to registering after the first normal observer if this private method ever changes. 45 | + (void)load { 46 | if (class_getInstanceMethod([self class], @selector(_addLegacyTestObserver:))) { 47 | // Swizzle -_addLegacyTestObserver: 48 | swizzleSelectors([self class], @selector(_addLegacyTestObserver:), @selector(NMB_original__addLegacyTestObserver:)); 49 | } else { 50 | // Swizzle -addTestObserver:, only if -_addLegacyTestObserver: is not implemented 51 | swizzleSelectors([self class], @selector(addTestObserver:), @selector(NMB_original_addTestObserver:)); 52 | } 53 | } 54 | 55 | #pragma mark - Replacement Methods 56 | 57 | /// Registers `CurrentTestCaseTracker` as a test observer after `XCTestLog` has been added. 58 | - (void)NMB_original__addLegacyTestObserver:(id)observer { 59 | [self NMB_original__addLegacyTestObserver:observer]; 60 | 61 | static dispatch_once_t onceToken; 62 | dispatch_once(&onceToken, ^{ 63 | [self addTestObserver:[CurrentTestCaseTracker sharedInstance]]; 64 | }); 65 | } 66 | 67 | /// Registers `CurrentTestCaseTracker` as a test observer after `XCTestLog` has been added. 68 | /// This method is only used if `-_addLegacyTestObserver:` is not impelemented. (added in Xcode 7.3) 69 | - (void)NMB_original_addTestObserver:(id)observer { 70 | [self NMB_original_addTestObserver:observer]; 71 | 72 | static dispatch_once_t onceToken; 73 | dispatch_once(&onceToken, ^{ 74 | [self NMB_original_addTestObserver:[CurrentTestCaseTracker sharedInstance]]; 75 | }); 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Callsite.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | An object encapsulating the file and line number at which 5 | a particular example is defined. 6 | */ 7 | final public class Callsite: NSObject { 8 | /** 9 | The absolute path of the file in which an example is defined. 10 | */ 11 | public let file: String 12 | 13 | /** 14 | The line number on which an example is defined. 15 | */ 16 | public let line: UInt 17 | 18 | internal init(file: String, line: UInt) { 19 | self.file = file 20 | self.line = line 21 | } 22 | } 23 | 24 | extension Callsite { 25 | /** 26 | Returns a boolean indicating whether two Callsite objects are equal. 27 | If two callsites are in the same file and on the same line, they must be equal. 28 | */ 29 | @nonobjc public static func == (lhs: Callsite, rhs: Callsite) -> Bool { 30 | return lhs.file == rhs.file && lhs.line == rhs.line 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ErrorUtility.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func raiseError(_ message: String) -> Never { 4 | #if _runtime(_ObjC) 5 | NSException(name: .internalInconsistencyException, reason: message, userInfo: nil).raise() 6 | #endif 7 | 8 | // This won't be reached when ObjC is available and the exception above is raisd 9 | fatalError(message) 10 | } 11 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ExampleGroup.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | Example groups are logical groupings of examples, defined with 5 | the `describe` and `context` functions. Example groups can share 6 | setup and teardown code. 7 | */ 8 | final public class ExampleGroup: NSObject { 9 | weak internal var parent: ExampleGroup? 10 | internal let hooks = ExampleHooks() 11 | 12 | internal var phase: HooksPhase = .nothingExecuted 13 | 14 | private let internalDescription: String 15 | private let flags: FilterFlags 16 | private let isInternalRootExampleGroup: Bool 17 | private var childGroups = [ExampleGroup]() 18 | private var childExamples = [Example]() 19 | 20 | internal init(description: String, flags: FilterFlags, isInternalRootExampleGroup: Bool = false) { 21 | self.internalDescription = description 22 | self.flags = flags 23 | self.isInternalRootExampleGroup = isInternalRootExampleGroup 24 | } 25 | 26 | public override var description: String { 27 | return internalDescription 28 | } 29 | 30 | /** 31 | Returns a list of examples that belong to this example group, 32 | or to any of its descendant example groups. 33 | */ 34 | public var examples: [Example] { 35 | var examples = childExamples 36 | for group in childGroups { 37 | examples.append(contentsOf: group.examples) 38 | } 39 | return examples 40 | } 41 | 42 | internal var name: String? { 43 | if let parent = parent { 44 | guard let name = parent.name else { return description } 45 | return "\(name), \(description)" 46 | } else { 47 | return isInternalRootExampleGroup ? nil : description 48 | } 49 | } 50 | 51 | internal var filterFlags: FilterFlags { 52 | var aggregateFlags = flags 53 | walkUp { group in 54 | for (key, value) in group.flags { 55 | aggregateFlags[key] = value 56 | } 57 | } 58 | return aggregateFlags 59 | } 60 | 61 | internal var befores: [BeforeExampleWithMetadataClosure] { 62 | var closures = Array(hooks.befores.reversed()) 63 | walkUp { group in 64 | closures.append(contentsOf: Array(group.hooks.befores.reversed())) 65 | } 66 | return Array(closures.reversed()) 67 | } 68 | 69 | internal var afters: [AfterExampleWithMetadataClosure] { 70 | var closures = hooks.afters 71 | walkUp { group in 72 | closures.append(contentsOf: group.hooks.afters) 73 | } 74 | return closures 75 | } 76 | 77 | internal func walkDownExamples(_ callback: (_ example: Example) -> Void) { 78 | for example in childExamples { 79 | callback(example) 80 | } 81 | for group in childGroups { 82 | group.walkDownExamples(callback) 83 | } 84 | } 85 | 86 | internal func appendExampleGroup(_ group: ExampleGroup) { 87 | group.parent = self 88 | childGroups.append(group) 89 | } 90 | 91 | internal func appendExample(_ example: Example) { 92 | example.group = self 93 | childExamples.append(example) 94 | } 95 | 96 | private func walkUp(_ callback: (_ group: ExampleGroup) -> Void) { 97 | var group = self 98 | while let parent = group.parent { 99 | callback(parent) 100 | group = parent 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ExampleMetadata.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A class that encapsulates information about an example, 5 | including the index at which the example was executed, as 6 | well as the example itself. 7 | */ 8 | final public class ExampleMetadata: NSObject { 9 | /** 10 | The example for which this metadata was collected. 11 | */ 12 | public let example: Example 13 | 14 | /** 15 | The index at which this example was executed in the 16 | test suite. 17 | */ 18 | public let exampleIndex: Int 19 | 20 | internal init(example: Example, exampleIndex: Int) { 21 | self.example = example 22 | self.exampleIndex = exampleIndex 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Filter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A mapping of string keys to booleans that can be used to 5 | filter examples or example groups. For example, a "focused" 6 | example would have the flags [Focused: true]. 7 | */ 8 | public typealias FilterFlags = [String: Bool] 9 | 10 | /** 11 | A namespace for filter flag keys, defined primarily to make the 12 | keys available in Objective-C. 13 | */ 14 | final public class Filter: NSObject { 15 | /** 16 | Example and example groups with [Focused: true] are included in test runs, 17 | excluding all other examples without this flag. Use this to only run one or 18 | two tests that you're currently focusing on. 19 | */ 20 | public class var focused: String { 21 | return "focused" 22 | } 23 | 24 | /** 25 | Example and example groups with [Pending: true] are excluded from test runs. 26 | Use this to temporarily suspend examples that you know do not pass yet. 27 | */ 28 | public class var pending: String { 29 | return "pending" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/Closures.swift: -------------------------------------------------------------------------------- 1 | // MARK: Example Hooks 2 | 3 | /** 4 | A closure executed before an example is run. 5 | */ 6 | public typealias BeforeExampleClosure = () -> Void 7 | 8 | /** 9 | A closure executed before an example is run. The closure is given example metadata, 10 | which contains information about the example that is about to be run. 11 | */ 12 | public typealias BeforeExampleWithMetadataClosure = (_ exampleMetadata: ExampleMetadata) -> Void 13 | 14 | /** 15 | A closure executed after an example is run. 16 | */ 17 | public typealias AfterExampleClosure = BeforeExampleClosure 18 | 19 | /** 20 | A closure executed after an example is run. The closure is given example metadata, 21 | which contains information about the example that has just finished running. 22 | */ 23 | public typealias AfterExampleWithMetadataClosure = BeforeExampleWithMetadataClosure 24 | 25 | // MARK: Suite Hooks 26 | 27 | /** 28 | A closure executed before any examples are run. 29 | */ 30 | public typealias BeforeSuiteClosure = () -> Void 31 | 32 | /** 33 | A closure executed after all examples have finished running. 34 | */ 35 | public typealias AfterSuiteClosure = BeforeSuiteClosure 36 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/ExampleHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after each example. 3 | */ 4 | final internal class ExampleHooks { 5 | internal var befores: [BeforeExampleWithMetadataClosure] = [] 6 | internal var afters: [AfterExampleWithMetadataClosure] = [] 7 | internal var phase: HooksPhase = .nothingExecuted 8 | 9 | internal func appendBefore(_ closure: @escaping BeforeExampleWithMetadataClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendBefore(_ closure: @escaping BeforeExampleClosure) { 14 | befores.append { (_: ExampleMetadata) in closure() } 15 | } 16 | 17 | internal func appendAfter(_ closure: @escaping AfterExampleWithMetadataClosure) { 18 | afters.append(closure) 19 | } 20 | 21 | internal func appendAfter(_ closure: @escaping AfterExampleClosure) { 22 | afters.append { (_: ExampleMetadata) in closure() } 23 | } 24 | 25 | internal func executeBefores(_ exampleMetadata: ExampleMetadata) { 26 | phase = .beforesExecuting 27 | for before in befores { 28 | before(exampleMetadata) 29 | } 30 | 31 | phase = .beforesFinished 32 | } 33 | 34 | internal func executeAfters(_ exampleMetadata: ExampleMetadata) { 35 | phase = .aftersExecuting 36 | for after in afters { 37 | after(exampleMetadata) 38 | } 39 | 40 | phase = .aftersFinished 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/HooksPhase.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A description of the execution cycle of the current example with 3 | respect to the hooks of that example. 4 | */ 5 | internal enum HooksPhase { 6 | case nothingExecuted 7 | case beforesExecuting 8 | case beforesFinished 9 | case aftersExecuting 10 | case aftersFinished 11 | } 12 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/SuiteHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after all examples. 3 | */ 4 | final internal class SuiteHooks { 5 | internal var befores: [BeforeSuiteClosure] = [] 6 | internal var afters: [AfterSuiteClosure] = [] 7 | internal var phase: HooksPhase = .nothingExecuted 8 | 9 | internal func appendBefore(_ closure: @escaping BeforeSuiteClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendAfter(_ closure: @escaping AfterSuiteClosure) { 14 | afters.append(closure) 15 | } 16 | 17 | internal func executeBefores() { 18 | phase = .beforesExecuting 19 | for before in befores { 20 | before() 21 | } 22 | phase = .beforesFinished 23 | } 24 | 25 | internal func executeAfters() { 26 | phase = .aftersExecuting 27 | for after in afters { 28 | after() 29 | } 30 | phase = .aftersFinished 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/NSBundle+CurrentTestBundle.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import Foundation 4 | 5 | extension Bundle { 6 | 7 | /** 8 | Locates the first bundle with a '.xctest' file extension. 9 | */ 10 | internal static var currentTestBundle: Bundle? { 11 | return allBundles.first { $0.bundlePath.hasSuffix(".xctest") } 12 | } 13 | 14 | /** 15 | Return the module name of the bundle. 16 | Uses the bundle filename and transform it to match Xcode's transformation. 17 | Module name has to be a valid "C99 extended identifier". 18 | */ 19 | internal var moduleName: String { 20 | let fileName = bundleURL.fileName as NSString 21 | return fileName.c99ExtendedIdentifier 22 | } 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/NSString+C99ExtendedIdentifier.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | import Foundation 3 | 4 | public extension NSString { 5 | 6 | private static var invalidCharacters: CharacterSet = { 7 | var invalidCharacters = CharacterSet() 8 | 9 | let invalidCharacterSets: [CharacterSet] = [ 10 | .whitespacesAndNewlines, 11 | .illegalCharacters, 12 | .controlCharacters, 13 | .punctuationCharacters, 14 | .nonBaseCharacters, 15 | .symbols, 16 | ] 17 | 18 | for invalidSet in invalidCharacterSets { 19 | invalidCharacters.formUnion(invalidSet) 20 | } 21 | 22 | return invalidCharacters 23 | }() 24 | 25 | @objc(qck_c99ExtendedIdentifier) 26 | var c99ExtendedIdentifier: String { 27 | let validComponents = components(separatedBy: NSString.invalidCharacters) 28 | let result = validComponents.joined(separator: "_") 29 | 30 | return result.isEmpty ? "_" : result 31 | } 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | import Foundation 3 | 4 | /** 5 | Responsible for building a "Selected tests" suite. This corresponds to a single 6 | spec, and all its examples. 7 | */ 8 | internal class QuickSelectedTestSuiteBuilder: QuickTestSuiteBuilder { 9 | 10 | /** 11 | The test spec class to run. 12 | */ 13 | let testCaseClass: AnyClass! 14 | 15 | /** 16 | For Objective-C classes, returns the class name. For Swift classes without, 17 | an explicit Objective-C name, returns a module-namespaced class name 18 | (e.g., "FooTests.FooSpec"). 19 | */ 20 | var testSuiteClassName: String { 21 | return NSStringFromClass(testCaseClass) 22 | } 23 | 24 | /** 25 | Given a test case name: 26 | 27 | FooSpec/testFoo 28 | 29 | Optionally constructs a test suite builder for the named test case class 30 | in the running test bundle. 31 | 32 | If no test bundle can be found, or the test case class can't be found, 33 | initialization fails and returns `nil`. 34 | */ 35 | init?(forTestCaseWithName name: String) { 36 | guard let testCaseClass = testCaseClassForTestCaseWithName(name) else { 37 | self.testCaseClass = nil 38 | return nil 39 | } 40 | 41 | self.testCaseClass = testCaseClass 42 | } 43 | 44 | /** 45 | Returns a `QuickTestSuite` that runs the associated test case class. 46 | */ 47 | func buildTestSuite() -> QuickTestSuite { 48 | return QuickTestSuite(forTestCaseClass: testCaseClass) 49 | } 50 | 51 | } 52 | 53 | /** 54 | Searches `Bundle.allBundles()` for an xctest bundle, then looks up the named 55 | test case class in that bundle. 56 | 57 | Returns `nil` if a bundle or test case class cannot be found. 58 | */ 59 | private func testCaseClassForTestCaseWithName(_ name: String) -> AnyClass? { 60 | func extractClassName(_ name: String) -> String? { 61 | return name.components(separatedBy: "/").first 62 | } 63 | 64 | guard let className = extractClassName(name) else { return nil } 65 | guard let bundle = Bundle.currentTestBundle else { return nil } 66 | 67 | if let testCaseClass = bundle.classNamed(className) { return testCaseClass } 68 | 69 | let moduleName = bundle.moduleName 70 | 71 | return NSClassFromString("\(moduleName).\(className)") 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/QuickTestSuite.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import XCTest 4 | 5 | /** 6 | This protocol defines the role of an object that builds test suites. 7 | */ 8 | internal protocol QuickTestSuiteBuilder { 9 | 10 | /** 11 | Construct a `QuickTestSuite` instance with the appropriate test cases added as tests. 12 | 13 | Subsequent calls to this method should return equivalent test suites. 14 | */ 15 | func buildTestSuite() -> QuickTestSuite 16 | 17 | } 18 | 19 | /** 20 | A base class for a class cluster of Quick test suites, that should correctly 21 | build dynamic test suites for XCTest to execute. 22 | */ 23 | public class QuickTestSuite: XCTestSuite { 24 | 25 | private static var builtTestSuites: Set = Set() 26 | 27 | /** 28 | Construct a test suite for a specific, selected subset of test cases (rather 29 | than the default, which as all test cases). 30 | 31 | If this method is called multiple times for the same test case class, e.g.. 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | 36 | It is expected that the first call should return a valid test suite, and 37 | all subsequent calls should return `nil`. 38 | */ 39 | public static func selectedTestSuite(forTestCaseWithName name: String) -> QuickTestSuite? { 40 | guard let builder = QuickSelectedTestSuiteBuilder(forTestCaseWithName: name) else { return nil } 41 | 42 | if builtTestSuites.contains(builder.testSuiteClassName) { 43 | return nil 44 | } else { 45 | builtTestSuites.insert(builder.testSuiteClassName) 46 | return builder.buildTestSuite() 47 | } 48 | } 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/URL+FileName.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension URL { 4 | 5 | /** 6 | Returns the path file name without file extension. 7 | */ 8 | var fileName: String { 9 | return self.deletingPathExtension().lastPathComponent 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Configuration/QuickConfiguration.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Configuration; 4 | 5 | /** 6 | Subclass QuickConfiguration and override the +[QuickConfiguration configure:] 7 | method in order to configure how Quick behaves when running specs, or to define 8 | shared examples that are used across spec files. 9 | */ 10 | @interface QuickConfiguration : NSObject 11 | 12 | /** 13 | This method is executed on each subclass of this class before Quick runs 14 | any examples. You may override this method on as many subclasses as you like, but 15 | there is no guarantee as to the order in which these methods are executed. 16 | 17 | You can override this method in order to: 18 | 19 | 1. Configure how Quick behaves, by modifying properties on the Configuration object. 20 | Setting the same properties in several methods has undefined behavior. 21 | 22 | 2. Define shared examples using `sharedExamples`. 23 | 24 | @param configuration A mutable object that is used to configure how Quick behaves on 25 | a framework level. For details on all the options, see the 26 | documentation in Configuration.swift. 27 | */ 28 | + (void)configure:(Configuration *)configuration; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Configuration/QuickConfiguration.m: -------------------------------------------------------------------------------- 1 | #import "QuickConfiguration.h" 2 | #import "World.h" 3 | #import 4 | 5 | typedef void (^QCKClassEnumerationBlock)(Class klass); 6 | 7 | /** 8 | Finds all direct subclasses of the given class and passes them to the block provided. 9 | The classes are iterated over in the order that objc_getClassList returns them. 10 | 11 | @param klass The base class to find subclasses of. 12 | @param block A block that takes a Class. This block will be executed once for each subclass of klass. 13 | */ 14 | void qck_enumerateSubclasses(Class klass, QCKClassEnumerationBlock block) { 15 | Class *classes = NULL; 16 | int classesCount = objc_getClassList(NULL, 0); 17 | 18 | if (classesCount > 0) { 19 | classes = (Class *)calloc(sizeof(Class), classesCount); 20 | classesCount = objc_getClassList(classes, classesCount); 21 | 22 | Class subclass, superclass; 23 | for(int i = 0; i < classesCount; i++) { 24 | subclass = classes[i]; 25 | superclass = class_getSuperclass(subclass); 26 | if (superclass == klass && block) { 27 | block(subclass); 28 | } 29 | } 30 | 31 | free(classes); 32 | } 33 | } 34 | 35 | @implementation QuickConfiguration 36 | 37 | #pragma mark - Object Lifecycle 38 | 39 | /** 40 | QuickConfiguration is not meant to be instantiated; it merely provides a hook 41 | for users to configure how Quick behaves. Raise an exception if an instance of 42 | QuickConfiguration is created. 43 | */ 44 | - (instancetype)init { 45 | NSString *className = NSStringFromClass([self class]); 46 | NSString *selectorName = NSStringFromSelector(@selector(configure:)); 47 | [NSException raise:NSInternalInconsistencyException 48 | format:@"%@ is not meant to be instantiated; " 49 | @"subclass %@ and override %@ to configure Quick.", 50 | className, className, selectorName]; 51 | return nil; 52 | } 53 | 54 | #pragma mark - NSObject Overrides 55 | 56 | /** 57 | Hook into when QuickConfiguration is initialized in the runtime in order to 58 | call +[QuickConfiguration configure:] on each of its subclasses. 59 | */ 60 | + (void)initialize { 61 | // Only enumerate over the subclasses of QuickConfiguration, not any of its subclasses. 62 | if ([self class] == [QuickConfiguration class]) { 63 | 64 | // Only enumerate over subclasses once, even if +[QuickConfiguration initialize] 65 | // were to be called several times. This is necessary because +[QuickSpec initialize] 66 | // manually calls +[QuickConfiguration initialize]. 67 | static dispatch_once_t onceToken; 68 | dispatch_once(&onceToken, ^{ 69 | qck_enumerateSubclasses([QuickConfiguration class], ^(__unsafe_unretained Class klass) { 70 | [[World sharedWorld] configure:^(Configuration *configuration) { 71 | [klass configure:configuration]; 72 | }]; 73 | }); 74 | [[World sharedWorld] finalizeConfiguration]; 75 | }); 76 | } 77 | } 78 | 79 | #pragma mark - Public Interface 80 | 81 | + (void)configure:(Configuration *)configuration { } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/DSL/QCKDSL.m: -------------------------------------------------------------------------------- 1 | #import "QCKDSL.h" 2 | #import "World.h" 3 | #import "World+DSL.h" 4 | 5 | void qck_beforeSuite(QCKDSLEmptyBlock closure) { 6 | [[World sharedWorld] beforeSuite:closure]; 7 | } 8 | 9 | void qck_afterSuite(QCKDSLEmptyBlock closure) { 10 | [[World sharedWorld] afterSuite:closure]; 11 | } 12 | 13 | void qck_sharedExamples(NSString *name, QCKDSLSharedExampleBlock closure) { 14 | [[World sharedWorld] sharedExamples:name closure:closure]; 15 | } 16 | 17 | void qck_describe(NSString *description, QCKDSLEmptyBlock closure) { 18 | [[World sharedWorld] describe:description flags:@{} closure:closure]; 19 | } 20 | 21 | void qck_context(NSString *description, QCKDSLEmptyBlock closure) { 22 | qck_describe(description, closure); 23 | } 24 | 25 | void qck_beforeEach(QCKDSLEmptyBlock closure) { 26 | [[World sharedWorld] beforeEach:closure]; 27 | } 28 | 29 | void qck_beforeEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 30 | [[World sharedWorld] beforeEachWithMetadata:closure]; 31 | } 32 | 33 | void qck_afterEach(QCKDSLEmptyBlock closure) { 34 | [[World sharedWorld] afterEach:closure]; 35 | } 36 | 37 | void qck_afterEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 38 | [[World sharedWorld] afterEachWithMetadata:closure]; 39 | } 40 | 41 | QCKItBlock qck_it_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 42 | return ^(NSString *description, QCKDSLEmptyBlock closure) { 43 | [[World sharedWorld] itWithDescription:description 44 | flags:flags 45 | file:file 46 | line:line 47 | closure:closure]; 48 | }; 49 | } 50 | 51 | QCKItBehavesLikeBlock qck_itBehavesLike_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 52 | return ^(NSString *name, QCKDSLSharedExampleContext context) { 53 | [[World sharedWorld] itBehavesLikeSharedExampleNamed:name 54 | sharedExampleContext:context 55 | flags:flags 56 | file:file 57 | line:line]; 58 | }; 59 | } 60 | 61 | void qck_pending(NSString *description, QCKDSLEmptyBlock closure) { 62 | [[World sharedWorld] pending:description closure:closure]; 63 | } 64 | 65 | void qck_xdescribe(NSString *description, QCKDSLEmptyBlock closure) { 66 | [[World sharedWorld] xdescribe:description flags:@{} closure:closure]; 67 | } 68 | 69 | void qck_xcontext(NSString *description, QCKDSLEmptyBlock closure) { 70 | qck_xdescribe(description, closure); 71 | } 72 | 73 | void qck_fdescribe(NSString *description, QCKDSLEmptyBlock closure) { 74 | [[World sharedWorld] fdescribe:description flags:@{} closure:closure]; 75 | } 76 | 77 | void qck_fcontext(NSString *description, QCKDSLEmptyBlock closure) { 78 | qck_fdescribe(description, closure); 79 | } 80 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/DSL/World+DSL.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface World (SWIFT_EXTENSION(Quick)) 4 | - (void)beforeSuite:(void (^ __nonnull)(void))closure; 5 | - (void)afterSuite:(void (^ __nonnull)(void))closure; 6 | - (void)sharedExamples:(NSString * __nonnull)name closure:(void (^ __nonnull)(NSDictionary * __nonnull (^ __nonnull)(void)))closure; 7 | - (void)describe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 8 | - (void)context:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 9 | - (void)fdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 10 | - (void)xdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 11 | - (void)beforeEach:(void (^ __nonnull)(void))closure; 12 | - (void)beforeEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 13 | - (void)afterEach:(void (^ __nonnull)(void))closure; 14 | - (void)afterEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 15 | - (void)itWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 16 | - (void)fitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 17 | - (void)xitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 18 | - (void)itBehavesLikeSharedExampleNamed:(NSString * __nonnull)name sharedExampleContext:(NSDictionary * __nonnull (^ __nonnull)(void))sharedExampleContext flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line; 19 | - (void)pending:(NSString * __nonnull)description closure:(void (^ __nonnull)(void))closure; 20 | @end 21 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Quick.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for Quick. 4 | FOUNDATION_EXPORT double QuickVersionNumber; 5 | 6 | //! Project version string for Quick. 7 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 8 | 9 | #import "QuickSpec.h" 10 | #import "QCKDSL.h" 11 | #import "QuickConfiguration.h" 12 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/QuickSpec.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec is a base class all specs written in Quick inherit from. 5 | They need to inherit from QuickSpec, a subclass of XCTestCase, in 6 | order to be discovered by the XCTest framework. 7 | 8 | XCTest automatically compiles a list of XCTestCase subclasses included 9 | in the test target. It iterates over each class in that list, and creates 10 | a new instance of that class for each test method. It then creates an 11 | "invocation" to execute that test method. The invocation is an instance of 12 | NSInvocation, which represents a single message send in Objective-C. 13 | The invocation is set on the XCTestCase instance, and the test is run. 14 | 15 | Most of the code in QuickSpec is dedicated to hooking into XCTest events. 16 | First, when the spec is first loaded and before it is sent any messages, 17 | the +[NSObject initialize] method is called. QuickSpec overrides this method 18 | to call +[QuickSpec spec]. This builds the example group stacks and 19 | registers them with Quick.World, a global register of examples. 20 | 21 | Then, XCTest queries QuickSpec for a list of test methods. Normally, XCTest 22 | automatically finds all methods whose selectors begin with the string "test". 23 | However, QuickSpec overrides this default behavior by implementing the 24 | +[XCTestCase testInvocations] method. This method iterates over each example 25 | registered in Quick.World, defines a new method for that example, and 26 | returns an invocation to call that method to XCTest. Those invocations are 27 | the tests that are run by XCTest. Their selector names are displayed in 28 | the Xcode test navigation bar. 29 | */ 30 | @interface QuickSpec : XCTestCase 31 | 32 | /** 33 | Override this method in your spec to define a set of example groups 34 | and examples. 35 | 36 | @code 37 | override func spec() { 38 | describe("winter") { 39 | it("is coming") { 40 | // ... 41 | } 42 | } 43 | } 44 | @endcode 45 | 46 | See DSL.swift for more information on what syntax is available. 47 | */ 48 | - (void)spec; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/World.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ExampleGroup; 4 | @class ExampleMetadata; 5 | 6 | SWIFT_CLASS("_TtC5Quick5World") 7 | @interface World 8 | 9 | @property (nonatomic) ExampleGroup * __nullable currentExampleGroup; 10 | @property (nonatomic) ExampleMetadata * __nullable currentExampleMetadata; 11 | @property (nonatomic) BOOL isRunningAdditionalSuites; 12 | + (World * __nonnull)sharedWorld; 13 | - (void)configure:(void (^ __nonnull)(Configuration * __nonnull))closure; 14 | - (void)finalizeConfiguration; 15 | - (ExampleGroup * __nonnull)rootExampleGroupForSpecClass:(Class __nonnull)cls; 16 | - (NSArray * __nonnull)examplesForSpecClass:(Class __nonnull)specClass; 17 | - (void)performWithCurrentExampleGroup:(ExampleGroup * __nonnull)group closure:(void (^ __nonnull)(void))closure; 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/XCTestSuite+QuickTestSuiteBuilder.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface XCTestSuite (QuickTestSuiteBuilder) 6 | @end 7 | 8 | @implementation XCTestSuite (QuickTestSuiteBuilder) 9 | 10 | /** 11 | In order to ensure we can correctly build dynamic test suites, we need to 12 | replace some of the default test suite constructors. 13 | */ 14 | + (void)load { 15 | Method testCaseWithName = class_getClassMethod(self, @selector(testSuiteForTestCaseWithName:)); 16 | Method hooked_testCaseWithName = class_getClassMethod(self, @selector(qck_hooked_testSuiteForTestCaseWithName:)); 17 | method_exchangeImplementations(testCaseWithName, hooked_testCaseWithName); 18 | } 19 | 20 | /** 21 | The `+testSuiteForTestCaseWithName:` method is called when a specific test case 22 | class is run from the Xcode test navigator. If the built test suite is `nil`, 23 | Xcode will not run any tests for that test case. 24 | 25 | Given if the following test case class is run from the Xcode test navigator: 26 | 27 | FooSpec 28 | testFoo 29 | testBar 30 | 31 | XCTest will invoke this once per test case, with test case names following this format: 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | */ 36 | + (nullable instancetype)qck_hooked_testSuiteForTestCaseWithName:(nonnull NSString *)name { 37 | return [QuickTestSuite selectedTestSuiteForTestCaseWithName:name]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickSpecBase/QuickSpecBase.m: -------------------------------------------------------------------------------- 1 | #import "QuickSpecBase.h" 2 | 3 | #pragma mark - _QuickSelectorWrapper 4 | 5 | @interface _QuickSelectorWrapper () 6 | @property(nonatomic, assign) SEL selector; 7 | @end 8 | 9 | @implementation _QuickSelectorWrapper 10 | 11 | - (instancetype)initWithSelector:(SEL)selector { 12 | self = [super init]; 13 | _selector = selector; 14 | return self; 15 | } 16 | 17 | @end 18 | 19 | 20 | #pragma mark - _QuickSpecBase 21 | 22 | @implementation _QuickSpecBase 23 | 24 | - (instancetype)init { 25 | self = [super initWithInvocation: nil]; 26 | return self; 27 | } 28 | 29 | /** 30 | Invocations for each test method in the test case. QuickSpec overrides this method to define a 31 | new method for each example defined in +[QuickSpec spec]. 32 | 33 | @return An array of invocations that execute the newly defined example methods. 34 | */ 35 | + (NSArray *)testInvocations { 36 | NSArray<_QuickSelectorWrapper *> *wrappers = [self _qck_testMethodSelectors]; 37 | NSMutableArray *invocations = [NSMutableArray arrayWithCapacity:wrappers.count]; 38 | 39 | for (_QuickSelectorWrapper *wrapper in wrappers) { 40 | SEL selector = wrapper.selector; 41 | NSMethodSignature *signature = [self instanceMethodSignatureForSelector:selector]; 42 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 43 | invocation.selector = selector; 44 | 45 | [invocations addObject:invocation]; 46 | } 47 | 48 | return invocations; 49 | } 50 | 51 | + (NSArray<_QuickSelectorWrapper *> *)_qck_testMethodSelectors { 52 | return @[]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickSpecBase/include/QuickSpecBase.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | @import XCTest; 3 | 4 | @interface _QuickSelectorWrapper : NSObject 5 | - (instancetype)initWithSelector:(SEL)selector; 6 | @end 7 | 8 | @interface _QuickSpecBase : XCTestCase 9 | + (NSArray<_QuickSelectorWrapper *> *)_qck_testMethodSelectors; 10 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 11 | @end 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.7 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/MachineLearningKit-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MachineLearningKit : NSObject 3 | @end 4 | @implementation PodsDummy_MachineLearningKit 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/MachineLearningKit-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/MachineLearningKit-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "MLKit.h" 14 | 15 | FOUNDATION_EXPORT double MachineLearningKitVersionNumber; 16 | FOUNDATION_EXPORT const unsigned char MachineLearningKitVersionString[]; 17 | 18 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/MachineLearningKit.modulemap: -------------------------------------------------------------------------------- 1 | framework module MachineLearningKit { 2 | umbrella header "MachineLearningKit-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MachineLearningKit/MachineLearningKit.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Upsurge" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | OTHER_LDFLAGS = -framework "MapKit" -framework "UIKit" 6 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 7 | PODS_BUILD_DIR = $BUILD_DIR 8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_ROOT = ${SRCROOT} 10 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 6.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Nimble : NSObject 3 | @end 4 | @implementation PodsDummy_Nimble 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "CwlCatchException.h" 14 | #import "CwlCatchBadInstruction.h" 15 | #import "mach_excServer.h" 16 | #import "Nimble.h" 17 | #import "DSL.h" 18 | #import "NMBExceptionCapture.h" 19 | #import "NMBStringify.h" 20 | 21 | FOUNDATION_EXPORT double NimbleVersionNumber; 22 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 23 | 24 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble.modulemap: -------------------------------------------------------------------------------- 1 | framework module Nimble { 2 | umbrella header "Nimble-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Nimble 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -weak-lswiftXCTest -weak_framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT} 11 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Nimble 12 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 13 | SKIP_INSTALL = YES 14 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MachineLearningKit 5 | 6 | Copyright (c) 2017 Guled Ahmed 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | ## Upsurge 28 | 29 | Copyright (c) 2014 Mattt Thompson (http://mattt.me/) 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | 49 | Generated by CocoaPods - https://cocoapods.org 50 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2017 Guled Ahmed <guledahmed777@gmail.com> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | MachineLearningKit 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright (c) 2014 Mattt Thompson (http://mattt.me/) 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 64 | THE SOFTWARE. 65 | 66 | License 67 | MIT 68 | Title 69 | Upsurge 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - https://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_MLKit_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_MLKit_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_MLKit_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_MLKit_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit" "$PODS_CONFIGURATION_BUILD_DIR/Upsurge" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit/MachineLearningKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Upsurge/Upsurge.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "MachineLearningKit" -framework "Upsurge" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_MLKit_Example { 2 | umbrella header "Pods-MLKit_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Example/Pods-MLKit_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit" "$PODS_CONFIGURATION_BUILD_DIR/Upsurge" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit/MachineLearningKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Upsurge/Upsurge.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "MachineLearningKit" -framework "Upsurge" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Pods-MLKit_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_MLKit_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_MLKit_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Pods-MLKit_Tests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_MLKit_TestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_MLKit_TestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Pods-MLKit_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) $(PLATFORM_DIR)/Developer/Library/Frameworks "$PODS_CONFIGURATION_BUILD_DIR/Nimble" "$PODS_CONFIGURATION_BUILD_DIR/Quick" "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit" "$PODS_CONFIGURATION_BUILD_DIR/Upsurge" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit/MachineLearningKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Upsurge/Upsurge.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Pods-MLKit_Tests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_MLKit_Tests { 2 | umbrella header "Pods-MLKit_Tests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-MLKit_Tests/Pods-MLKit_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) $(PLATFORM_DIR)/Developer/Library/Frameworks "$PODS_CONFIGURATION_BUILD_DIR/Nimble" "$PODS_CONFIGURATION_BUILD_DIR/Quick" "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit" "$PODS_CONFIGURATION_BUILD_DIR/Upsurge" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MachineLearningKit/MachineLearningKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Upsurge/Upsurge.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Quick : NSObject 3 | @end 4 | @implementation PodsDummy_Quick 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "QuickConfiguration.h" 14 | #import "QCKDSL.h" 15 | #import "Quick.h" 16 | #import "QuickSpec.h" 17 | 18 | FOUNDATION_EXPORT double QuickVersionNumber; 19 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 20 | 21 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick.modulemap: -------------------------------------------------------------------------------- 1 | framework module Quick { 2 | umbrella header "Quick-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Quick 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT} 11 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Quick 12 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 13 | SKIP_INSTALL = YES 14 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.8.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Upsurge-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Upsurge : NSObject 3 | @end 4 | @implementation PodsDummy_Upsurge 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Upsurge-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Upsurge-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double UpsurgeVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char UpsurgeVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Upsurge.modulemap: -------------------------------------------------------------------------------- 1 | framework module Upsurge { 2 | umbrella header "Upsurge-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Upsurge/Upsurge.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Upsurge 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_LDFLAGS = -framework "Accelerate" 5 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Upsurge 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /Example/Pods/Upsurge/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Mattt Thompson (http://mattt.me/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/Pods/Upsurge/Source/2D/QuadraticType.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 Venture Media Labs. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | public enum QuadraticArrangement { 22 | /// Consecutive elements in a rows are contiguous in memory 23 | case rowMajor 24 | 25 | /// Consecutive elements in a column are contiguous in memory 26 | case columnMajor 27 | } 28 | 29 | public protocol QuadraticType: TensorType { 30 | associatedtype Element 31 | 32 | /// The arrangement of rows and columns 33 | var arrangement: QuadraticArrangement { get } 34 | 35 | /// The number of rows 36 | var rows: Int { get } 37 | 38 | /// The number of columns 39 | var columns: Int { get } 40 | 41 | /// The step size between major-axis elements 42 | var stride: Int { get } 43 | 44 | /// The step of the base elements 45 | var step: Int { get } 46 | } 47 | 48 | public extension QuadraticType { 49 | /// The number of valid element in the memory block, taking into account the step size. 50 | public var count: Int { 51 | return rows * columns 52 | } 53 | 54 | public var dimensions: [Int] { 55 | if arrangement == .rowMajor { 56 | return [rows, columns] 57 | } else { 58 | return [columns, rows] 59 | } 60 | } 61 | } 62 | 63 | public protocol MutableQuadraticType: QuadraticType, MutableTensorType { 64 | } 65 | -------------------------------------------------------------------------------- /Example/Pods/Upsurge/Source/Types/Interval.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 Venture Media Labs. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | public protocol IntervalType { 22 | var start: Int? { get } 23 | var end: Int? { get } 24 | } 25 | 26 | public enum Interval: IntervalType, ExpressibleByIntegerLiteral { 27 | case all 28 | case range(CountableClosedRange) 29 | 30 | public init(range: CountableClosedRange) { 31 | self = Interval.range(range) 32 | } 33 | 34 | public init(integerLiteral value: Int) { 35 | self = Interval.range(value...value) 36 | } 37 | 38 | public var start: Int? { 39 | switch self { 40 | case .all: return nil 41 | case .range(let range): return range.lowerBound 42 | } 43 | } 44 | 45 | public var end: Int? { 46 | switch self { 47 | case .all: return nil 48 | case .range(let range): return range.upperBound + 1 49 | } 50 | } 51 | } 52 | 53 | extension CountableRange: IntervalType { 54 | public var start: Int? { 55 | return unsafeBitCast(lowerBound, to: Int.self) 56 | } 57 | 58 | public var end: Int? { 59 | return unsafeBitCast(upperBound, to: Int.self) 60 | } 61 | } 62 | 63 | extension CountableClosedRange: IntervalType { 64 | public var start: Int? { 65 | return unsafeBitCast(lowerBound, to: Int.self) 66 | } 67 | 68 | public var end: Int? { 69 | return unsafeBitCast(upperBound, to: Int.self) + 1 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Example/Pods/Upsurge/Source/Types/Real.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 Venture Media Labs. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | /// A real number 22 | public protocol Real: FloatingPoint, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, Comparable, CustomStringConvertible, Equatable, Hashable {} 23 | 24 | extension Double: Real {} 25 | extension Float: Real {} 26 | -------------------------------------------------------------------------------- /Example/Pods/Upsurge/Source/Types/Value.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 Venture Media Labs. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | import Foundation 22 | 23 | public protocol Value: Comparable, CustomStringConvertible, Equatable, Hashable {} 24 | 25 | extension Double: Value {} 26 | extension Float: Value {} 27 | extension Int: Value {} 28 | -------------------------------------------------------------------------------- /Example/Tests/CSVReader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CSVReader.swift 3 | // 4 | // Copyright (c) 2016 Peter Entwistle 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | import Foundation 26 | 27 | open class CSVReader { 28 | 29 | fileprivate var _numberOfColumns: Int = 0 30 | fileprivate var _numberOfRows: Int = 0 31 | fileprivate var _delimiter: String 32 | fileprivate var _lines = [String]() 33 | open var headers = [String]() 34 | open var columns = [String: [String]]() 35 | open var rows = [[String: String]]() 36 | 37 | open var numberOfColumns: Int { 38 | get { 39 | return _numberOfColumns 40 | } 41 | } 42 | 43 | open var numberOfRows: Int { 44 | get { 45 | return _numberOfRows 46 | } 47 | } 48 | 49 | public init(with: String, delimiter: String) { 50 | let csv = with.replacingOccurrences(of: "\r", with: "", options: NSString.CompareOptions.literal, range: nil) 51 | _delimiter = delimiter 52 | processLines(csv) 53 | _numberOfColumns = _lines[0].components(separatedBy: _delimiter).count 54 | _numberOfRows = _lines.count - 1 55 | headers = _lines[0].components(separatedBy: _delimiter) 56 | setRows() 57 | setColumns() 58 | } 59 | 60 | public convenience init(with: String) { 61 | self.init(with: with, delimiter: ",") 62 | } 63 | 64 | fileprivate func processLines(_ csv: String) { 65 | _lines = csv.components(separatedBy: "\n") 66 | // Remove blank lines 67 | var i = 0 68 | for line in _lines { 69 | if line.isEmpty { 70 | _lines.remove(at: i) 71 | i -= 1 72 | } 73 | i += 1 74 | } 75 | } 76 | 77 | fileprivate func setRows() { 78 | var rows = [[String: String]]() 79 | for i in 1..._numberOfRows { 80 | var row = [String: String]() 81 | let vals = _lines[i].components(separatedBy: _delimiter) 82 | var i = 0 83 | for header in headers { 84 | row[header] = vals[i] 85 | i+=1 86 | } 87 | rows.append(row) 88 | } 89 | self.rows = rows 90 | } 91 | 92 | fileprivate func setColumns() { 93 | var columns = [String: [String]]() 94 | for header in headers { 95 | var colValue = [String]() 96 | for row in rows { 97 | colValue.append(row[header]!) 98 | } 99 | columns[header] = colValue 100 | } 101 | self.columns = columns 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/LassoRegressionSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LassoRegressionSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class LassorRegressionSpec: QuickSpec { 16 | 17 | var weights: Matrix! 18 | let estimatedFinalWeights: ValueArray = [21624964.0, 63157280.0, 0.0] 19 | 20 | override func spec() { 21 | 22 | beforeSuite { 23 | // Obtain data from csv file 24 | let path = Bundle(for: LassorRegressionSpec.self).path(forResource: "kc_house_data", ofType: "csv") 25 | let csvUrl = NSURL(fileURLWithPath: path!) 26 | let file = try! String(contentsOf: csvUrl as URL, encoding: String.Encoding.utf8) 27 | let data = CSVReader(with: file) 28 | 29 | // Setup the features we need and convert them to floats if necessary 30 | let training_data_string = data.columns["sqft_living"]! 31 | let training_data_2_string = data.columns["bedrooms"]! 32 | 33 | // Features 34 | let feature1 = training_data_string.map { Float($0)!} 35 | let feature2 = training_data_2_string.map {Float($0)!} 36 | 37 | // Output 38 | let output_as_string = data.columns["price"]! 39 | let output_data = output_as_string.map { Float($0)! } 40 | 41 | // Setup Model 42 | let lassoModel = LassoRegression() 43 | 44 | // Set Initial Weights 45 | let initial_weights = Matrix(rows: 3, columns: 1, elements: [0.0, 0.0, 0.0]) 46 | 47 | // Params 48 | let l1_penalty = Float(1e7) 49 | let tolerance = Float(3.0) 50 | 51 | self.weights = try! lassoModel.train([feature1, feature2], output: output_data, initialWeights: initial_weights, l1Penalty: l1_penalty, tolerance: tolerance) 52 | 53 | } 54 | 55 | it("Should produce adequate weights.") { 56 | 57 | expect(self.weights.elements[0]).to(beCloseTo(self.estimatedFinalWeights[0], within: 0.1)) 58 | expect(self.weights.elements[1]).to(beCloseTo(self.estimatedFinalWeights[1], within: 0.1)) 59 | expect(self.weights.elements[2]).to(beCloseTo(self.estimatedFinalWeights[2], within: 0.1)) 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Example/Tests/MLDataManagerSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MLDataManagerSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class MLDataManagerSpec: QuickSpec { 16 | 17 | let data: [Float] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 18 | let nonFloat: [String] = ["1", "2", "3"] 19 | let output: [Float] = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5] 20 | 21 | override func spec() { 22 | 23 | it("Should be able to compute mean.") { 24 | 25 | let mean = MLDataManager.mean(self.data) 26 | let actualMean = Float(5.5) 27 | expect(mean).to(equal(actualMean)) 28 | } 29 | 30 | it("Should be able to convert training data to matrix form.") { 31 | 32 | let feature: [Float] = [1.0, 1.0] 33 | let output: [Float] = [1.0, 1.0] 34 | let convertedData = MLDataManager.dataToMatrix([feature], output: output) 35 | 36 | let matrix = convertedData.0 37 | let outputArr = convertedData.1 38 | 39 | let actualMatrix = Matrix(rows: 2, columns: 2, elements: [1.0, 1.0, 1.0, 1.0]) 40 | let actualOutput: ValueArray = [1.0, 1.0] 41 | 42 | expect(matrix.elements).to(equal(actualMatrix.elements)) 43 | expect(outputArr).to(equal(actualOutput)) 44 | } 45 | 46 | it("Should be able to convert String data to Float data.") { 47 | 48 | let floatData = try! MLDataManager.convertMyDataToFloat(self.nonFloat) 49 | let actualFloats: [Float] = [1.0, 2.0, 3.0] 50 | 51 | expect(floatData).to(equal(actualFloats)) 52 | } 53 | 54 | it("Should be able to split data successfully.") { 55 | 56 | let fakeData: [Float] = [1, 2, 3, 4, 5] 57 | // Cut the data in half 58 | let split = try! MLDataManager.splitData(fakeData, fraction: 0.5) 59 | 60 | let actualFirstHalf: [Float] = [1.0, 2.0] 61 | let actualSecondHalf: [Float] = [3.0, 4.0, 5.0] 62 | 63 | expect(split.0).to(equal(actualFirstHalf)) 64 | expect(split.1).to(equal(actualSecondHalf)) 65 | } 66 | 67 | it("Should be able to convert data to polynomial of degree x.") { 68 | 69 | let fakeData: [Float] = [1, 2, 3, 4, 5] 70 | let polynomialFeatures = try! MLDataManager.convertDataToPolynomialOfDegree(fakeData, degree: 2) 71 | 72 | // First feature is 'fakeData' variable 73 | let secondFeature: [Float] = [1.0, 4.0, 9.0, 16.0, 25.0] 74 | 75 | expect(polynomialFeatures[0]).to(equal(fakeData)) 76 | expect(polynomialFeatures[1]).to(equal(secondFeature)) 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Example/Tests/NeuralNetworkSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NeuralNetworkSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class NeuralNetworkSpec: QuickSpec { 16 | 17 | override func spec() { 18 | 19 | it("Should be able to run a simple AND example. ") { 20 | 21 | 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/Tests/PolynomialRegressionSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PolynomialRegressionSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class PolynomialRegressionSpec: QuickSpec { 16 | 17 | var weights: Matrix! 18 | let estimatedFinalWeights: ValueArray = [-99999.9, 303.321, 1.42297] 19 | var rss: Float! 20 | var quickPrediction: Float! 21 | let estimatedPrediction = Float(257921.0) 22 | 23 | override func spec() { 24 | 25 | beforeSuite { 26 | // Obtain data from csv file 27 | let path = Bundle(for: PolynomialRegressionSpec.self).path(forResource: "kc_house_data", ofType: "csv") 28 | let csvUrl = NSURL(fileURLWithPath: path!) 29 | let file = try! String(contentsOf: csvUrl as URL, encoding: String.Encoding.utf8) 30 | let data = CSVReader(with: file) 31 | 32 | // Setup the features we need and convert them to floats if necessary 33 | let training_data_string = data.columns["sqft_living"]! 34 | let training_data_2_string = data.columns["bedrooms"]! 35 | 36 | // Features 37 | let training_data = training_data_string.map { Float($0)! } 38 | let training_data_2 = training_data_2_string.map { Float($0)! } 39 | 40 | // Output 41 | let output_as_string = data.columns["price"]! 42 | let output_data = output_as_string.map { Float($0)! } 43 | 44 | // Fit the model 45 | let polynomialModel = PolynomialLinearRegression() 46 | 47 | // Setup initial weights 48 | let initial_weights = Matrix(rows: 3, columns: 1, elements: [-100000.0, 1.0, 1.0]) 49 | 50 | // Fit the model and obtain the weights 51 | self.weights = try! polynomialModel.train([training_data, training_data_2], output: output_data, initialWeights: initial_weights, stepSize: Float(4e-12), tolerance: Float(1e9)) 52 | 53 | // Compute RSS 54 | self.rss = try! polynomialModel.RSS([training_data, training_data_2], observation: output_data) 55 | 56 | // Make a prediction 57 | self.quickPrediction = polynomialModel.predict([Float(1.0), Float(1180.0), Float(1.0)], yourWeights: self.weights.elements) 58 | } 59 | 60 | it("Should produce weights equivalent to our estimated weights.") { 61 | 62 | expect(self.weights.elements[0]).to(beCloseTo(self.estimatedFinalWeights[0], within: 0.1)) 63 | expect(self.weights.elements[1]).to(beCloseTo(self.estimatedFinalWeights[1], within: 0.1)) 64 | expect(self.weights.elements[2]).to(beCloseTo(self.estimatedFinalWeights[2], within: 0.1)) 65 | } 66 | 67 | it("Should be able to produce a prediction equivalent to our estimated prediction.") { 68 | 69 | expect(self.quickPrediction).toEventually(beCloseTo(self.estimatedPrediction, within: 1)) 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Example/Tests/RidgeRegressionSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RidgeRegressionSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class RidgeRegressionSpec: QuickSpec { 16 | 17 | let estimatedWeights: ValueArray = [-0.201522, 263.089] 18 | let estimatedPrediction: Float = 310445.062 19 | var weights: Matrix! 20 | var quickPrediction: Float! 21 | 22 | override func spec() { 23 | 24 | beforeSuite { 25 | 26 | // Obtain data from csv file 27 | let path = Bundle(for: RidgeRegressionSpec.self).path(forResource: "kc_house_data", ofType: "csv") 28 | let csvUrl = NSURL(fileURLWithPath: path!) 29 | let file = try! String(contentsOf: csvUrl as URL, encoding: String.Encoding.utf8) 30 | let data = CSVReader(with: file) 31 | 32 | // Setup the features we need and convert them to floats if necessary 33 | let training_data_string = data.columns["sqft_living"]! 34 | // Features 35 | let training_data = training_data_string.map { Float($0)! } 36 | 37 | // Output 38 | let output_as_string = data.columns["price"]! 39 | let output_data = output_as_string.map { Float($0)! } 40 | 41 | // Fit the model 42 | let ridgeModel = RidgeRegression() 43 | 44 | // Setup initial weights 45 | let initial_weights = Matrix(rows: 2, columns: 1, elements: [0.0, 0.0]) 46 | 47 | // Fit the model and obtain the weights 48 | self.weights = try! ridgeModel.train([training_data], output: output_data, initialWeights: initial_weights, stepSize: Float(1e-12), l2Penalty: 0.0, maxIterations: 1000) 49 | 50 | // Make a prediction 51 | self.quickPrediction = ridgeModel.predict([Float(1.0), Float(1.18000000e+03)], yourWeights: self.weights.elements) 52 | 53 | } 54 | 55 | it("Should produce adequate weights.") { 56 | 57 | expect(self.weights.elements[0]).to(beCloseTo(self.estimatedWeights[0], within: 0.1)) 58 | expect(self.weights.elements[1]).to(beCloseTo(self.estimatedWeights[1], within: 0.1)) 59 | } 60 | 61 | it("Should be able to produce a prediction equivalent to our estimated prediction. ") { 62 | 63 | expect(self.quickPrediction).to(equal(self.estimatedPrediction)) 64 | } 65 | 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Example/Tests/SimpleLinearRegressionSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleLinearRegressionSpec.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 3/6/17. 6 | // Copyright © 2017 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Upsurge 11 | import MachineLearningKit 12 | import Quick 13 | import Nimble 14 | 15 | class SimpleLinearRegressionSpec: QuickSpec { 16 | 17 | let dataset: Array = [0, 1, 2, 3, 4] 18 | let output: Array = [1, 3, 7, 13, 21] 19 | let estimatedNonGradientWeights = (Float(5.0), Float(-1.0)) 20 | let estimatedGradientWeights = (Float(4.99797), Float(-0.994207)) 21 | let estimatedPrediction = Float(9.00173) 22 | 23 | override func spec() { 24 | 25 | it("Should produce adequate weights [Non Gradient Method].") { 26 | 27 | let model = SimpleLinearRegression() 28 | 29 | let weights = model.train(self.dataset, output: self.output) 30 | 31 | expect(weights.0).to(beCloseTo(self.estimatedNonGradientWeights.0, within: 0.1)) 32 | expect(weights.1).to(beCloseTo(self.estimatedNonGradientWeights.1, within: 0.1)) 33 | } 34 | 35 | it("Should produce adequate weights [Gradient Method].") { 36 | 37 | let model = SimpleLinearRegression() 38 | 39 | let weights = try! model.train(self.dataset, output: self.output, stepSize: 0.05, tolerance: 0.01) 40 | 41 | expect(weights.0).to(beCloseTo(self.estimatedGradientWeights.0, within: 0.1)) 42 | expect(weights.1).to(beCloseTo(self.estimatedGradientWeights.1, within: 0.1)) 43 | } 44 | 45 | it("Should be able to produce a prediction equivalent to our estimated prediction.") { 46 | 47 | let model = SimpleLinearRegression() 48 | 49 | // First we fit our model 50 | let weights = try! model.train(self.dataset, output: self.output, stepSize: 0.05, tolerance: 0.01) 51 | 52 | // Make one-time prediction 53 | let quickPrediction = model.predict(weights.0, intercept: weights.1, inputValue: 2) 54 | 55 | expect(quickPrediction).to(equal(self.estimatedPrediction)) 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Guled Ahmed 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /MLKit-PlayGround.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /MLKit-PlayGround.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MLKit-PlayGround.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /MLKit/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/MLKit/Assets/.gitkeep -------------------------------------------------------------------------------- /MLKit/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/MLKit/Classes/.gitkeep -------------------------------------------------------------------------------- /MLKit/Classes/ANN/InputDataType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InputDataType.swift 3 | // Pods 4 | // 5 | // Created by Guled on 4/7/17. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | /// Data structure the helps with neural network I/O. 12 | public struct InputDataType { 13 | 14 | /// Array of tuples (x,y) where x is your training data and y is your output data. 15 | var data: [(input: [Float], target: [Float])] 16 | 17 | /// Number of elements in 'data' attribute. 18 | var lengthOfTrainingData: Int { 19 | get { 20 | return data.count 21 | } 22 | } 23 | 24 | public init(data: [(input: [Float], target: [Float])]) { 25 | self.data = data 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MLKit/Classes/CSVReader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CSVReader.swift 3 | // 4 | // Copyright (c) 2016 Peter Entwistle 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | import Foundation 26 | 27 | open class CSVReader { 28 | 29 | fileprivate var _numberOfColumns: Int = 0 30 | fileprivate var _numberOfRows: Int = 0 31 | fileprivate var _delimiter: String 32 | fileprivate var _lines = [String]() 33 | open var headers = [String]() 34 | open var columns = [String: [String]]() 35 | open var rows = [[String: String]]() 36 | 37 | open var numberOfColumns: Int { 38 | get { 39 | return _numberOfColumns 40 | } 41 | } 42 | 43 | open var numberOfRows: Int { 44 | get { 45 | return _numberOfRows 46 | } 47 | } 48 | 49 | public init(with: String, delimiter: String) { 50 | let csv = with.replacingOccurrences(of: "\r", with: "", options: NSString.CompareOptions.literal, range: nil) 51 | _delimiter = delimiter 52 | processLines(csv) 53 | _numberOfColumns = _lines[0].components(separatedBy: _delimiter).count 54 | _numberOfRows = _lines.count - 1 55 | headers = _lines[0].components(separatedBy: _delimiter) 56 | setRows() 57 | setColumns() 58 | } 59 | 60 | public convenience init(with: String) { 61 | self.init(with: with, delimiter: ",") 62 | } 63 | 64 | fileprivate func processLines(_ csv: String) { 65 | _lines = csv.components(separatedBy: "\n") 66 | // Remove blank lines 67 | var i = 0 68 | for line in _lines { 69 | if line.isEmpty { 70 | _lines.remove(at: i) 71 | i -= 1 72 | } 73 | i += 1 74 | } 75 | } 76 | 77 | fileprivate func setRows() { 78 | var rows = [[String: String]]() 79 | for i in 1..._numberOfRows { 80 | var row = [String: String]() 81 | let vals = _lines[i].components(separatedBy: _delimiter) 82 | var i = 0 83 | for header in headers { 84 | row[header] = vals[i] 85 | i+=1 86 | } 87 | rows.append(row) 88 | } 89 | self.rows = rows 90 | } 91 | 92 | fileprivate func setColumns() { 93 | var columns = [String: [String]]() 94 | for header in headers { 95 | var colValue = [String]() 96 | for row in rows { 97 | colValue.append(row[header]!) 98 | } 99 | columns[header] = colValue 100 | } 101 | self.columns = columns 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /MLKit/Classes/Genetic Algorithms/Genome.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Genome.swift 3 | // Pods 4 | // 5 | // Created by Guled on 3/7/17. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | /// Protocol for a Genome. It is encouraged that you create your own `generateFitness` method as there are several ways to assess fitness. You are required, on the other hand, to have a genotype representation and a fitness for every Genome. 12 | public protocol Genome { 13 | 14 | /// Genotype representation of the genome. 15 | var genotypeRepresentation: [Float] { get set } 16 | 17 | /// Fitness of a particular genome. 18 | var fitness: Float { get set } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MLKit/Classes/Genetic Algorithms/Population.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Population.swift 3 | // Pods 4 | // 5 | // Created by Guled on 3/7/17. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | /// Handles processes involving selection. 12 | open class PopulationManager { 13 | 14 | /** 15 | The selectParents method selects two parents from the population to create an offspring. 16 | 17 | - parameter genomes: An array of genomes. 18 | 19 | - returns: A tuple consisted of two genomes. 20 | */ 21 | open static func selectParents(genomes: [Genome]) -> (Genome, Genome) { 22 | 23 | var genomes = genomes 24 | 25 | var tournament: [Genome] = [] 26 | 27 | // Create a "tournament" (an array of randomly selected genomes). 28 | for _ in 0.. maxFitness { 43 | maxFitness = genome.fitness as! Float 44 | firstBestGenome = genome 45 | indexOfBestGenome = i 46 | } 47 | } 48 | 49 | genomes.remove(at: indexOfBestGenome) 50 | 51 | // Now look for the second best genome in the population 52 | 53 | maxFitness = -10000 54 | indexOfBestGenome = 0 55 | 56 | for (i, genome) in genomes.enumerated() { 57 | if genome.fitness > maxFitness { 58 | maxFitness = genome.fitness 59 | secondBestGenome = genome 60 | indexOfBestGenome = i 61 | } 62 | } 63 | 64 | genomes.remove(at: indexOfBestGenome) 65 | 66 | return (firstBestGenome!, secondBestGenome!) 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /MLKit/Classes/Helper Classes & Extensions/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 7/6/16. 6 | // Copyright © 2016 Guled. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // Extensions below belong to Nate Cook 12 | // http://stackoverflow.com/questions/24026510/how-do-i-shuffle-an-array-in-swift 13 | 14 | extension Collection { 15 | /// Return a copy of `self` with its elements shuffled 16 | func shuffle() -> [Iterator.Element] { 17 | var list = Array(self) 18 | list.shuffle() 19 | return list 20 | } 21 | } 22 | 23 | extension MutableCollection where Indices.Iterator.Element == Index { 24 | /// Shuffles the contents of this collection. 25 | mutating func shuffle() { 26 | let c = count 27 | guard c > 1 else { return } 28 | 29 | for (firstUnshuffled, unshuffledCount) in zip(indices, stride(from: c, to: 1, by: -1)) { 30 | let d: IndexDistance = numericCast(arc4random_uniform(numericCast(unshuffledCount))) 31 | guard d != 0 else { continue } 32 | let i = index(firstUnshuffled, offsetBy: d) 33 | swap(&self[firstUnshuffled], &self[i]) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MLKit/Classes/Helper Classes & Extensions/MachineLeanringErrorEnum.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RegressionErrorEnum.swift 3 | // MLKit 4 | // 5 | // Created by Guled on 7/10/16. 6 | // Copyright © 2016 Guled. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum MachineLearningError: Error { 12 | 13 | /// Not enough data or no data was provided to a particular method 14 | case lengthOfDataArrayNotEqual 15 | 16 | /// The model was not fit on any data 17 | case modelHasNotBeenFit 18 | 19 | /// A method took invalid data as a parameter. 20 | case invalidInput 21 | 22 | /// Description for MachineLearningError enum 23 | 24 | var description: String { 25 | switch(self) { 26 | case .lengthOfDataArrayNotEqual: 27 | return "No data was provided." 28 | case .modelHasNotBeenFit: 29 | return "You need to have fit a model first before computing the RSS/Cost Function. To fit your model, call the `train` method." 30 | case .invalidInput: 31 | return "Input was invalid." 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MLKit/Classes/MLKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // MLKit.h 3 | // MLKit 4 | // 5 | // Created by Guled on 6/30/16. 6 | // Copyright © 2016 Somnibyte. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for MLKit. 12 | FOUNDATION_EXPORT double MLKitVersionNumber; 13 | 14 | //! Project version string for MLKit. 15 | FOUNDATION_EXPORT const unsigned char MLKitVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /MLKitLogo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/MLKitLogo2.png -------------------------------------------------------------------------------- /MLKitSmallerLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/MLKitSmallerLogo.png -------------------------------------------------------------------------------- /MachineLearningKit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint MLKit.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'MachineLearningKit' 11 | s.version = '0.1.8' 12 | s.summary = 'A simple machine learning framework written in Swift 🤖' 13 | 14 | s.description = <<-DESC 15 | MLKit is a simple machine learning framework written in Swift. Currently MLKit features machine learning algorithms that deal with the topic of regression, but the framework will expand over time with topics such as classification, clustering, recommender systems, and deep learning. The vision and goal of this framework is to provide developers with a toolkit to create products that can learn from data. MLKit is a side project of mine in order to make it easier for developers to implement machine learning algorithms on the go, and to familiarlize myself with machine learning concepts. 16 | 17 | 18 | DESC 19 | 20 | 21 | s.homepage = 'https://github.com/Somnibyte/MLKit' 22 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 23 | s.license = { :type => 'MIT', :file => 'LICENSE' } 24 | s.author = { 'Guled Ahmed' => 'guledahmed777@gmail.com' } 25 | s.source = { :git => 'https://github.com/Somnibyte/MLKit.git', :tag => s.version.to_s } 26 | # s.social_media_url = 'https://twitter.com/_Guled_' 27 | 28 | s.ios.deployment_target = '9.0' 29 | s.tvos.deployment_target = '10.1' 30 | 31 | s.source_files = 'MLKit/Classes/**/*' 32 | 33 | # s.resource_bundles = { 34 | # 'MLKit' => ['MLKit/Assets/*.png'] 35 | # } 36 | 37 | # s.public_header_files = 'Pod/Classes/**/*.h' 38 | s.frameworks = 'UIKit', 'MapKit' 39 | s.dependency 'Upsurge' 40 | end 41 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /flappybirdai.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Somnibyte/MLKit/a4eb14ec958323daa7e18cd51bfb69e2b73df740/flappybirdai.gif --------------------------------------------------------------------------------