├── Pods ├── Target Support Files │ ├── SQLite.swift │ │ ├── SQLite.swift-prefix.pch │ │ ├── SQLite.swift.modulemap │ │ ├── SQLite.swift-dummy.m │ │ ├── SQLite.swift-umbrella.h │ │ ├── Info.plist │ │ └── SQLite.swift.xcconfig │ ├── SwiftFSWatcher │ │ ├── SwiftFSWatcher-prefix.pch │ │ ├── SwiftFSWatcher.modulemap │ │ ├── SwiftFSWatcher-dummy.m │ │ ├── SwiftFSWatcher-umbrella.h │ │ ├── SwiftFSWatcher.xcconfig │ │ └── Info.plist │ ├── Pods-SimPermissions │ │ ├── Pods-SimPermissions.modulemap │ │ ├── Pods-SimPermissions-dummy.m │ │ ├── Pods-SimPermissions-umbrella.h │ │ ├── Pods-SimPermissions.debug.xcconfig │ │ ├── Pods-SimPermissions.release.xcconfig │ │ ├── Info.plist │ │ ├── Pods-SimPermissions-acknowledgements.markdown │ │ ├── Pods-SimPermissions-acknowledgements.plist │ │ ├── Pods-SimPermissions-frameworks.sh │ │ └── Pods-SimPermissions-resources.sh │ └── Pods-SimPermissionsTests │ │ ├── Pods-SimPermissionsTests-acknowledgements.markdown │ │ ├── Pods-SimPermissionsTests.modulemap │ │ ├── Pods-SimPermissionsTests-dummy.m │ │ ├── Pods-SimPermissionsTests-umbrella.h │ │ ├── Pods-SimPermissionsTests.debug.xcconfig │ │ ├── Pods-SimPermissionsTests.release.xcconfig │ │ ├── Info.plist │ │ ├── Pods-SimPermissionsTests-acknowledgements.plist │ │ ├── Pods-SimPermissionsTests-frameworks.sh │ │ └── Pods-SimPermissionsTests-resources.sh ├── SQLite.swift │ ├── SQLite │ │ ├── SQLite.h │ │ ├── Core │ │ │ ├── SQLite-Bridging.h │ │ │ ├── Blob.swift │ │ │ ├── Value.swift │ │ │ ├── SQLite-Bridging.m │ │ │ ├── fts3_tokenizer.h │ │ │ └── Statement.swift │ │ ├── Extensions │ │ │ ├── R*Tree.swift │ │ │ └── FTS4.swift │ │ ├── Typed │ │ │ ├── Collation.swift │ │ │ ├── Expression.swift │ │ │ ├── CustomFunctions.swift │ │ │ └── AggregateFunctions.swift │ │ ├── Foundation.swift │ │ └── Helpers.swift │ ├── CocoaPods │ │ ├── macosx │ │ │ └── module.modulemap │ │ ├── watchos │ │ │ └── module.modulemap │ │ ├── appletvos │ │ │ └── module.modulemap │ │ ├── iphoneos │ │ │ └── module.modulemap │ │ ├── watchsimulator │ │ │ └── module.modulemap │ │ ├── appletvsimulator │ │ │ └── module.modulemap │ │ └── iphonesimulator │ │ │ └── module.modulemap │ ├── LICENSE.txt │ └── README.md ├── Manifest.lock ├── SwiftFSWatcher │ ├── src │ │ └── SwiftFSWatcher │ │ │ └── SwiftFSWatcher │ │ │ ├── SwiftFSWatcher.h │ │ │ └── SwiftFSWatcher.swift │ └── README.md └── Pods.xcodeproj │ └── xcuserdata │ └── nickentin.xcuserdatad │ └── xcschemes │ ├── xcschememanagement.plist │ ├── SwiftFSWatcher.xcscheme │ ├── SQLite.swift.xcscheme │ ├── Pods-SimPermissions.xcscheme │ └── Pods-SimPermissionsTests.xcscheme ├── SimPermissions ├── Assets.xcassets │ ├── Contents.json │ ├── AppIcon.appiconset │ │ ├── AppIcon.png │ │ ├── AppIcon-1.png │ │ ├── AppIcon-2.png │ │ ├── AppIcon-3.png │ │ ├── AppIcon-4.png │ │ ├── AppIcon-5.png │ │ └── Contents.json │ ├── MissingAppIcon.imageset │ │ ├── MissingAppIcon.png │ │ └── Contents.json │ └── StatusBarIcon.imageset │ │ ├── StatusBarIcon@2x.png │ │ └── Contents.json ├── PFMoveApplication │ ├── MoveApplication.strings │ └── PFMoveApplication.h ├── SimPermissions-Bridging-Header.h ├── Base.lproj │ └── MainMenu.xib ├── Info.plist ├── SimulatorModel.swift ├── AppModel.swift ├── PermissionModel.swift ├── Label.swift ├── FileMonitor.swift ├── PermissionHeaderMenuItem.swift ├── PermissionHeaderMenuItemView.swift ├── SimulatorMenuItem.swift ├── AppDelegate.swift ├── AppManager.swift ├── PermissionMenuItem.swift ├── SimulatorMenuItemView.swift ├── MenuManager.swift ├── SimulatorManager.swift ├── PermissionManager.swift └── PermissionMenuItemView.swift ├── SimPermissions.xcworkspace ├── xcuserdata │ └── nickentin.xcuserdatad │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist └── contents.xcworkspacedata ├── SimPermissions.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcuserdata │ └── nickentin.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── xcshareddata │ └── xcschemes │ └── SimPermissions.xcscheme ├── Podfile ├── Podfile.lock ├── .travis.yml ├── SimPermissionsTests ├── Info.plist └── SimPermissionsTests.swift ├── LICENSE └── README.md /Pods/Target Support Files/SQLite.swift/SQLite.swift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/SwiftFSWatcher-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /SimPermissions/PFMoveApplication/MoveApplication.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/PFMoveApplication/MoveApplication.strings -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-1.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-2.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-3.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-4.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/AppIcon.appiconset/AppIcon-5.png -------------------------------------------------------------------------------- /Pods/Target Support Files/SQLite.swift/SQLite.swift.modulemap: -------------------------------------------------------------------------------- 1 | framework module SQLite { 2 | umbrella header "SQLite.swift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /SimPermissions/SimPermissions-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "PFMoveApplication.h" -------------------------------------------------------------------------------- /Pods/Target Support Files/SQLite.swift/SQLite.swift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SQLite_swift : NSObject 3 | @end 4 | @implementation PodsDummy_SQLite_swift 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/SwiftFSWatcher.modulemap: -------------------------------------------------------------------------------- 1 | framework module SwiftFSWatcher { 2 | umbrella header "SwiftFSWatcher-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /SimPermissions.xcworkspace/xcuserdata/nickentin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/MissingAppIcon.imageset/MissingAppIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/MissingAppIcon.imageset/MissingAppIcon.png -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/StatusBarIcon.imageset/StatusBarIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickEntin/SimPermissions/HEAD/SimPermissions/Assets.xcassets/StatusBarIcon.imageset/StatusBarIcon@2x.png -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/SwiftFSWatcher-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SwiftFSWatcher : NSObject 3 | @end 4 | @implementation PodsDummy_SwiftFSWatcher 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/SQLite.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | FOUNDATION_EXPORT double SQLiteVersionNumber; 4 | FOUNDATION_EXPORT const unsigned char SQLiteVersionString[]; 5 | 6 | #import 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_SimPermissions { 2 | umbrella header "Pods-SimPermissions-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SimPermissions : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SimPermissions 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/macosx/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/watchos/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/appletvos/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/iphoneos/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_SimPermissionsTests { 2 | umbrella header "Pods-SimPermissionsTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SimPermissionsTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SimPermissionsTests 5 | @end 6 | -------------------------------------------------------------------------------- /SimPermissions.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/watchsimulator/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_SimPermissionsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_SimPermissionsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/appletvsimulator/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/CocoaPods/iphonesimulator/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSQLite [system] { 2 | header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/SwiftFSWatcher-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "SwiftFSWatcher.h" 4 | 5 | FOUNDATION_EXPORT double SwiftFSWatcherVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char SwiftFSWatcherVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SQLite.swift/SQLite.swift-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "SQLite-Bridging.h" 4 | #import "SQLite.h" 5 | 6 | FOUNDATION_EXPORT double SQLiteVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char SQLiteVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_SimPermissionsTestsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_SimPermissionsTestsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /SimPermissions.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'SimPermissions' do 5 | use_frameworks! 6 | 7 | pod 'SQLite.swift', '~> 0.10.1' 8 | pod 'SwiftFSWatcher' 9 | 10 | target 'SimPermissionsTests' do 11 | inherit! :search_paths 12 | # Pods for testing 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/MissingAppIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "filename" : "MissingAppIcon.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SQLite.swift (0.10.1) 3 | - SwiftFSWatcher (1.02) 4 | 5 | DEPENDENCIES: 6 | - SQLite.swift (~> 0.10.1) 7 | - SwiftFSWatcher 8 | 9 | SPEC CHECKSUMS: 10 | SQLite.swift: 6a6e4b034efc317ce4e203b6af2d3024fee2b570 11 | SwiftFSWatcher: cc65f552d380629f7566b90fe32fbf57561184ee 12 | 13 | PODFILE CHECKSUM: dbeaf1a457f03ddd4879176f9691de1d2e49684c 14 | 15 | COCOAPODS: 1.0.1 16 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SQLite.swift (0.10.1) 3 | - SwiftFSWatcher (1.02) 4 | 5 | DEPENDENCIES: 6 | - SQLite.swift (~> 0.10.1) 7 | - SwiftFSWatcher 8 | 9 | SPEC CHECKSUMS: 10 | SQLite.swift: 6a6e4b034efc317ce4e203b6af2d3024fee2b570 11 | SwiftFSWatcher: cc65f552d380629f7566b90fe32fbf57561184ee 12 | 13 | PODFILE CHECKSUM: dbeaf1a457f03ddd4879176f9691de1d2e49684c 14 | 15 | COCOAPODS: 1.0.1 16 | -------------------------------------------------------------------------------- /SimPermissions/PFMoveApplication/PFMoveApplication.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFMoveApplication.h, version 1.17 3 | // LetsMove 4 | // 5 | // Created by Andy Kim at Potion Factory LLC on 9/17/09 6 | // 7 | // The contents of this file are dedicated to the public domain. 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | void PFMoveToApplicationsFolderIfNecessary(void); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /.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 | podfile: Podfile 8 | before_install: 9 | - gem install cocoapods 10 | - pod repo update 11 | - pod install 12 | script: 13 | - set -o pipefail && xcodebuild test -workspace SimPermissions.xcworkspace -scheme SimPermissions -sdk macosx10.11 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/StatusBarIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "mac", 9 | "filename" : "StatusBarIcon@2x.png", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | }, 17 | "properties" : { 18 | "template-rendering-intent" : "original" 19 | } 20 | } -------------------------------------------------------------------------------- /Pods/SwiftFSWatcher/src/SwiftFSWatcher/SwiftFSWatcher/SwiftFSWatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftFSWatcher.h 3 | // SwiftFSWatcher 4 | // 5 | // Created by Gurinder Hans on 4/9/16. 6 | // Copyright © 2016 Gurinder Hans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for SwiftFSWatcher. 12 | FOUNDATION_EXPORT double SwiftFSWatcherVersionNumber; 13 | 14 | //! Project version string for SwiftFSWatcher. 15 | FOUNDATION_EXPORT const unsigned char SwiftFSWatcherVersionString[]; -------------------------------------------------------------------------------- /SimPermissions.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SuppressBuildableAutocreation 6 | 7 | D2FDA85E1D409FBE00B79649 8 | 9 | primary 10 | 11 | 12 | D2FDA86D1D409FBE00B79649 13 | 14 | primary 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/SwiftFSWatcher.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 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 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift" "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher" 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/SQLite.swift/SQLite.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher/SwiftFSWatcher.framework/Headers" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift" "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher" 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/SQLite.swift/SQLite.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher/SwiftFSWatcher.framework/Headers" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /SimPermissionsTests/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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift" "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift/SQLite.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher/SwiftFSWatcher.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "SQLite" -framework "SwiftFSWatcher" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions.release.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift" "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SQLite.swift/SQLite.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftFSWatcher/SwiftFSWatcher.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "SQLite" -framework "SwiftFSWatcher" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SQLite.swift/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.10.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SwiftFSWatcher/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.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests-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 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Nick Entin 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 | -------------------------------------------------------------------------------- /SimPermissions/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/LICENSE.txt: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2014-2015 Stephen Celis () 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SQLite.swift/SQLite.swift.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SQLite.swift 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | OTHER_LDFLAGS = -l"sqlite3" 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 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | SWIFT_INCLUDE_PATHS[sdk=appletvos*] = $(SRCROOT)/SQLite.swift/CocoaPods/appletvos 13 | SWIFT_INCLUDE_PATHS[sdk=appletvsimulator*] = $(SRCROOT)/SQLite.swift/CocoaPods/appletvsimulator 14 | SWIFT_INCLUDE_PATHS[sdk=iphoneos*] = $(SRCROOT)/SQLite.swift/CocoaPods/iphoneos 15 | SWIFT_INCLUDE_PATHS[sdk=iphonesimulator*] = $(SRCROOT)/SQLite.swift/CocoaPods/iphonesimulator 16 | SWIFT_INCLUDE_PATHS[sdk=macosx*] = $(SRCROOT)/SQLite.swift/CocoaPods/macosx 17 | SWIFT_INCLUDE_PATHS[sdk=watchos*] = $(SRCROOT)/SQLite.swift/CocoaPods/watchos 18 | SWIFT_INCLUDE_PATHS[sdk=watchsimulator*] = $(SRCROOT)/SQLite.swift/CocoaPods/watchsimulator 19 | -------------------------------------------------------------------------------- /SimPermissions/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 0.1.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 2 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | LSUIElement 28 | 29 | NSHumanReadableCopyright 30 | Copyright © 2016 Nick Entin. All rights reserved. 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-SimPermissions.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-SimPermissionsTests.xcscheme 13 | 14 | isShown 15 | 16 | 17 | SQLite.swift.xcscheme 18 | 19 | isShown 20 | 21 | 22 | SwiftFSWatcher.xcscheme 23 | 24 | isShown 25 | 26 | 27 | 28 | SuppressBuildableAutocreation 29 | 30 | A0BD80FAE7514198EFEA2F868BFB31A2 31 | 32 | primary 33 | 34 | 35 | AC890360F2F09702E22314FEA1450A9D 36 | 37 | primary 38 | 39 | 40 | F455E68712766A618E17DB8D46AEE2D3 41 | 42 | primary 43 | 44 | 45 | F9472E5601C64ACB519A5E8A92C98CDA 46 | 47 | primary 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /SimPermissionsTests/SimPermissionsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimPermissionsTests.swift 3 | // SimPermissionsTests 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import XCTest 27 | @testable import SimPermissions 28 | 29 | class SimPermissionsTests: XCTestCase { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /SimPermissions/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "size" : "128x128", 25 | "idiom" : "mac", 26 | "filename" : "AppIcon-5.png", 27 | "scale" : "1x" 28 | }, 29 | { 30 | "size" : "128x128", 31 | "idiom" : "mac", 32 | "filename" : "AppIcon-4.png", 33 | "scale" : "2x" 34 | }, 35 | { 36 | "size" : "256x256", 37 | "idiom" : "mac", 38 | "filename" : "AppIcon-3.png", 39 | "scale" : "1x" 40 | }, 41 | { 42 | "size" : "256x256", 43 | "idiom" : "mac", 44 | "filename" : "AppIcon-2.png", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "size" : "512x512", 49 | "idiom" : "mac", 50 | "filename" : "AppIcon-1.png", 51 | "scale" : "1x" 52 | }, 53 | { 54 | "size" : "512x512", 55 | "idiom" : "mac", 56 | "filename" : "AppIcon.png", 57 | "scale" : "2x" 58 | } 59 | ], 60 | "info" : { 61 | "version" : 1, 62 | "author" : "xcode" 63 | } 64 | } -------------------------------------------------------------------------------- /SimPermissions/SimulatorModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimulatorModel.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | 28 | struct SimulatorModel { 29 | let name: String 30 | let system: String 31 | let udid: String 32 | let booted: Bool 33 | } 34 | -------------------------------------------------------------------------------- /SimPermissions/AppModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppModel.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | 28 | struct AppMetadata { 29 | let uuid: String 30 | 31 | let displayName: String 32 | let version: String 33 | let iconPath: String 34 | } 35 | -------------------------------------------------------------------------------- /SimPermissions/PermissionModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionModel.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | 28 | struct PermissionModel { 29 | let permissionType: String 30 | let appIdentifier: String 31 | let allowed: Bool 32 | let appMetadata: AppMetadata? 33 | } 34 | -------------------------------------------------------------------------------- /SimPermissions/Label.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Label.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class Label : NSTextField { 29 | override init(frame: CGRect) { 30 | super.init(frame: frame); 31 | 32 | self.bezeled = false 33 | self.drawsBackground = false 34 | self.editable = false 35 | self.selectable = false 36 | } 37 | 38 | required init?(coder: NSCoder) { 39 | fatalError("init(coder:) has not been implemented") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/SQLite-Bridging.h: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | @import Foundation; 26 | 27 | #ifndef COCOAPODS 28 | #import "sqlite3.h" 29 | #endif 30 | 31 | typedef struct SQLiteHandle SQLiteHandle; // CocoaPods workaround 32 | 33 | NS_ASSUME_NONNULL_BEGIN 34 | typedef NSString * _Nullable (^_SQLiteTokenizerNextCallback)(const char * input, int * inputOffset, int * inputLength); 35 | int _SQLiteRegisterTokenizer(SQLiteHandle * db, const char * module, const char * tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); 36 | NS_ASSUME_NONNULL_END 37 | 38 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Extensions/R*Tree.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | extension Module { 26 | 27 | @warn_unused_result public static func RTree(primaryKey: Expression, _ pairs: (Expression, Expression)...) -> Module { 28 | var arguments: [Expressible] = [primaryKey] 29 | 30 | for pair in pairs { 31 | arguments.appendContentsOf([pair.0, pair.1] as [Expressible]) 32 | } 33 | 34 | return Module(name: "rtree", arguments: arguments) 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimPermissions 2 | 3 | [![Build Status](https://travis-ci.org/NickEntin/SimPermissions.svg?branch=travis)](https://travis-ci.org/NickEntin/SimPermissions/) 4 | [![Version 0.1.1](https://img.shields.io/badge/version-0.1.1-green.svg)](https://github.com/NickEntin/SimPermissions/releases) 5 | [![Issues](https://img.shields.io/github/issues/nickentin/simpermissions.svg?maxAge=2592000)](https://github.com/NickEntin/SimPermissions/issues) 6 | [![MIT License](https://img.shields.io/badge/license-MIT-lightgray.svg)](https://github.com/NickEntin/SimPermissions/blob/master/LICENSE) 7 | 8 | SimPermissions is a macOS menu bar app that lets you manage individual app permissions on the iOS simulator. First, select a simulator. You will then see a list of permissions that have been set on that simulator. Each item has an option to grant/revoke that permission, or clear it completely. 9 | 10 | The app is currently in beta and has a lot of UI issues. 11 | 12 | ### Capabilities 13 | 14 | SimPermissions can modify a range of permission settings, with more coming soon. Currently it can change or clear permissions for: 15 | 16 | * Contacts 17 | * Calendar 18 | * Reminders 19 | * Photos 20 | * Camera 21 | * Media Library 22 | 23 | ### How do I get set up? 24 | 25 | * Download the latest binary from the [releases](https://github.com/NickEntin/SimPermissions/releases/) page 26 | 27 | -- OR -- 28 | 29 | * Clone the repo 30 | * Run `pod install` 31 | * Open `SimPermissions.xcworkspace` 32 | * Run the app from Xcode 33 | 34 | ### Contributing 35 | 36 | Find a bug? Have a feature you'd like to see added? Submit an [issue](https://github.com/NickEntin/SimPermissions/issues/new) and/or [pull request](https://github.com/NickEntin/SimPermissions/compare). 37 | 38 | ### Open Source Libraries 39 | 40 | * [SQLite.swift](https://github.com/stephencelis/SQLite.swift) 41 | * [SwiftFSWatcher](https://github.com/gurinderhans/SwiftFSWatcher) 42 | * [LetsMove](https://github.com/potionfactory/LetsMove) 43 | -------------------------------------------------------------------------------- /SimPermissions/FileMonitor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FileMonitor.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | import SwiftFSWatcher 28 | 29 | class FileMonitor { 30 | var fileWatcher: SwiftFSWatcher? 31 | var refresh: ()->() = {} 32 | 33 | func monitorChangesForSimulator(simulator: SimulatorModel) { 34 | stopMonitoring() 35 | 36 | let fileWatcher = SwiftFSWatcher(["/Users/\(NSUserName())/Library/Developer/CoreSimulator/Devices/\(simulator.udid)/data/Library/TCC/"]) 37 | fileWatcher.watch { changeEvents in 38 | self.refresh() 39 | } 40 | self.fileWatcher = fileWatcher 41 | } 42 | 43 | func stopMonitoring() { 44 | self.fileWatcher?.pause() 45 | self.fileWatcher = nil 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/Blob.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | public struct Blob { 26 | 27 | public let bytes: [UInt8] 28 | 29 | public init(bytes: [UInt8]) { 30 | self.bytes = bytes 31 | } 32 | 33 | public init(bytes: UnsafePointer, length: Int) { 34 | self.init(bytes: [UInt8](UnsafeBufferPointer( 35 | start: UnsafePointer(bytes), count: length 36 | ))) 37 | } 38 | 39 | public func toHex() -> String { 40 | return bytes.map { 41 | ($0 < 16 ? "0" : "") + String($0, radix: 16, uppercase: false) 42 | }.joinWithSeparator("") 43 | } 44 | 45 | } 46 | 47 | extension Blob : CustomStringConvertible { 48 | 49 | public var description: String { 50 | return "x'\(toHex())'" 51 | } 52 | 53 | } 54 | 55 | extension Blob : Equatable { 56 | 57 | } 58 | 59 | public func ==(lhs: Blob, rhs: Blob) -> Bool { 60 | return lhs.bytes == rhs.bytes 61 | } 62 | -------------------------------------------------------------------------------- /SimPermissions/PermissionHeaderMenuItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionHeaderMenuItem.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class PermissionHeaderMenuItem : NSMenuItem { 29 | let simulatorManager: SimulatorManager 30 | let refresh: () -> () 31 | 32 | init(simulatorManager: SimulatorManager, refresh: ()->()) { 33 | self.simulatorManager = simulatorManager 34 | self.refresh = refresh 35 | 36 | super.init(title: "", action: nil, keyEquivalent: "") 37 | 38 | if let simulator = simulatorManager.activeSimulator { 39 | let headerView = PermissionHeaderMenuItemView(simulator: simulator) 40 | headerView.backButton.target = self 41 | headerView.backButton.action = #selector(back) 42 | view = headerView 43 | } 44 | } 45 | 46 | required init?(coder aDecoder: NSCoder) { 47 | fatalError("init(coder:) has not been implemented") 48 | } 49 | 50 | @objc func back() { 51 | simulatorManager.activeSimulator = nil 52 | refresh() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /SimPermissions/PermissionHeaderMenuItemView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionHeaderMenuItemView.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class PermissionHeaderMenuItemView : NSView { 29 | let backButton: NSButton 30 | 31 | init(simulator: SimulatorModel) { 32 | backButton = NSButton(frame: CGRect(x: 0, y: 0, width: 50, height: 40)) 33 | backButton.title = "< BACK" 34 | backButton.bordered = false 35 | 36 | let simulatorLabel = Label(frame: CGRect(x: 60, y: 14, width: 200, height: 16)) 37 | simulatorLabel.stringValue = "\(simulator.name) (\(simulator.system))" 38 | simulatorLabel.font = NSFont.systemFontOfSize(16) 39 | simulatorLabel.textColor = NSColor.grayColor() 40 | simulatorLabel.alignment = NSCenterTextAlignment 41 | 42 | super.init(frame: CGRect(x: 0, y: 0, width: 320, height: 40)) 43 | 44 | addSubview(backButton) 45 | addSubview(simulatorLabel) 46 | } 47 | 48 | required init?(coder: NSCoder) { 49 | fatalError("init(coder:) has not been implemented") 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/SwiftFSWatcher.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Typed/Collation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | /// A collating function used to compare to strings. 26 | /// 27 | /// - SeeAlso: 28 | public enum Collation { 29 | 30 | /// Compares string by raw data. 31 | case Binary 32 | 33 | /// Like binary, but folds uppercase ASCII letters into their lowercase 34 | /// equivalents. 35 | case Nocase 36 | 37 | /// Like binary, but strips trailing space. 38 | case Rtrim 39 | 40 | /// A custom collating sequence identified by the given string, registered 41 | /// using `Database.create(collation:…)` 42 | case Custom(String) 43 | 44 | } 45 | 46 | extension Collation : Expressible { 47 | 48 | public var expression: Expression { 49 | return Expression(literal: description) 50 | } 51 | 52 | } 53 | 54 | extension Collation : CustomStringConvertible { 55 | 56 | public var description : String { 57 | switch self { 58 | case Binary: 59 | return "BINARY" 60 | case Nocase: 61 | return "NOCASE" 62 | case Rtrim: 63 | return "RTRIM" 64 | case Custom(let collation): 65 | return collation.quote() 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /SimPermissions/SimulatorMenuItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimulatorMenuItem.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class SimulatorMenuItem : NSMenuItem { 29 | var simulator: SimulatorModel 30 | var simulatorsManager: SimulatorManager 31 | var refresh: ()->() 32 | 33 | init(simulator: SimulatorModel, simulatorsManager: SimulatorManager, refresh: ()->()) { 34 | self.simulator = simulator 35 | self.simulatorsManager = simulatorsManager 36 | self.refresh = refresh 37 | 38 | super.init(title: " \(simulator.name) (\(simulator.system))", action: #selector(selectSimulator), keyEquivalent: "") 39 | 40 | self.target = self 41 | 42 | let menuItemView = SimulatorMenuItemView(simulator: simulator) 43 | menuItemView.addGestureRecognizer(NSClickGestureRecognizer(target: self, action: #selector(selectSimulator))) 44 | view = menuItemView 45 | } 46 | 47 | required init?(coder aDecoder: NSCoder) { 48 | fatalError("init(coder:) has not been implemented") 49 | } 50 | 51 | override init(title aString: String, action aSelector: Selector, keyEquivalent charCode: String) { 52 | fatalError("init(title:action:keyEquivalent:) has not been implemented") 53 | } 54 | 55 | @objc func selectSimulator(sender: AnyObject) { 56 | simulatorsManager.activeSimulator = simulator 57 | refresh() 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SimPermissions/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Cocoa 27 | 28 | @NSApplicationMain 29 | class AppDelegate: NSObject, NSApplicationDelegate { 30 | 31 | @IBOutlet weak var window: NSWindow! 32 | 33 | var statusItem: NSStatusItem 34 | var statusItemMenu: NSMenu 35 | 36 | let simulatorManager: SimulatorManager 37 | let appManager: AppManager 38 | let permissionManager: PermissionManager 39 | let menuManager: MenuManager 40 | let fileMonitor: FileMonitor 41 | 42 | override init() { 43 | statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength) 44 | statusItem.image = NSImage(named: "StatusBarIcon") 45 | 46 | statusItemMenu = NSMenu() 47 | statusItem.menu = statusItemMenu 48 | 49 | fileMonitor = FileMonitor() 50 | simulatorManager = SimulatorManager(fileMonitor: fileMonitor) 51 | appManager = AppManager() 52 | permissionManager = PermissionManager(simulatorManager: simulatorManager) 53 | menuManager = MenuManager(simulatorManager: simulatorManager, appManager: appManager, permissionManager: permissionManager, fileMonitor: fileMonitor, menu: statusItemMenu) 54 | 55 | super.init() 56 | } 57 | 58 | func applicationDidFinishLaunching(aNotification: NSNotification) { 59 | PFMoveToApplicationsFolderIfNecessary() 60 | menuManager.setupMenuItems() 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SQLite.swift 5 | 6 | (The MIT License) 7 | 8 | Copyright (c) 2014-2015 Stephen Celis () 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | 29 | ## SwiftFSWatcher 30 | 31 | Version 1.0 32 | 33 | Created by Gurinder Hans on 04/10/2016. 34 | Copyright 2016 Gurinder Hans 35 | 36 | This code is distributed under the terms and conditions of the MIT license. 37 | 38 | Permission is hereby granted, free of charge, to any person obtaining a copy 39 | of this software and associated documentation files (the "Software"), to deal 40 | in the Software without restriction, including without limitation the rights 41 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 42 | copies of the Software, and to permit persons to whom the Software is 43 | furnished to do so, subject to the following conditions: 44 | 45 | The above copyright notice and this permission notice shall be included in 46 | all copies or substantial portions of the Software. 47 | 48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 49 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 50 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 51 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 52 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 53 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 54 | THE SOFTWARE. 55 | 56 | Generated by CocoaPods - https://cocoapods.org 57 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/SQLite.swift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/Pods-SimPermissions.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/nickentin.xcuserdatad/xcschemes/Pods-SimPermissionsTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/SwiftFSWatcher/README.md: -------------------------------------------------------------------------------- 1 | # SwiftFSWatcher 2 | A simple easy to use / extend File System watcher using Swift 3 | 4 | # Example (Swift) 5 | 6 | ```swift 7 | import Cocoa 8 | import SwiftFSWatcher 9 | 10 | class ViewController: NSViewController { 11 | 12 | // NOTE: - Any instance of `SwiftFSWatcher` must be class scoped, like below: 13 | 14 | /* This will not crash your app. */ 15 | let fileWatcher = SwiftFSWatcher(["/var/www/html/", "/home/Downloads/"]) 16 | let anotherWatcher = SwiftFSWatcher() 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | /* Using `localWatcher` will crash your app. */ 22 | // let localWatcher = SwiftFSWatcher() 23 | 24 | fileWatcher.watch { changeEvents in 25 | for ev in changeEvents { 26 | print("eventPath: \(ev.eventPath), eventFlag: \(ev.eventFlag), eventId: \(ev.eventId)") 27 | 28 | // check if this event is of a file created 29 | if ev.eventFlag == (kFSEventStreamEventFlagItemIsFile + kFSEventStreamEventFlagItemCreated) { 30 | print("created file at path: \(ev.eventPath)") 31 | } 32 | 33 | } 34 | } 35 | 36 | // setup and listen second watcher events on files only 37 | anotherWatcher.watchingPaths = ["/home/myFile.txt", "/root/bash_session.txt"] 38 | anotherWatcher.watch { changeEvents in 39 | for ev in changeEvents { 40 | print("eventPath: \(ev.eventPath), eventFlag: \(ev.eventFlag), eventId: \(ev.eventId)") 41 | 42 | if ev.eventFlag == (kFSEventStreamEventFlagItemIsFile + kFSEventStreamEventFlagItemInodeMetaMod + kFSEventStreamEventFlagItemModified) { 43 | print("file modified at: \(ev.eventPath)") 44 | } 45 | } 46 | } 47 | } 48 | } 49 | ``` 50 | 51 | # Example (Objective-C) 52 | ```objc 53 | #import "ViewController.h" 54 | #import 55 | 56 | @implementation ViewController 57 | 58 | SwiftFSWatcher * s; 59 | 60 | - (void)viewDidLoad { 61 | [super viewDidLoad]; 62 | 63 | s = [[SwiftFSWatcher alloc] init]; 64 | 65 | s.watchingPaths = [@[@"/path/to/some/folder/", @"/path/to/myFile.txt"] mutableCopy]; 66 | 67 | [s watch:^(NSArray * aa) { 68 | NSLog(@"changed paths: %@", aa); 69 | }]; 70 | } 71 | @end 72 | ``` 73 | 74 | # Installation (two ways) 75 | 76 | + Include `pod 'SwiftFSWatcher'` in your Podfile 77 | + You'll need to add `use_frameworks!` since the framework is built in Swift. 78 | 79 | + Grab the `SwiftFSWatcher.framework` and add it to your project or build the `.framework` yoursleves by downloading this project. 80 | 81 | + Use it in your app 82 | 83 | # Questions? 84 | 85 | Have a question? Feel free to email me. 86 | 87 | # You added a new feature? 88 | 89 | Send it in right now! I can't wait to see what you've done! 90 | 91 | # Found a Bug? 92 | 93 | Oh No! Send in a pull request with the patch (very much appreciated) or just contact me :D 94 | 95 | # License 96 | 97 | [MIT License](http://opensource.org/licenses/MIT) 98 | -------------------------------------------------------------------------------- /SimPermissions/AppManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppManager.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | 28 | class AppManager { 29 | func getAppMetadata(udid: String, bundleIdentifier: String) -> AppMetadata? { 30 | let fileManager = NSFileManager.defaultManager() 31 | let basePath = "/Users/\(NSUserName())/Library/Developer/CoreSimulator/Devices/\(udid)/data/Containers/Bundle/Application" 32 | 33 | do { 34 | let appDirectories: [String] = try fileManager.contentsOfDirectoryAtPath(basePath) 35 | for appDirectory in appDirectories { 36 | if appDirectory == ".DS_Store" { 37 | continue 38 | } 39 | let appContents: [String] = try fileManager.contentsOfDirectoryAtPath("\(basePath)/\(appDirectory)") 40 | for appContent in appContents { 41 | if appContent.hasSuffix(".app") { 42 | if let appInfo = NSDictionary(contentsOfFile: "\(basePath)/\(appDirectory)/\(appContent)/Info.plist") { 43 | if let bundleName: String = appInfo["CFBundleName"] as? String, 44 | let bundleId: String = appInfo["CFBundleIdentifier"] as? String, 45 | let appVersion: String = appInfo["CFBundleShortVersionString"] as? String { 46 | if bundleId == bundleIdentifier { 47 | let iconPath = "\(basePath)/\(appDirectory)/\(appContent)/AppIcon60x60@3x.png" 48 | let meta = AppMetadata( 49 | uuid: appDirectory, 50 | displayName: bundleName, 51 | version: appVersion, 52 | iconPath: iconPath 53 | ) 54 | return meta 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | } catch _ { 62 | 63 | } 64 | 65 | return nil 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SimPermissions/PermissionMenuItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionMenuItem.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class PermissionMenuItem : NSMenuItem { 29 | let permission: PermissionModel 30 | let permissionManager: PermissionManager 31 | let refresh: ()->() 32 | 33 | init(permission: PermissionModel, permissionManager: PermissionManager, refresh: ()->()) { 34 | self.permission = permission 35 | self.permissionManager = permissionManager 36 | self.refresh = refresh 37 | 38 | super.init(title: "", action: nil, keyEquivalent: "") 39 | 40 | let permissionView = PermissionMenuItemView(permission: permission) 41 | permissionView.allowButton.target = self 42 | permissionView.allowButton.action = #selector(grantPermission) 43 | permissionView.revokeButton.target = self 44 | permissionView.revokeButton.action = #selector(revokePermission) 45 | permissionView.deleteButton.target = self 46 | permissionView.deleteButton.action = #selector(clearPermission) 47 | view = permissionView 48 | } 49 | 50 | required init?(coder aDecoder: NSCoder) { 51 | fatalError("init(coder:) has not been implemented") 52 | } 53 | 54 | override init(title aString: String, action aSelector: Selector, keyEquivalent charCode: String) { 55 | fatalError("init(title:action:keyEquivalent:) has not been implemented") 56 | } 57 | 58 | @objc func grantPermission(sender: AnyObject) { 59 | do { 60 | try permissionManager.grantPermission(permission) 61 | refresh() 62 | } catch _ { 63 | print("Unable to grant permission") 64 | } 65 | } 66 | 67 | @objc func revokePermission(sender: AnyObject) { 68 | do { 69 | try permissionManager.revokePermission(permission) 70 | refresh() 71 | } catch _ { 72 | print("Unable to revoke permission") 73 | } 74 | } 75 | 76 | @objc func clearPermission(sender: AnyObject) { 77 | do { 78 | try permissionManager.deletePermission(permission) 79 | refresh() 80 | } catch _ { 81 | print("Unable to clear permission") 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Pods/SwiftFSWatcher/src/SwiftFSWatcher/SwiftFSWatcher/SwiftFSWatcher.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftFSWatcher.swift 3 | // SwiftFSWatcher 4 | // 5 | // Created by Gurinder Hans on 4/9/16. 6 | // Copyright © 2016 Gurinder Hans. All rights reserved. 7 | // 8 | 9 | @objc public class SwiftFSWatcher : NSObject { 10 | 11 | var isRunning = false 12 | 13 | var stream: FSEventStreamRef? 14 | 15 | var onChangeCallback: ([FileEvent] -> Void)? 16 | 17 | public var watchingPaths: [String]? 18 | 19 | 20 | // MARK: - Init methods 21 | 22 | public override init() { 23 | // Default init 24 | super.init() 25 | } 26 | 27 | public convenience init(_ paths: [String]) { 28 | self.init() 29 | self.watchingPaths = paths 30 | } 31 | 32 | // MARK: - API public methods 33 | 34 | public func watch(changeCb: ([FileEvent] -> Void)?) { 35 | 36 | guard let paths = watchingPaths else { 37 | return 38 | } 39 | 40 | guard stream == nil else { 41 | return 42 | } 43 | 44 | onChangeCallback = changeCb 45 | 46 | var context = FSEventStreamContext(version: 0, info: UnsafeMutablePointer(unsafeAddressOf(self)), retain: nil, release: nil, copyDescription: nil) 47 | 48 | stream = FSEventStreamCreate(kCFAllocatorDefault, innerEventCallback, &context, paths, FSEventStreamEventId(kFSEventStreamEventIdSinceNow), 0, UInt32(kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagFileEvents)) 49 | 50 | FSEventStreamScheduleWithRunLoop(stream!, NSRunLoop.currentRunLoop().getCFRunLoop(), kCFRunLoopDefaultMode) 51 | FSEventStreamStart(stream!) 52 | 53 | isRunning = true 54 | } 55 | 56 | public func resume() { 57 | 58 | guard stream != nil else { 59 | return 60 | } 61 | 62 | FSEventStreamStart(stream!) 63 | } 64 | 65 | public func pause() { 66 | 67 | guard stream != nil else { 68 | return 69 | } 70 | 71 | FSEventStreamStop(stream!) 72 | } 73 | 74 | // MARK: - [Private] Closure passed into `FSEventStream` and is called on new file event 75 | 76 | private let innerEventCallback: FSEventStreamCallback = { (stream: ConstFSEventStreamRef, contextInfo: UnsafeMutablePointer, numEvents: Int, eventPaths: UnsafeMutablePointer, eventFlags: UnsafePointer, eventIds: UnsafePointer) in 77 | 78 | let fsWatcher: SwiftFSWatcher = unsafeBitCast(contextInfo, SwiftFSWatcher.self) 79 | 80 | let paths = unsafeBitCast(eventPaths, NSArray.self) as! [String] 81 | 82 | var fileEvents = [FileEvent]() 83 | for i in 0.. 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 | (The MIT License) 18 | 19 | Copyright (c) 2014-2015 Stephen Celis (<stephen@stephencelis.com>) 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | Title 40 | SQLite.swift 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Version 1.0 47 | 48 | Created by Gurinder Hans on 04/10/2016. 49 | Copyright 2016 Gurinder Hans 50 | 51 | This code is distributed under the terms and conditions of the MIT license. 52 | 53 | Permission is hereby granted, free of charge, to any person obtaining a copy 54 | of this software and associated documentation files (the "Software"), to deal 55 | in the Software without restriction, including without limitation the rights 56 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 57 | copies of the Software, and to permit persons to whom the Software is 58 | furnished to do so, subject to the following conditions: 59 | 60 | The above copyright notice and this permission notice shall be included in 61 | all copies or substantial portions of the Software. 62 | 63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 65 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 66 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 67 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 68 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 69 | THE SOFTWARE. 70 | 71 | Title 72 | SwiftFSWatcher 73 | Type 74 | PSGroupSpecifier 75 | 76 | 77 | FooterText 78 | Generated by CocoaPods - https://cocoapods.org 79 | Title 80 | 81 | Type 82 | PSGroupSpecifier 83 | 84 | 85 | StringsTable 86 | Acknowledgements 87 | Title 88 | Acknowledgements 89 | 90 | 91 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Foundation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | import Foundation 26 | 27 | extension NSData : Value { 28 | 29 | public class var declaredDatatype: String { 30 | return Blob.declaredDatatype 31 | } 32 | 33 | public class func fromDatatypeValue(dataValue: Blob) -> NSData { 34 | return NSData(bytes: dataValue.bytes, length: dataValue.bytes.count) 35 | } 36 | 37 | public var datatypeValue: Blob { 38 | return Blob(bytes: bytes, length: length) 39 | } 40 | 41 | } 42 | 43 | extension NSDate : Value { 44 | 45 | public class var declaredDatatype: String { 46 | return String.declaredDatatype 47 | } 48 | 49 | public class func fromDatatypeValue(stringValue: String) -> NSDate { 50 | return dateFormatter.dateFromString(stringValue)! 51 | } 52 | 53 | public var datatypeValue: String { 54 | return dateFormatter.stringFromDate(self) 55 | } 56 | 57 | } 58 | 59 | /// A global date formatter used to serialize and deserialize `NSDate` objects. 60 | /// If multiple date formats are used in an application’s database(s), use a 61 | /// custom `Value` type per additional format. 62 | public var dateFormatter: NSDateFormatter = { 63 | let formatter = NSDateFormatter() 64 | formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" 65 | formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") 66 | formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) 67 | return formatter 68 | }() 69 | 70 | // FIXME: rdar://problem/18673897 // subscript… 71 | 72 | extension QueryType { 73 | 74 | public subscript(column: Expression) -> Expression { 75 | return namespace(column) 76 | } 77 | public subscript(column: Expression) -> Expression { 78 | return namespace(column) 79 | } 80 | 81 | public subscript(column: Expression) -> Expression { 82 | return namespace(column) 83 | } 84 | public subscript(column: Expression) -> Expression { 85 | return namespace(column) 86 | } 87 | 88 | } 89 | 90 | extension Row { 91 | 92 | public subscript(column: Expression) -> NSData { 93 | return get(column) 94 | } 95 | public subscript(column: Expression) -> NSData? { 96 | return get(column) 97 | } 98 | 99 | public subscript(column: Expression) -> NSDate { 100 | return get(column) 101 | } 102 | public subscript(column: Expression) -> NSDate? { 103 | return get(column) 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /SimPermissions/SimulatorMenuItemView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimulatorMenuItemView.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class SimulatorMenuItemView : NSView { 29 | let activeIcon: NSView 30 | let simulatorLabel: Label 31 | let systemLabel: Label 32 | let udidLabel: Label 33 | 34 | init(simulator: SimulatorModel) { 35 | activeIcon = NSView(frame: CGRect(x: 10, y: 12.5, width: 15, height: 15)) 36 | activeIcon.wantsLayer = true 37 | activeIcon.layer?.cornerRadius = 10 38 | if simulator.booted { 39 | activeIcon.layer?.backgroundColor = NSColor.greenColor().CGColor 40 | } else { 41 | activeIcon.layer?.backgroundColor = NSColor.grayColor().CGColor 42 | } 43 | 44 | simulatorLabel = Label(frame: CGRect(x: 35, y: 15, width: 100, height: 20)) 45 | simulatorLabel.stringValue = simulator.name 46 | 47 | systemLabel = Label(frame: CGRect(x: 170, y: 15, width: 80, height: 20)) 48 | systemLabel.alignment = NSTextAlignment.Right 49 | systemLabel.stringValue = simulator.system 50 | 51 | udidLabel = Label(frame: CGRect(x: 35, y: 5, width: 220, height: 10)) 52 | udidLabel.stringValue = simulator.udid 53 | udidLabel.font = NSFont.systemFontOfSize(9) 54 | 55 | super.init(frame: CGRect(x: 0, y: 0, width: 260, height: 40)) 56 | 57 | addSubview(activeIcon) 58 | addSubview(simulatorLabel) 59 | addSubview(systemLabel) 60 | addSubview(udidLabel) 61 | 62 | addTrackingArea(NSTrackingArea(rect: self.bounds, options: [ NSTrackingAreaOptions.MouseEnteredAndExited, NSTrackingAreaOptions.ActiveAlways ], owner: self, userInfo: nil)) 63 | 64 | wantsLayer = true 65 | applyDefaultViewStyle() 66 | } 67 | 68 | required init?(coder: NSCoder) { 69 | fatalError("init(coder:) has not been implemented") 70 | } 71 | 72 | func applyDefaultViewStyle() { 73 | layer?.backgroundColor = NSColor.clearColor().CGColor 74 | simulatorLabel.textColor = NSColor.blackColor() 75 | systemLabel.textColor = NSColor.blackColor() 76 | udidLabel.textColor = NSColor.grayColor() 77 | } 78 | 79 | override func mouseEntered(theEvent: NSEvent) { 80 | layer?.backgroundColor = NSColor(red: 46.0 / 255.0, green: 136.0 / 255.0, blue: 243.0 / 255.0, alpha: 1.0).CGColor 81 | simulatorLabel.textColor = NSColor.whiteColor() 82 | systemLabel.textColor = NSColor.whiteColor() 83 | udidLabel.textColor = NSColor.whiteColor() 84 | } 85 | 86 | override func mouseExited(theEvent: NSEvent) { 87 | applyDefaultViewStyle() 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/Value.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | /// - Warning: `Binding` is a protocol that SQLite.swift uses internally to 26 | /// directly map SQLite types to Swift types. 27 | /// 28 | /// Do not conform custom types to the Binding protocol. See the `Value` 29 | /// protocol, instead. 30 | public protocol Binding {} 31 | 32 | public protocol Number : Binding {} 33 | 34 | public protocol Value : Expressible { // extensions cannot have inheritance clauses 35 | 36 | associatedtype ValueType = Self 37 | 38 | associatedtype Datatype : Binding 39 | 40 | static var declaredDatatype: String { get } 41 | 42 | static func fromDatatypeValue(datatypeValue: Datatype) -> ValueType 43 | 44 | var datatypeValue: Datatype { get } 45 | 46 | } 47 | 48 | extension Double : Number, Value { 49 | 50 | public static let declaredDatatype = "REAL" 51 | 52 | public static func fromDatatypeValue(datatypeValue: Double) -> Double { 53 | return datatypeValue 54 | } 55 | 56 | public var datatypeValue: Double { 57 | return self 58 | } 59 | 60 | } 61 | 62 | extension Int64 : Number, Value { 63 | 64 | public static let declaredDatatype = "INTEGER" 65 | 66 | public static func fromDatatypeValue(datatypeValue: Int64) -> Int64 { 67 | return datatypeValue 68 | } 69 | 70 | public var datatypeValue: Int64 { 71 | return self 72 | } 73 | 74 | } 75 | 76 | extension String : Binding, Value { 77 | 78 | public static let declaredDatatype = "TEXT" 79 | 80 | public static func fromDatatypeValue(datatypeValue: String) -> String { 81 | return datatypeValue 82 | } 83 | 84 | public var datatypeValue: String { 85 | return self 86 | } 87 | 88 | } 89 | 90 | extension Blob : Binding, Value { 91 | 92 | public static let declaredDatatype = "BLOB" 93 | 94 | public static func fromDatatypeValue(datatypeValue: Blob) -> Blob { 95 | return datatypeValue 96 | } 97 | 98 | public var datatypeValue: Blob { 99 | return self 100 | } 101 | 102 | } 103 | 104 | // MARK: - 105 | 106 | extension Bool : Binding, Value { 107 | 108 | public static var declaredDatatype = Int64.declaredDatatype 109 | 110 | public static func fromDatatypeValue(datatypeValue: Int64) -> Bool { 111 | return datatypeValue != 0 112 | } 113 | 114 | public var datatypeValue: Int64 { 115 | return self ? 1 : 0 116 | } 117 | 118 | } 119 | 120 | extension Int : Number, Value { 121 | 122 | public static var declaredDatatype = Int64.declaredDatatype 123 | 124 | public static func fromDatatypeValue(datatypeValue: Int64) -> Int { 125 | return Int(datatypeValue) 126 | } 127 | 128 | public var datatypeValue: Int64 { 129 | return Int64(self) 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/SQLite.swift/SQLite.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/SwiftFSWatcher/SwiftFSWatcher.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/SQLite.swift/SQLite.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/SwiftFSWatcher/SwiftFSWatcher.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /SimPermissions/MenuManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuManager.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class MenuManager : NSObject { 29 | let simulatorManager: SimulatorManager 30 | let appManager: AppManager 31 | let permissionManager: PermissionManager 32 | 33 | let menu: NSMenu 34 | 35 | init(simulatorManager: SimulatorManager, appManager: AppManager, permissionManager: PermissionManager, fileMonitor: FileMonitor, menu: NSMenu) { 36 | self.simulatorManager = simulatorManager 37 | self.appManager = appManager 38 | self.permissionManager = permissionManager 39 | self.menu = menu 40 | 41 | super.init() 42 | 43 | fileMonitor.refresh = refreshMenu 44 | } 45 | 46 | func setupMenuItems() { 47 | menu.removeAllItems() 48 | 49 | if let _ = simulatorManager.activeSimulator { 50 | menu.addItem(PermissionHeaderMenuItem(simulatorManager: simulatorManager, refresh: refreshMenu)) 51 | addMenuItemsForApps() 52 | } else { 53 | addMenuItemsForSimulators() 54 | } 55 | 56 | let menuItem = NSMenuItem(title: "Refresh List", action: #selector(refreshMenu), keyEquivalent: "r") 57 | menuItem.target = self 58 | menu.addItem(menuItem) 59 | menu.addItem(NSMenuItem(title: "Quit SimPermissions", action: Selector("terminate:"), keyEquivalent: "q")) 60 | } 61 | 62 | @objc func refreshMenu() { 63 | setupMenuItems() 64 | } 65 | 66 | func addMenuItemsForApps() { 67 | do { 68 | let permissions = try permissionManager.getPermissions() 69 | for permission in permissions { 70 | menu.addItem(PermissionMenuItem(permission: permission, permissionManager: permissionManager, refresh: setupMenuItems)) 71 | } 72 | if permissions.count == 0 { 73 | menu.addItem(NSMenuItem(title: "No permissions found", action: nil, keyEquivalent: "")) 74 | menu.addItem(NSMenuItem.separatorItem()) 75 | } 76 | } catch _ { 77 | menu.addItem(NSMenuItem(title: "No permissions found", action: nil, keyEquivalent: "")) 78 | menu.addItem(NSMenuItem.separatorItem()) 79 | } 80 | } 81 | 82 | func addMenuItemsForSimulators() { 83 | menu.addItem(NSMenuItem(title: "Select a simulator:", action: nil, keyEquivalent: "")) 84 | 85 | if let simulators = simulatorManager.getSimulators() { 86 | for simulator in simulators { 87 | menu.addItem(SimulatorMenuItem(simulator: simulator, simulatorsManager: simulatorManager, refresh: setupMenuItems)) 88 | } 89 | } else { 90 | print("No simulators found") 91 | menu.addItem(NSMenuItem(title: " No simulators found", action: nil, keyEquivalent: "")) 92 | } 93 | 94 | menu.addItem(NSMenuItem.separatorItem()) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /SimPermissions.xcodeproj/xcshareddata/xcschemes/SimPermissions.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /SimPermissions/SimulatorManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimulatorsManager.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | 28 | class SimulatorManager { 29 | let fileMonitor: FileMonitor 30 | 31 | var activeSimulator: SimulatorModel? { 32 | didSet { 33 | if let activeSimulator = activeSimulator { 34 | fileMonitor.monitorChangesForSimulator(activeSimulator) 35 | } else { 36 | fileMonitor.stopMonitoring() 37 | } 38 | } 39 | } 40 | 41 | init(fileMonitor: FileMonitor) { 42 | self.fileMonitor = fileMonitor 43 | } 44 | 45 | func getSimulators() -> [SimulatorModel]? { 46 | var simulators: [SimulatorModel] = [] 47 | 48 | if let devicesData = execute("xcrun", "simctl", "list", "devices", "--json") { 49 | do { 50 | if let json: [String : AnyObject] = try NSJSONSerialization.JSONObjectWithData(devicesData, options: NSJSONReadingOptions(rawValue: 0)) as? [String : AnyObject], 51 | let deviceTypes: [String : AnyObject] = json["devices"] as? [String : AnyObject] { 52 | for (deviceType, devices) in deviceTypes { 53 | if deviceType.rangeOfString("iOS") != nil { 54 | let deviceType = deviceType.stringByReplacingOccurrencesOfString("com.apple.CoreSimulator.SimRuntime.", withString: "") 55 | .stringByReplacingOccurrencesOfString("iOS-", withString: "iOS ") 56 | .stringByReplacingOccurrencesOfString("-", withString: ".") 57 | 58 | if let devices = devices as? [[String:String]] { 59 | simulators.appendContentsOf(simulatorsFromDescriptionList(devices, system: deviceType)) 60 | } 61 | } 62 | } 63 | return simulators 64 | } 65 | } catch _ { 66 | print ("Could not parse JSON") 67 | } 68 | } else { 69 | print("Could not load devices") 70 | } 71 | return nil 72 | } 73 | 74 | func simulatorsFromDescriptionList(descriptionList: [[String:String]], system: String) -> [SimulatorModel] { 75 | var simulators: [SimulatorModel] = [] 76 | for device in descriptionList { 77 | if let name = device["name"], udid = device["udid"], state = device["state"] { 78 | let booted = (state == "Booted") 79 | simulators.append(SimulatorModel( 80 | name: name, 81 | system: system, 82 | udid: udid, 83 | booted: booted 84 | )) 85 | } 86 | 87 | } 88 | return simulators 89 | } 90 | 91 | func execute(args: String...) -> NSData? { 92 | let task = NSTask() 93 | task.launchPath = "/usr/bin/env" 94 | task.arguments = args 95 | 96 | let outputPipe = NSPipe() 97 | task.standardOutput = outputPipe 98 | 99 | task.launch() 100 | task.waitUntilExit() 101 | 102 | let fileHandle = outputPipe.fileHandleForReading; 103 | let data = fileHandle.readDataToEndOfFile() 104 | return data 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Typed/Expression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | public protocol ExpressionType : Expressible { // extensions cannot have inheritance clauses 26 | 27 | associatedtype UnderlyingType = Void 28 | 29 | var template: String { get } 30 | var bindings: [Binding?] { get } 31 | 32 | init(_ template: String, _ bindings: [Binding?]) 33 | 34 | } 35 | 36 | extension ExpressionType { 37 | 38 | public init(literal: String) { 39 | self.init(literal, []) 40 | } 41 | 42 | public init(_ identifier: String) { 43 | self.init(literal: identifier.quote()) 44 | } 45 | 46 | public init(_ expression: U) { 47 | self.init(expression.template, expression.bindings) 48 | } 49 | 50 | } 51 | 52 | /// An `Expression` represents a raw SQL fragment and any associated bindings. 53 | public struct Expression : ExpressionType { 54 | 55 | public typealias UnderlyingType = Datatype 56 | 57 | public var template: String 58 | public var bindings: [Binding?] 59 | 60 | public init(_ template: String, _ bindings: [Binding?]) { 61 | self.template = template 62 | self.bindings = bindings 63 | } 64 | 65 | } 66 | 67 | public protocol Expressible { 68 | 69 | var expression: Expression { get } 70 | 71 | } 72 | 73 | extension Expressible { 74 | 75 | // naïve compiler for statements that can’t be bound, e.g., CREATE TABLE 76 | // FIXME: use @testable and make internal 77 | public func asSQL() -> String { 78 | let expressed = expression 79 | var idx = 0 80 | return expressed.template.characters.reduce("") { template, character in 81 | let transcoded: String 82 | 83 | if character == "?" { 84 | transcoded = transcode(expressed.bindings[idx]) 85 | idx += 1 86 | } else { 87 | transcoded = String(character) 88 | } 89 | return template + transcoded 90 | } 91 | } 92 | 93 | } 94 | 95 | extension ExpressionType { 96 | 97 | public var expression: Expression { 98 | return Expression(template, bindings) 99 | } 100 | 101 | public var asc: Expressible { 102 | return " ".join([self, Expression(literal: "ASC")]) 103 | } 104 | 105 | public var desc: Expressible { 106 | return " ".join([self, Expression(literal: "DESC")]) 107 | } 108 | 109 | } 110 | 111 | extension ExpressionType where UnderlyingType : Value { 112 | 113 | public init(value: UnderlyingType) { 114 | self.init("?", [value.datatypeValue]) 115 | } 116 | 117 | } 118 | 119 | extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : Value { 120 | 121 | public static var null: Self { 122 | return self.init(value: nil) 123 | } 124 | 125 | public init(value: UnderlyingType.WrappedType?) { 126 | self.init("?", [value?.datatypeValue]) 127 | } 128 | 129 | } 130 | 131 | extension Value { 132 | 133 | public var expression: Expression { 134 | return Expression(value: self).expression 135 | } 136 | 137 | } 138 | 139 | public let rowid = Expression("ROWID") 140 | 141 | public func cast(expression: Expression) -> Expression { 142 | return Expression("CAST (\(expression.template) AS \(U.declaredDatatype))", expression.bindings) 143 | } 144 | 145 | public func cast(expression: Expression) -> Expression { 146 | return Expression("CAST (\(expression.template) AS \(U.declaredDatatype))", expression.bindings) 147 | } 148 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Helpers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | import CSQLite 26 | 27 | public typealias Star = (Expression?, Expression?) -> Expression 28 | 29 | public func *(_: Expression?, _: Expression?) -> Expression { 30 | return Expression(literal: "*") 31 | } 32 | 33 | public protocol _OptionalType { 34 | 35 | associatedtype WrappedType 36 | 37 | } 38 | 39 | extension Optional : _OptionalType { 40 | 41 | public typealias WrappedType = Wrapped 42 | 43 | } 44 | 45 | // let SQLITE_STATIC = unsafeBitCast(0, sqlite3_destructor_type.self) 46 | let SQLITE_TRANSIENT = unsafeBitCast(-1, sqlite3_destructor_type.self) 47 | 48 | extension String { 49 | 50 | @warn_unused_result func quote(mark: Character = "\"") -> String { 51 | let escaped = characters.reduce("") { string, character in 52 | string + (character == mark ? "\(mark)\(mark)" : "\(character)") 53 | } 54 | return "\(mark)\(escaped)\(mark)" 55 | } 56 | 57 | @warn_unused_result func join(expressions: [Expressible]) -> Expressible { 58 | var (template, bindings) = ([String](), [Binding?]()) 59 | for expressible in expressions { 60 | let expression = expressible.expression 61 | template.append(expression.template) 62 | bindings.appendContentsOf(expression.bindings) 63 | } 64 | return Expression(template.joinWithSeparator(self), bindings) 65 | } 66 | 67 | @warn_unused_result func infix(lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> Expression { 68 | let expression = Expression(" \(self) ".join([lhs, rhs]).expression) 69 | guard wrap else { 70 | return expression 71 | } 72 | return "".wrap(expression) 73 | } 74 | 75 | @warn_unused_result func prefix(expressions: Expressible) -> Expressible { 76 | return "\(self) ".wrap(expressions) as Expression 77 | } 78 | 79 | @warn_unused_result func prefix(expressions: [Expressible]) -> Expressible { 80 | return "\(self) ".wrap(expressions) as Expression 81 | } 82 | 83 | @warn_unused_result func wrap(expression: Expressible) -> Expression { 84 | return Expression("\(self)(\(expression.expression.template))", expression.expression.bindings) 85 | } 86 | 87 | @warn_unused_result func wrap(expressions: [Expressible]) -> Expression { 88 | return wrap(", ".join(expressions)) 89 | } 90 | 91 | } 92 | 93 | @warn_unused_result func infix(lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression { 94 | return function.infix(lhs, rhs, wrap: wrap) 95 | } 96 | 97 | @warn_unused_result func wrap(expression: Expressible, function: String = #function) -> Expression { 98 | return function.wrap(expression) 99 | } 100 | 101 | @warn_unused_result func wrap(expressions: [Expressible], function: String = #function) -> Expression { 102 | return function.wrap(", ".join(expressions)) 103 | } 104 | 105 | @warn_unused_result func transcode(literal: Binding?) -> String { 106 | guard let literal = literal else { return "NULL" } 107 | 108 | switch literal { 109 | case let blob as Blob: 110 | return blob.description 111 | case let string as String: 112 | return string.quote("'") 113 | case let binding: 114 | return "\(binding)" 115 | } 116 | } 117 | 118 | @warn_unused_result func value(v: Binding) -> A { 119 | return A.fromDatatypeValue(v as! A.Datatype) as! A 120 | } 121 | 122 | @warn_unused_result func value(v: Binding?) -> A { 123 | return value(v!) 124 | } 125 | -------------------------------------------------------------------------------- /SimPermissions/PermissionManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionsManager.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import Foundation 27 | import SQLite 28 | 29 | class PermissionManager { 30 | enum PermissionManagerError : ErrorType { 31 | case NoActiveSimulator 32 | } 33 | 34 | let simulatorManager: SimulatorManager 35 | let appManager: AppManager 36 | 37 | init(simulatorManager: SimulatorManager) { 38 | self.simulatorManager = simulatorManager 39 | self.appManager = AppManager() 40 | } 41 | 42 | func getPermissions() throws -> [PermissionModel] { 43 | if let udid = simulatorManager.activeSimulator?.udid { 44 | let db = try Connection(path(udid)) 45 | 46 | let access = Table("access") 47 | let service = Expression("service") 48 | let client = Expression("client") 49 | let allowed = Expression("allowed") 50 | 51 | var permissions: [PermissionModel] = [] 52 | 53 | for row in try db.prepare(access) { 54 | if (row[client].rangeOfString("com.apple") == nil) { 55 | let metadata = appManager.getAppMetadata(udid, bundleIdentifier: row[client]) 56 | permissions.append(PermissionModel( 57 | permissionType: row[service], 58 | appIdentifier: row[client], 59 | allowed: (row[allowed] == 1), 60 | appMetadata: metadata 61 | )) 62 | } 63 | } 64 | 65 | return permissions 66 | } else { 67 | throw PermissionManagerError.NoActiveSimulator 68 | } 69 | } 70 | 71 | func grantPermission(permission: PermissionModel) throws { 72 | if let udid = simulatorManager.activeSimulator?.udid { 73 | let db = try Connection(path(udid)) 74 | 75 | let access = Table("access") 76 | let service = Expression("service") 77 | let client = Expression("client") 78 | let allowed = Expression("allowed") 79 | 80 | let rows = access.filter(service == permission.permissionType && client == permission.appIdentifier) 81 | try db.run(rows.update(allowed <- 1)) 82 | } else { 83 | throw PermissionManagerError.NoActiveSimulator 84 | } 85 | } 86 | 87 | func revokePermission(permission: PermissionModel) throws { 88 | if let udid = simulatorManager.activeSimulator?.udid { 89 | let db = try Connection(path(udid)) 90 | 91 | let access = Table("access") 92 | let service = Expression("service") 93 | let client = Expression("client") 94 | let allowed = Expression("allowed") 95 | 96 | let rows = access.filter(service == permission.permissionType && client == permission.appIdentifier) 97 | try db.run(rows.update(allowed <- 0)) 98 | } else { 99 | throw PermissionManagerError.NoActiveSimulator 100 | } 101 | } 102 | 103 | func deletePermission(permission: PermissionModel) throws { 104 | if let udid = simulatorManager.activeSimulator?.udid { 105 | let db = try Connection(path(udid)) 106 | 107 | let access = Table("access") 108 | let service = Expression("service") 109 | let client = Expression("client") 110 | 111 | let rows = access.filter(service == permission.permissionType && client == permission.appIdentifier) 112 | try db.run(rows.delete()) 113 | } else { 114 | throw PermissionManagerError.NoActiveSimulator 115 | } 116 | } 117 | 118 | func path(udid: String) -> String { 119 | return "/Users/\(NSUserName())/Library/Developer/CoreSimulator/Devices/\(udid)/data/Library/TCC/TCC.db" 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/SQLite-Bridging.m: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | #import "SQLite-Bridging.h" 26 | #import "sqlite3.h" 27 | #import "fts3_tokenizer.h" 28 | 29 | #pragma mark - FTS 30 | 31 | typedef struct __SQLiteTokenizer { 32 | sqlite3_tokenizer base; 33 | __unsafe_unretained _SQLiteTokenizerNextCallback callback; 34 | } __SQLiteTokenizer; 35 | 36 | typedef struct __SQLiteTokenizerCursor { 37 | void * base; 38 | const char * input; 39 | int inputOffset; 40 | int inputLength; 41 | int idx; 42 | } __SQLiteTokenizerCursor; 43 | 44 | static NSMutableDictionary * __SQLiteTokenizerMap; 45 | 46 | static int __SQLiteTokenizerCreate(int argc, const char * const * argv, sqlite3_tokenizer ** ppTokenizer) { 47 | __SQLiteTokenizer * tokenizer = (__SQLiteTokenizer *)sqlite3_malloc(sizeof(__SQLiteTokenizer)); 48 | if (!tokenizer) { 49 | return SQLITE_NOMEM; 50 | } 51 | memset(tokenizer, 0, sizeof(* tokenizer)); 52 | 53 | NSString * key = [NSString stringWithUTF8String:argv[0]]; 54 | tokenizer->callback = [__SQLiteTokenizerMap objectForKey:key]; 55 | if (!tokenizer->callback) { 56 | return SQLITE_ERROR; 57 | } 58 | 59 | *ppTokenizer = &tokenizer->base; 60 | return SQLITE_OK; 61 | } 62 | 63 | static int __SQLiteTokenizerDestroy(sqlite3_tokenizer * pTokenizer) { 64 | sqlite3_free(pTokenizer); 65 | return SQLITE_OK; 66 | } 67 | 68 | static int __SQLiteTokenizerOpen(sqlite3_tokenizer * pTokenizer, const char * pInput, int nBytes, sqlite3_tokenizer_cursor ** ppCursor) { 69 | __SQLiteTokenizerCursor * cursor = (__SQLiteTokenizerCursor *)sqlite3_malloc(sizeof(__SQLiteTokenizerCursor)); 70 | if (!cursor) { 71 | return SQLITE_NOMEM; 72 | } 73 | 74 | cursor->input = pInput; 75 | cursor->inputOffset = 0; 76 | cursor->inputLength = 0; 77 | cursor->idx = 0; 78 | 79 | *ppCursor = (sqlite3_tokenizer_cursor *)cursor; 80 | return SQLITE_OK; 81 | } 82 | 83 | static int __SQLiteTokenizerClose(sqlite3_tokenizer_cursor * pCursor) { 84 | sqlite3_free(pCursor); 85 | return SQLITE_OK; 86 | } 87 | 88 | static int __SQLiteTokenizerNext(sqlite3_tokenizer_cursor * pCursor, const char ** ppToken, int * pnBytes, int * piStartOffset, int * piEndOffset, int * piPosition) { 89 | __SQLiteTokenizerCursor * cursor = (__SQLiteTokenizerCursor *)pCursor; 90 | __SQLiteTokenizer * tokenizer = (__SQLiteTokenizer *)cursor->base; 91 | 92 | cursor->inputOffset += cursor->inputLength; 93 | const char * input = cursor->input + cursor->inputOffset; 94 | const char * token = [tokenizer->callback(input, &cursor->inputOffset, &cursor->inputLength) cStringUsingEncoding:NSUTF8StringEncoding]; 95 | if (!token) { 96 | return SQLITE_DONE; 97 | } 98 | 99 | *ppToken = token; 100 | *pnBytes = (int)strlen(token); 101 | *piStartOffset = cursor->inputOffset; 102 | *piEndOffset = cursor->inputOffset + cursor->inputLength; 103 | *piPosition = cursor->idx++; 104 | return SQLITE_OK; 105 | } 106 | 107 | static const sqlite3_tokenizer_module __SQLiteTokenizerModule = { 108 | 0, 109 | __SQLiteTokenizerCreate, 110 | __SQLiteTokenizerDestroy, 111 | __SQLiteTokenizerOpen, 112 | __SQLiteTokenizerClose, 113 | __SQLiteTokenizerNext 114 | }; 115 | 116 | int _SQLiteRegisterTokenizer(SQLiteHandle * db, const char * moduleName, const char * submoduleName, _SQLiteTokenizerNextCallback callback) { 117 | static dispatch_once_t onceToken; 118 | dispatch_once(&onceToken, ^{ 119 | __SQLiteTokenizerMap = [NSMutableDictionary new]; 120 | }); 121 | 122 | sqlite3_stmt * stmt; 123 | int status = sqlite3_prepare_v2((sqlite3 *)db, "SELECT fts3_tokenizer(?, ?)", -1, &stmt, 0); 124 | if (status != SQLITE_OK ){ 125 | return status; 126 | } 127 | const sqlite3_tokenizer_module * pModule = &__SQLiteTokenizerModule; 128 | sqlite3_bind_text(stmt, 1, moduleName, -1, SQLITE_STATIC); 129 | sqlite3_bind_blob(stmt, 2, &pModule, sizeof(pModule), SQLITE_STATIC); 130 | sqlite3_step(stmt); 131 | status = sqlite3_finalize(stmt); 132 | if (status != SQLITE_OK ){ 133 | return status; 134 | } 135 | 136 | [__SQLiteTokenizerMap setObject:[callback copy] forKey:[NSString stringWithUTF8String:submoduleName]]; 137 | 138 | return SQLITE_OK; 139 | } 140 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissions/Pods-SimPermissions-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SimPermissionsTests/Pods-SimPermissionsTests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /SimPermissions/PermissionMenuItemView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PermissionMenuItemView.swift 3 | // SimPermissions 4 | // 5 | // Copyright (c) 2016 Nick Entin 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | 28 | class PermissionMenuItemView : NSView { 29 | let allowButton: NSButton 30 | let revokeButton: NSButton 31 | let deleteButton: NSButton 32 | 33 | init(permission: PermissionModel) { 34 | allowButton = NSButton(frame: NSRect(x: 0, y: 5, width: 106, height: 30)) 35 | revokeButton = NSButton(frame: NSRect(x: 107, y: 5, width: 106, height: 30)) 36 | deleteButton = NSButton(frame: NSRect(x: 215, y: 5, width: 106, height: 30)) 37 | 38 | super.init(frame: NSRect(x: 0, y: 0, width: 320, height: 80)) 39 | 40 | let appIcon = NSImageView(frame: NSRect(x: 10, y: 42, width: 35, height: 35)) 41 | if let metadata = permission.appMetadata, 42 | let image = NSImage(contentsOfFile: metadata.iconPath) { 43 | appIcon.image = image 44 | } else if let defaultImage = NSImage(named: "MissingAppIcon") { 45 | appIcon.image = defaultImage 46 | } 47 | appIcon.wantsLayer = true 48 | appIcon.layer?.cornerRadius = 9.0 49 | addSubview(appIcon) 50 | 51 | let appLabel = Label(frame: NSRect(x: 50, y: 55, width: 180, height: 20)) 52 | if let metadata = permission.appMetadata { 53 | let titleString: NSMutableAttributedString = NSMutableAttributedString(string: "\(metadata.displayName) ") 54 | titleString.addAttribute(NSFontAttributeName, value: NSFont.boldSystemFontOfSize(12.0), range: NSMakeRange(0, titleString.length)) 55 | 56 | let versionString: NSMutableAttributedString = NSMutableAttributedString(string: "\(metadata.version)") 57 | versionString.addAttribute(NSForegroundColorAttributeName, value: NSColor.grayColor(), range: NSMakeRange(0, versionString.length)) 58 | titleString.appendAttributedString(versionString) 59 | 60 | appLabel.attributedStringValue = titleString 61 | } else { 62 | appLabel.stringValue = permission.appIdentifier 63 | } 64 | addSubview(appLabel) 65 | 66 | let appIdLabel = Label(frame: NSRect(x: 50, y: 40, width: 260, height: 15)) 67 | appIdLabel.stringValue = permission.appIdentifier 68 | appIdLabel.font = NSFont(name: (appIdLabel.font?.fontName)!, size: 10.0) 69 | appIdLabel.textColor = NSColor.darkGrayColor() 70 | addSubview(appIdLabel) 71 | 72 | let serviceLabel = Label(frame: NSRect(x: 230, y: 55, width: 80, height: 20)) 73 | serviceLabel.stringValue = serviceDisplayName[permission.permissionType] ?? "Unknown" 74 | serviceLabel.alignment = NSTextAlignment.Right 75 | addSubview(serviceLabel) 76 | 77 | allowButton.title = "GRANT" 78 | allowButton.bordered = false 79 | addSubview(allowButton) 80 | 81 | revokeButton.title = "REVOKE" 82 | revokeButton.bordered = false 83 | addSubview(revokeButton) 84 | 85 | deleteButton.title = "CLEAR" 86 | deleteButton.bordered = false 87 | addSubview(deleteButton) 88 | 89 | let buttonsTopBorder = NSView(frame: NSRect(x: 0, y: 35, width: 320, height: 1)) 90 | buttonsTopBorder.wantsLayer = true 91 | buttonsTopBorder.layer?.backgroundColor = NSColor.grayColor().CGColor 92 | addSubview(buttonsTopBorder) 93 | 94 | let buttonsVerticalBorder1 = NSView(frame: NSRect(x: 106, y: 5, width: 1, height: 30)) 95 | buttonsVerticalBorder1.wantsLayer = true 96 | buttonsVerticalBorder1.layer?.backgroundColor = NSColor.grayColor().CGColor 97 | addSubview(buttonsVerticalBorder1) 98 | 99 | let buttonsVerticalBorder2 = NSView(frame: NSRect(x: 214, y: 5, width: 1, height: 30)) 100 | buttonsVerticalBorder2.wantsLayer = true 101 | buttonsVerticalBorder2.layer?.backgroundColor = NSColor.grayColor().CGColor 102 | addSubview(buttonsVerticalBorder2) 103 | 104 | let buttonsBottomBorder = NSView(frame: NSRect(x: 0, y: 5, width: 320, height: 1)) 105 | buttonsBottomBorder.wantsLayer = true 106 | buttonsBottomBorder.layer?.backgroundColor = NSColor.grayColor().CGColor 107 | addSubview(buttonsBottomBorder) 108 | } 109 | 110 | required init?(coder: NSCoder) { 111 | fatalError("init(coder:) has not been implemented") 112 | } 113 | 114 | let serviceDisplayName: [String : String] = [ 115 | "kTCCServiceAddressBook": "Contacts", 116 | "kTCCServiceCalendar": "Calendar", 117 | "kTCCServiceReminders": "Reminders", 118 | "kTCCServicePhotos": "Photos", 119 | "kTCCServiceCamera": "Camera", 120 | "kTCCServiceMediaLibrary": "Media Library", 121 | ] 122 | } 123 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Extensions/FTS4.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | extension Module { 26 | 27 | @warn_unused_result public static func FTS4(column: Expressible, _ more: Expressible...) -> Module { 28 | return FTS4([column] + more) 29 | } 30 | 31 | @warn_unused_result public static func FTS4(columns: [Expressible] = [], tokenize tokenizer: Tokenizer? = nil) -> Module { 32 | var columns = columns 33 | 34 | if let tokenizer = tokenizer { 35 | columns.append("=".join([Expression(literal: "tokenize"), Expression(literal: tokenizer.description)])) 36 | } 37 | return Module(name: "fts4", arguments: columns) 38 | } 39 | 40 | } 41 | 42 | extension VirtualTable { 43 | 44 | /// Builds an expression appended with a `MATCH` query against the given 45 | /// pattern. 46 | /// 47 | /// let emails = VirtualTable("emails") 48 | /// 49 | /// emails.filter(emails.match("Hello")) 50 | /// // SELECT * FROM "emails" WHERE "emails" MATCH 'Hello' 51 | /// 52 | /// - Parameter pattern: A pattern to match. 53 | /// 54 | /// - Returns: An expression appended with a `MATCH` query against the given 55 | /// pattern. 56 | @warn_unused_result public func match(pattern: String) -> Expression { 57 | return "MATCH".infix(tableName(), pattern) 58 | } 59 | 60 | @warn_unused_result public func match(pattern: Expression) -> Expression { 61 | return "MATCH".infix(tableName(), pattern) 62 | } 63 | 64 | @warn_unused_result public func match(pattern: Expression) -> Expression { 65 | return "MATCH".infix(tableName(), pattern) 66 | } 67 | 68 | /// Builds a copy of the query with a `WHERE … MATCH` clause. 69 | /// 70 | /// let emails = VirtualTable("emails") 71 | /// 72 | /// emails.match("Hello") 73 | /// // SELECT * FROM "emails" WHERE "emails" MATCH 'Hello' 74 | /// 75 | /// - Parameter pattern: A pattern to match. 76 | /// 77 | /// - Returns: A query with the given `WHERE … MATCH` clause applied. 78 | @warn_unused_result public func match(pattern: String) -> QueryType { 79 | return filter(match(pattern)) 80 | } 81 | 82 | @warn_unused_result public func match(pattern: Expression) -> QueryType { 83 | return filter(match(pattern)) 84 | } 85 | 86 | @warn_unused_result public func match(pattern: Expression) -> QueryType { 87 | return filter(match(pattern)) 88 | } 89 | 90 | } 91 | 92 | public struct Tokenizer { 93 | 94 | public static let Simple = Tokenizer("simple") 95 | 96 | public static let Porter = Tokenizer("porter") 97 | 98 | @warn_unused_result public static func Unicode61(removeDiacritics removeDiacritics: Bool? = nil, tokenchars: Set = [], separators: Set = []) -> Tokenizer { 99 | var arguments = [String]() 100 | 101 | if let removeDiacritics = removeDiacritics { 102 | arguments.append("removeDiacritics=\(removeDiacritics ? 1 : 0)".quote()) 103 | } 104 | 105 | if !tokenchars.isEmpty { 106 | let joined = tokenchars.map { String($0) }.joinWithSeparator("") 107 | arguments.append("tokenchars=\(joined)".quote()) 108 | } 109 | 110 | if !separators.isEmpty { 111 | let joined = separators.map { String($0) }.joinWithSeparator("") 112 | arguments.append("separators=\(joined)".quote()) 113 | } 114 | 115 | return Tokenizer("unicode61", arguments) 116 | } 117 | 118 | @warn_unused_result public static func Custom(name: String) -> Tokenizer { 119 | return Tokenizer(Tokenizer.moduleName.quote(), [name.quote()]) 120 | } 121 | 122 | public let name: String 123 | 124 | public let arguments: [String] 125 | 126 | private init(_ name: String, _ arguments: [String] = []) { 127 | self.name = name 128 | self.arguments = arguments 129 | } 130 | 131 | private static let moduleName = "SQLite.swift" 132 | 133 | } 134 | 135 | extension Tokenizer : CustomStringConvertible { 136 | 137 | public var description: String { 138 | return ([name] + arguments).joinWithSeparator(" ") 139 | } 140 | 141 | } 142 | 143 | extension Connection { 144 | 145 | public func registerTokenizer(submoduleName: String, next: String -> (String, Range)?) throws { 146 | try check(_SQLiteRegisterTokenizer(handle, Tokenizer.moduleName, submoduleName) { input, offset, length in 147 | let string = String.fromCString(input)! 148 | 149 | guard let (token, range) = next(string) else { return nil } 150 | 151 | let view = string.utf8 152 | offset.memory += string.substringToIndex(range.startIndex).utf8.count 153 | length.memory = Int32(range.startIndex.samePositionIn(view).distanceTo(range.endIndex.samePositionIn(view))) 154 | return token 155 | }) 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/fts3_tokenizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 July 10 3 | ** 4 | ** The author disclaims copyright to this source code. 5 | ** 6 | ************************************************************************* 7 | ** Defines the interface to tokenizers used by fulltext-search. There 8 | ** are three basic components: 9 | ** 10 | ** sqlite3_tokenizer_module is a singleton defining the tokenizer 11 | ** interface functions. This is essentially the class structure for 12 | ** tokenizers. 13 | ** 14 | ** sqlite3_tokenizer is used to define a particular tokenizer, perhaps 15 | ** including customization information defined at creation time. 16 | ** 17 | ** sqlite3_tokenizer_cursor is generated by a tokenizer to generate 18 | ** tokens from a particular input. 19 | */ 20 | #ifndef _FTS3_TOKENIZER_H_ 21 | #define _FTS3_TOKENIZER_H_ 22 | 23 | /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time. 24 | ** If tokenizers are to be allowed to call sqlite3_*() functions, then 25 | ** we will need a way to register the API consistently. 26 | */ 27 | #import "sqlite3.h" 28 | 29 | /* 30 | ** Structures used by the tokenizer interface. When a new tokenizer 31 | ** implementation is registered, the caller provides a pointer to 32 | ** an sqlite3_tokenizer_module containing pointers to the callback 33 | ** functions that make up an implementation. 34 | ** 35 | ** When an fts3 table is created, it passes any arguments passed to 36 | ** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the 37 | ** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer 38 | ** implementation. The xCreate() function in turn returns an 39 | ** sqlite3_tokenizer structure representing the specific tokenizer to 40 | ** be used for the fts3 table (customized by the tokenizer clause arguments). 41 | ** 42 | ** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen() 43 | ** method is called. It returns an sqlite3_tokenizer_cursor object 44 | ** that may be used to tokenize a specific input buffer based on 45 | ** the tokenization rules supplied by a specific sqlite3_tokenizer 46 | ** object. 47 | */ 48 | typedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module; 49 | typedef struct sqlite3_tokenizer sqlite3_tokenizer; 50 | typedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor; 51 | 52 | struct sqlite3_tokenizer_module { 53 | 54 | /* 55 | ** Structure version. Should always be set to 0 or 1. 56 | */ 57 | int iVersion; 58 | 59 | /* 60 | ** Create a new tokenizer. The values in the argv[] array are the 61 | ** arguments passed to the "tokenizer" clause of the CREATE VIRTUAL 62 | ** TABLE statement that created the fts3 table. For example, if 63 | ** the following SQL is executed: 64 | ** 65 | ** CREATE .. USING fts3( ... , tokenizer arg1 arg2) 66 | ** 67 | ** then argc is set to 2, and the argv[] array contains pointers 68 | ** to the strings "arg1" and "arg2". 69 | ** 70 | ** This method should return either SQLITE_OK (0), or an SQLite error 71 | ** code. If SQLITE_OK is returned, then *ppTokenizer should be set 72 | ** to point at the newly created tokenizer structure. The generic 73 | ** sqlite3_tokenizer.pModule variable should not be initialized by 74 | ** this callback. The caller will do so. 75 | */ 76 | int (*xCreate)( 77 | int argc, /* Size of argv array */ 78 | const char *const*argv, /* Tokenizer argument strings */ 79 | sqlite3_tokenizer **ppTokenizer /* OUT: Created tokenizer */ 80 | ); 81 | 82 | /* 83 | ** Destroy an existing tokenizer. The fts3 module calls this method 84 | ** exactly once for each successful call to xCreate(). 85 | */ 86 | int (*xDestroy)(sqlite3_tokenizer *pTokenizer); 87 | 88 | /* 89 | ** Create a tokenizer cursor to tokenize an input buffer. The caller 90 | ** is responsible for ensuring that the input buffer remains valid 91 | ** until the cursor is closed (using the xClose() method). 92 | */ 93 | int (*xOpen)( 94 | sqlite3_tokenizer *pTokenizer, /* Tokenizer object */ 95 | const char *pInput, int nBytes, /* Input buffer */ 96 | sqlite3_tokenizer_cursor **ppCursor /* OUT: Created tokenizer cursor */ 97 | ); 98 | 99 | /* 100 | ** Destroy an existing tokenizer cursor. The fts3 module calls this 101 | ** method exactly once for each successful call to xOpen(). 102 | */ 103 | int (*xClose)(sqlite3_tokenizer_cursor *pCursor); 104 | 105 | /* 106 | ** Retrieve the next token from the tokenizer cursor pCursor. This 107 | ** method should either return SQLITE_OK and set the values of the 108 | ** "OUT" variables identified below, or SQLITE_DONE to indicate that 109 | ** the end of the buffer has been reached, or an SQLite error code. 110 | ** 111 | ** *ppToken should be set to point at a buffer containing the 112 | ** normalized version of the token (i.e. after any case-folding and/or 113 | ** stemming has been performed). *pnBytes should be set to the length 114 | ** of this buffer in bytes. The input text that generated the token is 115 | ** identified by the byte offsets returned in *piStartOffset and 116 | ** *piEndOffset. *piStartOffset should be set to the index of the first 117 | ** byte of the token in the input buffer. *piEndOffset should be set 118 | ** to the index of the first byte just past the end of the token in 119 | ** the input buffer. 120 | ** 121 | ** The buffer *ppToken is set to point at is managed by the tokenizer 122 | ** implementation. It is only required to be valid until the next call 123 | ** to xNext() or xClose(). 124 | */ 125 | /* TODO(shess) current implementation requires pInput to be 126 | ** nul-terminated. This should either be fixed, or pInput/nBytes 127 | ** should be converted to zInput. 128 | */ 129 | int (*xNext)( 130 | sqlite3_tokenizer_cursor *pCursor, /* Tokenizer cursor */ 131 | const char **ppToken, int *pnBytes, /* OUT: Normalized text for token */ 132 | int *piStartOffset, /* OUT: Byte offset of token in input buffer */ 133 | int *piEndOffset, /* OUT: Byte offset of end of token in input buffer */ 134 | int *piPosition /* OUT: Number of tokens returned before this one */ 135 | ); 136 | 137 | /*********************************************************************** 138 | ** Methods below this point are only available if iVersion>=1. 139 | */ 140 | 141 | /* 142 | ** Configure the language id of a tokenizer cursor. 143 | */ 144 | int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid); 145 | }; 146 | 147 | struct sqlite3_tokenizer { 148 | const sqlite3_tokenizer_module *pModule; /* The module for this tokenizer */ 149 | /* Tokenizer implementations will typically add additional fields */ 150 | }; 151 | 152 | struct sqlite3_tokenizer_cursor { 153 | sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */ 154 | /* Tokenizer implementations will typically add additional fields */ 155 | }; 156 | 157 | int fts3_global_term_cnt(int iTerm, int iCol); 158 | int fts3_term_cnt(int iTerm, int iCol); 159 | 160 | 161 | #endif /* _FTS3_TOKENIZER_H_ */ 162 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Typed/CustomFunctions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | public extension Connection { 26 | 27 | /// Creates or redefines a custom SQL function. 28 | /// 29 | /// - Parameters: 30 | /// 31 | /// - function: The name of the function to create or redefine. 32 | /// 33 | /// - deterministic: Whether or not the function is deterministic (_i.e._ 34 | /// the function always returns the same result for a given input). 35 | /// 36 | /// Default: `false` 37 | /// 38 | /// - block: A block of code to run when the function is called. 39 | /// The assigned types must be explicit. 40 | /// 41 | /// - Returns: A closure returning an SQL expression to call the function. 42 | public func createFunction(function: String, deterministic: Bool = false, _ block: () -> Z) throws -> (() -> Expression) { 43 | let fn = try createFunction(function, 0, deterministic) { _ in block() } 44 | return { fn([]) } 45 | } 46 | 47 | public func createFunction(function: String, deterministic: Bool = false, _ block: () -> Z?) throws -> (() -> Expression) { 48 | let fn = try createFunction(function, 0, deterministic) { _ in block() } 49 | return { fn([]) } 50 | } 51 | 52 | // MARK: - 53 | 54 | public func createFunction(function: String, deterministic: Bool = false, _ block: A -> Z) throws -> (Expression -> Expression) { 55 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0])) } 56 | return { arg in fn([arg]) } 57 | } 58 | 59 | public func createFunction(function function: String, deterministic: Bool = false, _ block: A? -> Z) throws -> (Expression -> Expression) { 60 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value)) } 61 | return { arg in fn([arg]) } 62 | } 63 | 64 | public func createFunction(function function: String, deterministic: Bool = false, _ block: A -> Z?) throws -> (Expression -> Expression) { 65 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0])) } 66 | return { arg in fn([arg]) } 67 | } 68 | 69 | public func createFunction(function function: String, deterministic: Bool = false, _ block: A? -> Z?) throws -> (Expression -> Expression) { 70 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value)) } 71 | return { arg in fn([arg]) } 72 | } 73 | 74 | // MARK: - 75 | 76 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A, B) -> Z) throws -> (Expression, Expression) -> Expression { 77 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0]), value(args[1])) } 78 | return { a, b in fn([a, b]) } 79 | } 80 | 81 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A?, B) -> Z) throws -> (Expression, Expression) -> Expression { 82 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value), value(args[1])) } 83 | return { a, b in fn([a, b]) } 84 | } 85 | 86 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A, B?) -> Z) throws -> (Expression, Expression) -> Expression { 87 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0]), args[1].map(value)) } 88 | return { a, b in fn([a, b]) } 89 | } 90 | 91 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A, B) -> Z?) throws -> (Expression, Expression) -> Expression { 92 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0]), value(args[1])) } 93 | return { a, b in fn([a, b]) } 94 | } 95 | 96 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A?, B?) -> Z) throws -> (Expression, Expression) -> Expression { 97 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value), args[1].map(value)) } 98 | return { a, b in fn([a, b]) } 99 | } 100 | 101 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A?, B) -> Z?) throws -> (Expression, Expression) -> Expression { 102 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value), value(args[1])) } 103 | return { a, b in fn([a, b]) } 104 | } 105 | 106 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A, B?) -> Z?) throws -> (Expression, Expression) -> Expression { 107 | let fn = try createFunction(function, 1, deterministic) { args in block(value(args[0]), args[1].map(value)) } 108 | return { a, b in fn([a, b]) } 109 | } 110 | 111 | public func createFunction(function: String, deterministic: Bool = false, _ block: (A?, B?) -> Z?) throws -> (Expression, Expression) -> Expression { 112 | let fn = try createFunction(function, 1, deterministic) { args in block(args[0].map(value), args[1].map(value)) } 113 | return { a, b in fn([a, b]) } 114 | } 115 | 116 | // MARK: - 117 | 118 | private func createFunction(function: String, _ argumentCount: UInt, _ deterministic: Bool, _ block: [Binding?] -> Z) throws -> ([Expressible] -> Expression) { 119 | createFunction(function, argumentCount: argumentCount, deterministic: deterministic) { arguments in 120 | block(arguments).datatypeValue 121 | } 122 | return { arguments in 123 | function.quote().wrap(", ".join(arguments)) 124 | } 125 | } 126 | 127 | private func createFunction(function: String, _ argumentCount: UInt, _ deterministic: Bool, _ block: [Binding?] -> Z?) throws -> ([Expressible] -> Expression) { 128 | createFunction(function, argumentCount: argumentCount, deterministic: deterministic) { arguments in 129 | block(arguments)?.datatypeValue 130 | } 131 | return { arguments in 132 | function.quote().wrap(", ".join(arguments)) 133 | } 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Typed/AggregateFunctions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | extension ExpressionType where UnderlyingType : Value { 26 | 27 | /// Builds a copy of the expression prefixed with the `DISTINCT` keyword. 28 | /// 29 | /// let name = Expression("name") 30 | /// name.distinct 31 | /// // DISTINCT "name" 32 | /// 33 | /// - Returns: A copy of the expression prefixed with the `DISTINCT` 34 | /// keyword. 35 | public var distinct: Expression { 36 | return Expression("DISTINCT \(template)", bindings) 37 | } 38 | 39 | /// Builds a copy of the expression wrapped with the `count` aggregate 40 | /// function. 41 | /// 42 | /// let name = Expression("name") 43 | /// name.count 44 | /// // count("name") 45 | /// name.distinct.count 46 | /// // count(DISTINCT "name") 47 | /// 48 | /// - Returns: A copy of the expression wrapped with the `count` aggregate 49 | /// function. 50 | public var count: Expression { 51 | return wrap(self) 52 | } 53 | 54 | } 55 | 56 | extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : Value { 57 | 58 | /// Builds a copy of the expression prefixed with the `DISTINCT` keyword. 59 | /// 60 | /// let name = Expression("name") 61 | /// name.distinct 62 | /// // DISTINCT "name" 63 | /// 64 | /// - Returns: A copy of the expression prefixed with the `DISTINCT` 65 | /// keyword. 66 | public var distinct: Expression { 67 | return Expression("DISTINCT \(template)", bindings) 68 | } 69 | 70 | /// Builds a copy of the expression wrapped with the `count` aggregate 71 | /// function. 72 | /// 73 | /// let name = Expression("name") 74 | /// name.count 75 | /// // count("name") 76 | /// name.distinct.count 77 | /// // count(DISTINCT "name") 78 | /// 79 | /// - Returns: A copy of the expression wrapped with the `count` aggregate 80 | /// function. 81 | public var count: Expression { 82 | return wrap(self) 83 | } 84 | 85 | } 86 | 87 | extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : Comparable { 88 | 89 | /// Builds a copy of the expression wrapped with the `max` aggregate 90 | /// function. 91 | /// 92 | /// let age = Expression("age") 93 | /// age.max 94 | /// // max("age") 95 | /// 96 | /// - Returns: A copy of the expression wrapped with the `max` aggregate 97 | /// function. 98 | public var max: Expression { 99 | return wrap(self) 100 | } 101 | 102 | /// Builds a copy of the expression wrapped with the `min` aggregate 103 | /// function. 104 | /// 105 | /// let age = Expression("age") 106 | /// age.min 107 | /// // min("age") 108 | /// 109 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 110 | /// function. 111 | public var min: Expression { 112 | return wrap(self) 113 | } 114 | 115 | } 116 | 117 | extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : Value, UnderlyingType.WrappedType.Datatype : Comparable { 118 | 119 | /// Builds a copy of the expression wrapped with the `max` aggregate 120 | /// function. 121 | /// 122 | /// let age = Expression("age") 123 | /// age.max 124 | /// // max("age") 125 | /// 126 | /// - Returns: A copy of the expression wrapped with the `max` aggregate 127 | /// function. 128 | public var max: Expression { 129 | return wrap(self) 130 | } 131 | 132 | /// Builds a copy of the expression wrapped with the `min` aggregate 133 | /// function. 134 | /// 135 | /// let age = Expression("age") 136 | /// age.min 137 | /// // min("age") 138 | /// 139 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 140 | /// function. 141 | public var min: Expression { 142 | return wrap(self) 143 | } 144 | 145 | } 146 | 147 | extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : Number { 148 | 149 | /// Builds a copy of the expression wrapped with the `avg` aggregate 150 | /// function. 151 | /// 152 | /// let salary = Expression("salary") 153 | /// salary.average 154 | /// // avg("salary") 155 | /// 156 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 157 | /// function. 158 | public var average: Expression { 159 | return "avg".wrap(self) 160 | } 161 | 162 | /// Builds a copy of the expression wrapped with the `sum` aggregate 163 | /// function. 164 | /// 165 | /// let salary = Expression("salary") 166 | /// salary.sum 167 | /// // sum("salary") 168 | /// 169 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 170 | /// function. 171 | public var sum: Expression { 172 | return wrap(self) 173 | } 174 | 175 | /// Builds a copy of the expression wrapped with the `total` aggregate 176 | /// function. 177 | /// 178 | /// let salary = Expression("salary") 179 | /// salary.total 180 | /// // total("salary") 181 | /// 182 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 183 | /// function. 184 | public var total: Expression { 185 | return wrap(self) 186 | } 187 | 188 | } 189 | 190 | extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : Value, UnderlyingType.WrappedType.Datatype : Number { 191 | 192 | /// Builds a copy of the expression wrapped with the `avg` aggregate 193 | /// function. 194 | /// 195 | /// let salary = Expression("salary") 196 | /// salary.average 197 | /// // avg("salary") 198 | /// 199 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 200 | /// function. 201 | public var average: Expression { 202 | return "avg".wrap(self) 203 | } 204 | 205 | /// Builds a copy of the expression wrapped with the `sum` aggregate 206 | /// function. 207 | /// 208 | /// let salary = Expression("salary") 209 | /// salary.sum 210 | /// // sum("salary") 211 | /// 212 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 213 | /// function. 214 | public var sum: Expression { 215 | return wrap(self) 216 | } 217 | 218 | /// Builds a copy of the expression wrapped with the `total` aggregate 219 | /// function. 220 | /// 221 | /// let salary = Expression("salary") 222 | /// salary.total 223 | /// // total("salary") 224 | /// 225 | /// - Returns: A copy of the expression wrapped with the `min` aggregate 226 | /// function. 227 | public var total: Expression { 228 | return wrap(self) 229 | } 230 | 231 | } 232 | 233 | extension ExpressionType where UnderlyingType == Int { 234 | 235 | @warn_unused_result static func count(star: Star) -> Expression { 236 | return wrap(star(nil, nil)) 237 | } 238 | 239 | } 240 | 241 | /// Builds an expression representing `count(*)` (when called with the `*` 242 | /// function literal). 243 | /// 244 | /// count(*) 245 | /// // count(*) 246 | /// 247 | /// - Returns: An expression returning `count(*)` (when called with the `*` 248 | /// function literal). 249 | @warn_unused_result public func count(star: Star) -> Expression { 250 | return Expression.count(star) 251 | } 252 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/README.md: -------------------------------------------------------------------------------- 1 | # SQLite.swift 2 | 3 | [![Build Status][Badge]][Travis] [![CocoaPods Version](https://cocoapod-badges.herokuapp.com/v/SQLite.swift/badge.png)](http://cocoadocs.org/docsets/SQLite.swift) [![Platform](https://cocoapod-badges.herokuapp.com/p/SQLite.swift/badge.png)](http://cocoadocs.org/docsets/SQLite.swift) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Join the chat at https://gitter.im/stephencelis/SQLite.swift](https://badges.gitter.im/stephencelis/SQLite.swift.svg)](https://gitter.im/stephencelis/SQLite.swift) 4 | 5 | A type-safe, [Swift][]-language layer over [SQLite3][]. 6 | 7 | [SQLite.swift][] provides compile-time confidence in SQL statement 8 | syntax _and_ intent. 9 | 10 | [Badge]: https://img.shields.io/travis/stephencelis/SQLite.swift/master.svg?style=flat 11 | [Travis]: https://travis-ci.org/stephencelis/SQLite.swift 12 | [Swift]: https://developer.apple.com/swift/ 13 | [SQLite3]: http://www.sqlite.org 14 | [SQLite.swift]: https://github.com/stephencelis/SQLite.swift 15 | 16 | 17 | ## Features 18 | 19 | - A pure-Swift interface 20 | - A type-safe, optional-aware SQL expression builder 21 | - A flexible, chainable, lazy-executing query layer 22 | - Automatically-typed data access 23 | - A lightweight, uncomplicated query and parameter binding interface 24 | - Developer-friendly error handling and debugging 25 | - [Full-text search][] support 26 | - [Well-documented][See Documentation] 27 | - Extensively tested 28 | - Companion project has [SQLCipher support](https://github.com/stephencelis/SQLiteCipher.swift) 29 | - Active support at [StackOverflow](http://stackoverflow.com/questions/tagged/sqlite.swift), and [Gitter Chat Room](https://gitter.im/stephencelis/SQLite.swift) (_experimental_) 30 | 31 | [Full-text search]: Documentation/Index.md#full-text-search 32 | [See Documentation]: Documentation/Index.md#sqliteswift-documentation 33 | 34 | 35 | ## Usage 36 | 37 | ``` swift 38 | import SQLite 39 | 40 | let db = try Connection("path/to/db.sqlite3") 41 | 42 | let users = Table("users") 43 | let id = Expression("id") 44 | let name = Expression("name") 45 | let email = Expression("email") 46 | 47 | try db.run(users.create { t in 48 | t.column(id, primaryKey: true) 49 | t.column(name) 50 | t.column(email, unique: true) 51 | }) 52 | // CREATE TABLE "users" ( 53 | // "id" INTEGER PRIMARY KEY NOT NULL, 54 | // "name" TEXT, 55 | // "email" TEXT NOT NULL UNIQUE 56 | // ) 57 | 58 | let insert = users.insert(name <- "Alice", email <- "alice@mac.com") 59 | let rowid = try db.run(insert) 60 | // INSERT INTO "users" ("name", "email") VALUES ('Alice', 'alice@mac.com') 61 | 62 | for user in try db.prepare(users) { 63 | print("id: \(user[id]), name: \(user[name]), email: \(user[email])") 64 | // id: 1, name: Optional("Alice"), email: alice@mac.com 65 | } 66 | // SELECT * FROM "users" 67 | 68 | let alice = users.filter(id == rowid) 69 | 70 | try db.run(alice.update(email <- email.replace("mac.com", with: "me.com"))) 71 | // UPDATE "users" SET "email" = replace("email", 'mac.com', 'me.com') 72 | // WHERE ("id" = 1) 73 | 74 | try db.run(alice.delete()) 75 | // DELETE FROM "users" WHERE ("id" = 1) 76 | 77 | db.scalar(users.count) // 0 78 | // SELECT count(*) FROM "users" 79 | ``` 80 | 81 | SQLite.swift also works as a lightweight, Swift-friendly wrapper over the C 82 | API. 83 | 84 | ``` swift 85 | let stmt = try db.prepare("INSERT INTO users (email) VALUES (?)") 86 | for email in ["betty@icloud.com", "cathy@icloud.com"] { 87 | try stmt.run(email) 88 | } 89 | 90 | db.totalChanges // 3 91 | db.changes // 1 92 | db.lastInsertRowid // 3 93 | 94 | for row in try db.prepare("SELECT id, email FROM users") { 95 | print("id: \(row[0]), email: \(row[1])") 96 | // id: Optional(2), email: Optional("betty@icloud.com") 97 | // id: Optional(3), email: Optional("cathy@icloud.com") 98 | } 99 | 100 | db.scalar("SELECT count(*) FROM users") // 2 101 | ``` 102 | 103 | [Read the documentation][See Documentation] or explore more, 104 | interactively, from the Xcode project’s playground. 105 | 106 | ![SQLite.playground Screen Shot](Documentation/Resources/playground@2x.png) 107 | 108 | For a more comprehensive example, see [this article](http://masteringswift.blogspot.com/2015/09/create-data-access-layer-with.html) and the [companion repository](https://github.com/hoffmanjon/SQLiteDataAccessLayer2/tree/master). 109 | 110 | ## Installation 111 | 112 | > _Note:_ SQLite.swift requires Swift 2 (and [Xcode][] 7) or greater. 113 | > 114 | > The following instructions apply to targets that support embedded 115 | > Swift frameworks. To use SQLite.swift in iOS 7 or an OS X command line 116 | > tool, please read the [Frameworkless Targets][] section of the 117 | > documentation. 118 | 119 | 120 | ### Carthage 121 | 122 | [Carthage][] is a simple, decentralized dependency manager for Cocoa. To 123 | install SQLite.swift with Carthage: 124 | 125 | 1. Make sure Carthage is [installed][Carthage Installation]. 126 | 127 | 2. Update your Cartfile to include the following: 128 | 129 | ``` 130 | github "stephencelis/SQLite.swift" ~> 0.10.1 131 | ``` 132 | 133 | 3. Run `carthage update` and [add the appropriate framework][Carthage Usage]. 134 | 135 | 136 | [Carthage]: https://github.com/Carthage/Carthage 137 | [Carthage Installation]: https://github.com/Carthage/Carthage#installing-carthage 138 | [Carthage Usage]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application 139 | 140 | 141 | ### CocoaPods 142 | 143 | [CocoaPods][] is a dependency manager for Cocoa projects. To install 144 | SQLite.swift with CocoaPods: 145 | 146 | 1. Make sure the latest CocoaPods beta is [installed][CocoaPods 147 | Installation]. (SQLite.swift requires version 1.0.0.beta.6 or greater.) 148 | 149 | ``` sh 150 | # Using the default Ruby install will require you to use sudo when 151 | # installing and updating gems. 152 | sudo gem install --pre cocoapods 153 | ``` 154 | 155 | 2. Update your Podfile to include the following: 156 | 157 | ``` ruby 158 | use_frameworks! 159 | 160 | pod 'SQLite.swift', '~> 0.10.1' 161 | ``` 162 | 163 | 3. Run `pod install`. 164 | 165 | [CocoaPods]: https://cocoapods.org 166 | [CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started 167 | 168 | 169 | ### Manual 170 | 171 | To install SQLite.swift as an Xcode sub-project: 172 | 173 | 1. Drag the **SQLite.xcodeproj** file into your own project. 174 | ([Submodule][], clone, or [download][] the project first.) 175 | 176 | ![Installation Screen Shot](Documentation/Resources/installation@2x.png) 177 | 178 | 2. In your target’s **General** tab, click the **+** button under **Linked 179 | Frameworks and Libraries**. 180 | 181 | 3. Select the appropriate **SQLite.framework** for your platform. 182 | 183 | 4. **Add**. 184 | 185 | [Frameworkless Targets]: Documentation/Index.md#frameworkless-targets 186 | [Xcode]: https://developer.apple.com/xcode/downloads/ 187 | [Submodule]: http://git-scm.com/book/en/Git-Tools-Submodules 188 | [download]: https://github.com/stephencelis/SQLite.swift/archive/master.zip 189 | 190 | 191 | ## Communication 192 | 193 | [See the planning document] for a roadmap and existing feature requests. 194 | 195 | [Read the contributing guidelines][]. The _TL;DR_ (but please; _R_): 196 | 197 | - Need **help** or have a **general question**? [Ask on Stack 198 | Overflow][] (tag `sqlite.swift`). 199 | - Found a **bug** or have a **feature request**? [Open an issue][]. 200 | - Want to **contribute**? [Submit a pull request][]. 201 | 202 | [See the planning document]: /Documentation/Planning.md 203 | [Read the contributing guidelines]: ./CONTRIBUTING.md#contributing 204 | [Ask on Stack Overflow]: http://stackoverflow.com/questions/tagged/sqlite.swift 205 | [Open an issue]: https://github.com/stephencelis/SQLite.swift/issues/new 206 | [Submit a pull request]: https://github.com/stephencelis/SQLite.swift/fork 207 | 208 | 209 | ## Author 210 | 211 | - [Stephen Celis](mailto:stephen@stephencelis.com) 212 | ([@stephencelis](https://twitter.com/stephencelis)) 213 | 214 | 215 | ## License 216 | 217 | SQLite.swift is available under the MIT license. See [the LICENSE 218 | file](./LICENSE.txt) for more information. 219 | 220 | ## Related 221 | 222 | These projects enhance or use SQLite.swift: 223 | 224 | - [SQLiteCipher.swift](https://github.com/stephencelis/SQLiteCipher.swift) 225 | - [SQLiteMigrationManager.swift](https://github.com/garriguv/SQLiteMigrationManager.swift) (inspired by [FMDBMigrationManager](https://github.com/layerhq/FMDBMigrationManager)) 226 | 227 | 228 | ## Alternatives 229 | 230 | Looking for something else? Try another Swift wrapper (or [FMDB][]): 231 | 232 | - [Camembert](https://github.com/remirobert/Camembert) 233 | - [EonilSQLite3](https://github.com/Eonil/SQLite3) 234 | - [SQLiteDB](https://github.com/FahimF/SQLiteDB) 235 | - [Squeal](https://github.com/nerdyc/Squeal) 236 | - [SwiftData](https://github.com/ryanfowler/SwiftData) 237 | - [SwiftSQLite](https://github.com/chrismsimpson/SwiftSQLite) 238 | 239 | [FMDB]: https://github.com/ccgus/fmdb 240 | -------------------------------------------------------------------------------- /Pods/SQLite.swift/SQLite/Core/Statement.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SQLite.swift 3 | // https://github.com/stephencelis/SQLite.swift 4 | // Copyright © 2014-2015 Stephen Celis. 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 14 | // all 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 22 | // THE SOFTWARE. 23 | // 24 | 25 | import CSQLite 26 | 27 | /// A single SQL statement. 28 | public final class Statement { 29 | 30 | private var handle: COpaquePointer = nil 31 | 32 | private let connection: Connection 33 | 34 | init(_ connection: Connection, _ SQL: String) throws { 35 | self.connection = connection 36 | try connection.check(sqlite3_prepare_v2(connection.handle, SQL, -1, &handle, nil)) 37 | } 38 | 39 | deinit { 40 | sqlite3_finalize(handle) 41 | } 42 | 43 | public lazy var columnCount: Int = Int(sqlite3_column_count(self.handle)) 44 | 45 | public lazy var columnNames: [String] = (0.. Statement { 58 | return bind(values) 59 | } 60 | 61 | /// Binds a list of parameters to a statement. 62 | /// 63 | /// - Parameter values: A list of parameters to bind to the statement. 64 | /// 65 | /// - Returns: The statement object (useful for chaining). 66 | public func bind(values: [Binding?]) -> Statement { 67 | if values.isEmpty { return self } 68 | reset() 69 | guard values.count == Int(sqlite3_bind_parameter_count(handle)) else { 70 | fatalError("\(sqlite3_bind_parameter_count(handle)) values expected, \(values.count) passed") 71 | } 72 | for idx in 1...values.count { bind(values[idx - 1], atIndex: idx) } 73 | return self 74 | } 75 | 76 | /// Binds a dictionary of named parameters to a statement. 77 | /// 78 | /// - Parameter values: A dictionary of named parameters to bind to the 79 | /// statement. 80 | /// 81 | /// - Returns: The statement object (useful for chaining). 82 | public func bind(values: [String: Binding?]) -> Statement { 83 | reset() 84 | for (name, value) in values { 85 | let idx = sqlite3_bind_parameter_index(handle, name) 86 | guard idx > 0 else { 87 | fatalError("parameter not found: \(name)") 88 | } 89 | bind(value, atIndex: Int(idx)) 90 | } 91 | return self 92 | } 93 | 94 | private func bind(value: Binding?, atIndex idx: Int) { 95 | if value == nil { 96 | sqlite3_bind_null(handle, Int32(idx)) 97 | } else if let value = value as? Blob { 98 | sqlite3_bind_blob(handle, Int32(idx), value.bytes, Int32(value.bytes.count), SQLITE_TRANSIENT) 99 | } else if let value = value as? Double { 100 | sqlite3_bind_double(handle, Int32(idx), value) 101 | } else if let value = value as? Int64 { 102 | sqlite3_bind_int64(handle, Int32(idx), value) 103 | } else if let value = value as? String { 104 | sqlite3_bind_text(handle, Int32(idx), value, -1, SQLITE_TRANSIENT) 105 | } else if let value = value as? Int { 106 | self.bind(value.datatypeValue, atIndex: idx) 107 | } else if let value = value as? Bool { 108 | self.bind(value.datatypeValue, atIndex: idx) 109 | } else if let value = value { 110 | fatalError("tried to bind unexpected value \(value)") 111 | } 112 | } 113 | 114 | /// - Parameter bindings: A list of parameters to bind to the statement. 115 | /// 116 | /// - Throws: `Result.Error` if query execution fails. 117 | /// 118 | /// - Returns: The statement object (useful for chaining). 119 | public func run(bindings: Binding?...) throws -> Statement { 120 | guard bindings.isEmpty else { 121 | return try run(bindings) 122 | } 123 | 124 | reset(clearBindings: false) 125 | repeat {} while try step() 126 | return self 127 | } 128 | 129 | /// - Parameter bindings: A list of parameters to bind to the statement. 130 | /// 131 | /// - Throws: `Result.Error` if query execution fails. 132 | /// 133 | /// - Returns: The statement object (useful for chaining). 134 | public func run(bindings: [Binding?]) throws -> Statement { 135 | return try bind(bindings).run() 136 | } 137 | 138 | /// - Parameter bindings: A dictionary of named parameters to bind to the 139 | /// statement. 140 | /// 141 | /// - Throws: `Result.Error` if query execution fails. 142 | /// 143 | /// - Returns: The statement object (useful for chaining). 144 | public func run(bindings: [String: Binding?]) throws -> Statement { 145 | return try bind(bindings).run() 146 | } 147 | 148 | /// - Parameter bindings: A list of parameters to bind to the statement. 149 | /// 150 | /// - Returns: The first value of the first row returned. 151 | @warn_unused_result public func scalar(bindings: Binding?...) -> Binding? { 152 | guard bindings.isEmpty else { 153 | return scalar(bindings) 154 | } 155 | 156 | reset(clearBindings: false) 157 | try! step() 158 | return row[0] 159 | } 160 | 161 | /// - Parameter bindings: A list of parameters to bind to the statement. 162 | /// 163 | /// - Returns: The first value of the first row returned. 164 | @warn_unused_result public func scalar(bindings: [Binding?]) -> Binding? { 165 | return bind(bindings).scalar() 166 | } 167 | 168 | 169 | /// - Parameter bindings: A dictionary of named parameters to bind to the 170 | /// statement. 171 | /// 172 | /// - Returns: The first value of the first row returned. 173 | @warn_unused_result public func scalar(bindings: [String: Binding?]) -> Binding? { 174 | return bind(bindings).scalar() 175 | } 176 | 177 | public func step() throws -> Bool { 178 | return try connection.sync { try self.connection.check(sqlite3_step(self.handle)) == SQLITE_ROW } 179 | } 180 | 181 | private func reset(clearBindings shouldClear: Bool = true) { 182 | sqlite3_reset(handle) 183 | if (shouldClear) { sqlite3_clear_bindings(handle) } 184 | } 185 | 186 | } 187 | 188 | extension Statement : SequenceType { 189 | 190 | public func generate() -> Statement { 191 | reset(clearBindings: false) 192 | return self 193 | } 194 | 195 | } 196 | 197 | extension Statement : GeneratorType { 198 | 199 | public func next() -> [Binding?]? { 200 | return try! step() ? Array(row) : nil 201 | } 202 | 203 | } 204 | 205 | extension Statement : CustomStringConvertible { 206 | 207 | public var description: String { 208 | return String.fromCString(sqlite3_sql(handle))! 209 | } 210 | 211 | } 212 | 213 | public struct Cursor { 214 | 215 | private let handle: COpaquePointer 216 | 217 | private let columnCount: Int 218 | 219 | private init(_ statement: Statement) { 220 | handle = statement.handle 221 | columnCount = statement.columnCount 222 | } 223 | 224 | public subscript(idx: Int) -> Double { 225 | return sqlite3_column_double(handle, Int32(idx)) 226 | } 227 | 228 | public subscript(idx: Int) -> Int64 { 229 | return sqlite3_column_int64(handle, Int32(idx)) 230 | } 231 | 232 | public subscript(idx: Int) -> String { 233 | return String.fromCString(UnsafePointer(sqlite3_column_text(handle, Int32(idx)))) ?? "" 234 | } 235 | 236 | public subscript(idx: Int) -> Blob { 237 | let bytes = sqlite3_column_blob(handle, Int32(idx)) 238 | let length = Int(sqlite3_column_bytes(handle, Int32(idx))) 239 | return Blob(bytes: bytes, length: length) 240 | } 241 | 242 | // MARK: - 243 | 244 | public subscript(idx: Int) -> Bool { 245 | return Bool.fromDatatypeValue(self[idx]) 246 | } 247 | 248 | public subscript(idx: Int) -> Int { 249 | return Int.fromDatatypeValue(self[idx]) 250 | } 251 | 252 | } 253 | 254 | /// Cursors provide direct access to a statement’s current row. 255 | extension Cursor : SequenceType { 256 | 257 | public subscript(idx: Int) -> Binding? { 258 | switch sqlite3_column_type(handle, Int32(idx)) { 259 | case SQLITE_BLOB: 260 | return self[idx] as Blob 261 | case SQLITE_FLOAT: 262 | return self[idx] as Double 263 | case SQLITE_INTEGER: 264 | return self[idx] as Int64 265 | case SQLITE_NULL: 266 | return nil 267 | case SQLITE_TEXT: 268 | return self[idx] as String 269 | case let type: 270 | fatalError("unsupported column type: \(type)") 271 | } 272 | } 273 | 274 | public func generate() -> AnyGenerator { 275 | var idx = 0 276 | return AnyGenerator { 277 | if idx >= self.columnCount { 278 | return Optional.None 279 | } else { 280 | idx += 1 281 | return self[idx - 1] 282 | } 283 | } 284 | } 285 | 286 | } 287 | --------------------------------------------------------------------------------