├── .gitignore ├── README.md ├── swift-camera-sample.xcodeproj └── project.pbxproj ├── swift-camera-sample ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist └── ViewController.swift └── swift-camera-sampleTests ├── Info.plist └── swift_camera_sampleTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Swift Camera Sample 2 | =================== 3 | 4 | This is just a sample camera app written in Swift. 5 | 6 | Now, initialize your camera device and preview only. 7 | -------------------------------------------------------------------------------- /swift-camera-sample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 44E9C2AA19440BE6007282AF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44E9C2A919440BE6007282AF /* AppDelegate.swift */; }; 11 | 44E9C2AC19440BE6007282AF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44E9C2AB19440BE6007282AF /* ViewController.swift */; }; 12 | 44E9C2AF19440BE6007282AF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 44E9C2AD19440BE6007282AF /* Main.storyboard */; }; 13 | 44E9C2B119440BE6007282AF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44E9C2B019440BE6007282AF /* Images.xcassets */; }; 14 | 44E9C2BD19440BE6007282AF /* swift_camera_sampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44E9C2BC19440BE6007282AF /* swift_camera_sampleTests.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | 44E9C2B719440BE6007282AF /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = 44E9C29C19440BE6007282AF /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = 44E9C2A319440BE6007282AF; 23 | remoteInfo = "swift-camera-sample"; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 44E9C2A419440BE6007282AF /* swift-camera-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift-camera-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 44E9C2A819440BE6007282AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 44E9C2A919440BE6007282AF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 31 | 44E9C2AB19440BE6007282AF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 32 | 44E9C2AE19440BE6007282AF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | 44E9C2B019440BE6007282AF /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | 44E9C2B619440BE6007282AF /* swift-camera-sampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "swift-camera-sampleTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 44E9C2BB19440BE6007282AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 44E9C2BC19440BE6007282AF /* swift_camera_sampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swift_camera_sampleTests.swift; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 44E9C2A119440BE6007282AF /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | 44E9C2B319440BE6007282AF /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 44E9C29B19440BE6007282AF = { 58 | isa = PBXGroup; 59 | children = ( 60 | 44E9C2A619440BE6007282AF /* swift-camera-sample */, 61 | 44E9C2B919440BE6007282AF /* swift-camera-sampleTests */, 62 | 44E9C2A519440BE6007282AF /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 44E9C2A519440BE6007282AF /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 44E9C2A419440BE6007282AF /* swift-camera-sample.app */, 70 | 44E9C2B619440BE6007282AF /* swift-camera-sampleTests.xctest */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 44E9C2A619440BE6007282AF /* swift-camera-sample */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 44E9C2A919440BE6007282AF /* AppDelegate.swift */, 79 | 44E9C2AB19440BE6007282AF /* ViewController.swift */, 80 | 44E9C2AD19440BE6007282AF /* Main.storyboard */, 81 | 44E9C2B019440BE6007282AF /* Images.xcassets */, 82 | 44E9C2A719440BE6007282AF /* Supporting Files */, 83 | ); 84 | path = "swift-camera-sample"; 85 | sourceTree = ""; 86 | }; 87 | 44E9C2A719440BE6007282AF /* Supporting Files */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 44E9C2A819440BE6007282AF /* Info.plist */, 91 | ); 92 | name = "Supporting Files"; 93 | sourceTree = ""; 94 | }; 95 | 44E9C2B919440BE6007282AF /* swift-camera-sampleTests */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 44E9C2BC19440BE6007282AF /* swift_camera_sampleTests.swift */, 99 | 44E9C2BA19440BE6007282AF /* Supporting Files */, 100 | ); 101 | path = "swift-camera-sampleTests"; 102 | sourceTree = ""; 103 | }; 104 | 44E9C2BA19440BE6007282AF /* Supporting Files */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 44E9C2BB19440BE6007282AF /* Info.plist */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | /* End PBXGroup section */ 113 | 114 | /* Begin PBXNativeTarget section */ 115 | 44E9C2A319440BE6007282AF /* swift-camera-sample */ = { 116 | isa = PBXNativeTarget; 117 | buildConfigurationList = 44E9C2C019440BE6007282AF /* Build configuration list for PBXNativeTarget "swift-camera-sample" */; 118 | buildPhases = ( 119 | 44E9C2A019440BE6007282AF /* Sources */, 120 | 44E9C2A119440BE6007282AF /* Frameworks */, 121 | 44E9C2A219440BE6007282AF /* Resources */, 122 | ); 123 | buildRules = ( 124 | ); 125 | dependencies = ( 126 | ); 127 | name = "swift-camera-sample"; 128 | productName = "swift-camera-sample"; 129 | productReference = 44E9C2A419440BE6007282AF /* swift-camera-sample.app */; 130 | productType = "com.apple.product-type.application"; 131 | }; 132 | 44E9C2B519440BE6007282AF /* swift-camera-sampleTests */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = 44E9C2C319440BE6007282AF /* Build configuration list for PBXNativeTarget "swift-camera-sampleTests" */; 135 | buildPhases = ( 136 | 44E9C2B219440BE6007282AF /* Sources */, 137 | 44E9C2B319440BE6007282AF /* Frameworks */, 138 | 44E9C2B419440BE6007282AF /* Resources */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | 44E9C2B819440BE6007282AF /* PBXTargetDependency */, 144 | ); 145 | name = "swift-camera-sampleTests"; 146 | productName = "swift-camera-sampleTests"; 147 | productReference = 44E9C2B619440BE6007282AF /* swift-camera-sampleTests.xctest */; 148 | productType = "com.apple.product-type.bundle.unit-test"; 149 | }; 150 | /* End PBXNativeTarget section */ 151 | 152 | /* Begin PBXProject section */ 153 | 44E9C29C19440BE6007282AF /* Project object */ = { 154 | isa = PBXProject; 155 | attributes = { 156 | LastSwiftMigration = 0720; 157 | LastSwiftUpdateCheck = 0720; 158 | LastUpgradeCheck = 0720; 159 | ORGANIZATIONNAME = "Shoken Fujisaki"; 160 | TargetAttributes = { 161 | 44E9C2A319440BE6007282AF = { 162 | CreatedOnToolsVersion = 6.0; 163 | }; 164 | 44E9C2B519440BE6007282AF = { 165 | CreatedOnToolsVersion = 6.0; 166 | TestTargetID = 44E9C2A319440BE6007282AF; 167 | }; 168 | }; 169 | }; 170 | buildConfigurationList = 44E9C29F19440BE6007282AF /* Build configuration list for PBXProject "swift-camera-sample" */; 171 | compatibilityVersion = "Xcode 3.2"; 172 | developmentRegion = English; 173 | hasScannedForEncodings = 0; 174 | knownRegions = ( 175 | en, 176 | Base, 177 | ); 178 | mainGroup = 44E9C29B19440BE6007282AF; 179 | productRefGroup = 44E9C2A519440BE6007282AF /* Products */; 180 | projectDirPath = ""; 181 | projectRoot = ""; 182 | targets = ( 183 | 44E9C2A319440BE6007282AF /* swift-camera-sample */, 184 | 44E9C2B519440BE6007282AF /* swift-camera-sampleTests */, 185 | ); 186 | }; 187 | /* End PBXProject section */ 188 | 189 | /* Begin PBXResourcesBuildPhase section */ 190 | 44E9C2A219440BE6007282AF /* Resources */ = { 191 | isa = PBXResourcesBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | 44E9C2AF19440BE6007282AF /* Main.storyboard in Resources */, 195 | 44E9C2B119440BE6007282AF /* Images.xcassets in Resources */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | 44E9C2B419440BE6007282AF /* Resources */ = { 200 | isa = PBXResourcesBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXResourcesBuildPhase section */ 207 | 208 | /* Begin PBXSourcesBuildPhase section */ 209 | 44E9C2A019440BE6007282AF /* Sources */ = { 210 | isa = PBXSourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | 44E9C2AC19440BE6007282AF /* ViewController.swift in Sources */, 214 | 44E9C2AA19440BE6007282AF /* AppDelegate.swift in Sources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | 44E9C2B219440BE6007282AF /* Sources */ = { 219 | isa = PBXSourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | 44E9C2BD19440BE6007282AF /* swift_camera_sampleTests.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | /* End PBXSourcesBuildPhase section */ 227 | 228 | /* Begin PBXTargetDependency section */ 229 | 44E9C2B819440BE6007282AF /* PBXTargetDependency */ = { 230 | isa = PBXTargetDependency; 231 | target = 44E9C2A319440BE6007282AF /* swift-camera-sample */; 232 | targetProxy = 44E9C2B719440BE6007282AF /* PBXContainerItemProxy */; 233 | }; 234 | /* End PBXTargetDependency section */ 235 | 236 | /* Begin PBXVariantGroup section */ 237 | 44E9C2AD19440BE6007282AF /* Main.storyboard */ = { 238 | isa = PBXVariantGroup; 239 | children = ( 240 | 44E9C2AE19440BE6007282AF /* Base */, 241 | ); 242 | name = Main.storyboard; 243 | sourceTree = ""; 244 | }; 245 | /* End PBXVariantGroup section */ 246 | 247 | /* Begin XCBuildConfiguration section */ 248 | 44E9C2BE19440BE6007282AF /* Debug */ = { 249 | isa = XCBuildConfiguration; 250 | buildSettings = { 251 | ALWAYS_SEARCH_USER_PATHS = NO; 252 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 253 | CLANG_CXX_LIBRARY = "libc++"; 254 | CLANG_ENABLE_MODULES = YES; 255 | CLANG_ENABLE_OBJC_ARC = YES; 256 | CLANG_WARN_BOOL_CONVERSION = YES; 257 | CLANG_WARN_CONSTANT_CONVERSION = YES; 258 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 259 | CLANG_WARN_EMPTY_BODY = YES; 260 | CLANG_WARN_ENUM_CONVERSION = YES; 261 | CLANG_WARN_INT_CONVERSION = YES; 262 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 266 | COPY_PHASE_STRIP = NO; 267 | ENABLE_STRICT_OBJC_MSGSEND = YES; 268 | ENABLE_TESTABILITY = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_DYNAMIC_NO_PIC = NO; 271 | GCC_OPTIMIZATION_LEVEL = 0; 272 | GCC_PREPROCESSOR_DEFINITIONS = ( 273 | "DEBUG=1", 274 | "$(inherited)", 275 | ); 276 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 284 | METAL_ENABLE_DEBUG_INFO = YES; 285 | ONLY_ACTIVE_ARCH = YES; 286 | SDKROOT = iphoneos; 287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 288 | }; 289 | name = Debug; 290 | }; 291 | 44E9C2BF19440BE6007282AF /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ALWAYS_SEARCH_USER_PATHS = NO; 295 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 296 | CLANG_CXX_LIBRARY = "libc++"; 297 | CLANG_ENABLE_MODULES = YES; 298 | CLANG_ENABLE_OBJC_ARC = YES; 299 | CLANG_WARN_BOOL_CONVERSION = YES; 300 | CLANG_WARN_CONSTANT_CONVERSION = YES; 301 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INT_CONVERSION = YES; 305 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 306 | CLANG_WARN_UNREACHABLE_CODE = YES; 307 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 308 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 309 | COPY_PHASE_STRIP = YES; 310 | ENABLE_NS_ASSERTIONS = NO; 311 | ENABLE_STRICT_OBJC_MSGSEND = YES; 312 | GCC_C_LANGUAGE_STANDARD = gnu99; 313 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 314 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 315 | GCC_WARN_UNDECLARED_SELECTOR = YES; 316 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 317 | GCC_WARN_UNUSED_FUNCTION = YES; 318 | GCC_WARN_UNUSED_VARIABLE = YES; 319 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 320 | METAL_ENABLE_DEBUG_INFO = NO; 321 | SDKROOT = iphoneos; 322 | VALIDATE_PRODUCT = YES; 323 | }; 324 | name = Release; 325 | }; 326 | 44E9C2C119440BE6007282AF /* Debug */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 330 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 331 | INFOPLIST_FILE = "swift-camera-sample/Info.plist"; 332 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 333 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 334 | PRODUCT_BUNDLE_IDENTIFIER = "com.kitchhike.${PRODUCT_NAME:rfc1034identifier}"; 335 | PRODUCT_NAME = "$(TARGET_NAME)"; 336 | PROVISIONING_PROFILE = ""; 337 | }; 338 | name = Debug; 339 | }; 340 | 44E9C2C219440BE6007282AF /* Release */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 344 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 345 | INFOPLIST_FILE = "swift-camera-sample/Info.plist"; 346 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = "com.kitchhike.${PRODUCT_NAME:rfc1034identifier}"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | PROVISIONING_PROFILE = ""; 351 | }; 352 | name = Release; 353 | }; 354 | 44E9C2C419440BE6007282AF /* Debug */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swift-camera-sample.app/swift-camera-sample"; 358 | FRAMEWORK_SEARCH_PATHS = ( 359 | "$(SDKROOT)/Developer/Library/Frameworks", 360 | "$(inherited)", 361 | ); 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | INFOPLIST_FILE = "swift-camera-sampleTests/Info.plist"; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 368 | METAL_ENABLE_DEBUG_INFO = YES; 369 | PRODUCT_BUNDLE_IDENTIFIER = "com.kitchhike.${PRODUCT_NAME:rfc1034identifier}"; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | TEST_HOST = "$(BUNDLE_LOADER)"; 372 | }; 373 | name = Debug; 374 | }; 375 | 44E9C2C519440BE6007282AF /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swift-camera-sample.app/swift-camera-sample"; 379 | FRAMEWORK_SEARCH_PATHS = ( 380 | "$(SDKROOT)/Developer/Library/Frameworks", 381 | "$(inherited)", 382 | ); 383 | INFOPLIST_FILE = "swift-camera-sampleTests/Info.plist"; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 385 | METAL_ENABLE_DEBUG_INFO = NO; 386 | PRODUCT_BUNDLE_IDENTIFIER = "com.kitchhike.${PRODUCT_NAME:rfc1034identifier}"; 387 | PRODUCT_NAME = "$(TARGET_NAME)"; 388 | TEST_HOST = "$(BUNDLE_LOADER)"; 389 | }; 390 | name = Release; 391 | }; 392 | /* End XCBuildConfiguration section */ 393 | 394 | /* Begin XCConfigurationList section */ 395 | 44E9C29F19440BE6007282AF /* Build configuration list for PBXProject "swift-camera-sample" */ = { 396 | isa = XCConfigurationList; 397 | buildConfigurations = ( 398 | 44E9C2BE19440BE6007282AF /* Debug */, 399 | 44E9C2BF19440BE6007282AF /* Release */, 400 | ); 401 | defaultConfigurationIsVisible = 0; 402 | defaultConfigurationName = Release; 403 | }; 404 | 44E9C2C019440BE6007282AF /* Build configuration list for PBXNativeTarget "swift-camera-sample" */ = { 405 | isa = XCConfigurationList; 406 | buildConfigurations = ( 407 | 44E9C2C119440BE6007282AF /* Debug */, 408 | 44E9C2C219440BE6007282AF /* Release */, 409 | ); 410 | defaultConfigurationIsVisible = 0; 411 | defaultConfigurationName = Release; 412 | }; 413 | 44E9C2C319440BE6007282AF /* Build configuration list for PBXNativeTarget "swift-camera-sampleTests" */ = { 414 | isa = XCConfigurationList; 415 | buildConfigurations = ( 416 | 44E9C2C419440BE6007282AF /* Debug */, 417 | 44E9C2C519440BE6007282AF /* Release */, 418 | ); 419 | defaultConfigurationIsVisible = 0; 420 | defaultConfigurationName = Release; 421 | }; 422 | /* End XCConfigurationList section */ 423 | }; 424 | rootObject = 44E9C29C19440BE6007282AF /* Project object */; 425 | } 426 | -------------------------------------------------------------------------------- /swift-camera-sample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swift-camera-sample 4 | // 5 | // Created by Shoken Fujisaki on 6/8/14. 6 | // Copyright (c) 2014 Shoken Fujisaki. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | func applicationWillResignActive(application: UIApplication) { 22 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 23 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 24 | } 25 | 26 | func applicationDidEnterBackground(application: UIApplication) { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | func applicationWillEnterForeground(application: UIApplication) { 32 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 33 | } 34 | 35 | func applicationDidBecomeActive(application: UIApplication) { 36 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 37 | } 38 | 39 | func applicationWillTerminate(application: UIApplication) { 40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 41 | } 42 | 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /swift-camera-sample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /swift-camera-sample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swift-camera-sample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swift-camera-sample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /swift-camera-sample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // swift-camera-sample 4 | // 5 | // Created by Shoken Fujisaki on 6/8/14. 6 | // Copyright (c) 2014 Shoken Fujisaki. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | 12 | class ViewController: UIViewController { 13 | 14 | var stillImageOutput: AVCaptureStillImageOutput! 15 | var session: AVCaptureSession! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | // Do any additional setup after loading the view, typically from a nib. 20 | 21 | // Start Camera 22 | self.configureCamera() 23 | } 24 | 25 | override func didReceiveMemoryWarning() { 26 | super.didReceiveMemoryWarning() 27 | // Dispose of any resources that can be recreated. 28 | } 29 | 30 | func configureCamera() -> Bool { 31 | // init camera device 32 | var captureDevice: AVCaptureDevice? 33 | let devices: NSArray = AVCaptureDevice.devices() 34 | 35 | // find back camera 36 | for device: AnyObject in devices { 37 | if device.position == AVCaptureDevicePosition.Back { 38 | captureDevice = device as? AVCaptureDevice 39 | } 40 | } 41 | 42 | if captureDevice != nil { 43 | // Debug 44 | print(captureDevice!.localizedName) 45 | print(captureDevice!.modelID) 46 | } else { 47 | print("Missing Camera") 48 | return false 49 | } 50 | 51 | // init device input 52 | do { 53 | let deviceInput: AVCaptureInput = try AVCaptureDeviceInput(device: captureDevice) as AVCaptureInput 54 | 55 | self.stillImageOutput = AVCaptureStillImageOutput() 56 | 57 | // init session 58 | self.session = AVCaptureSession() 59 | self.session.sessionPreset = AVCaptureSessionPresetPhoto 60 | self.session.addInput(deviceInput as AVCaptureInput) 61 | self.session.addOutput(self.stillImageOutput) 62 | 63 | // layer for preview 64 | let previewLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: self.session) as AVCaptureVideoPreviewLayer 65 | previewLayer.frame = self.view.bounds 66 | self.view.layer.addSublayer(previewLayer) 67 | 68 | self.session.startRunning() 69 | } 70 | catch { 71 | // handle error here 72 | } 73 | return true 74 | } 75 | 76 | } 77 | 78 | -------------------------------------------------------------------------------- /swift-camera-sampleTests/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 | -------------------------------------------------------------------------------- /swift-camera-sampleTests/swift_camera_sampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swift_camera_sampleTests.swift 3 | // swift-camera-sampleTests 4 | // 5 | // Created by Shoken Fujisaki on 6/8/14. 6 | // Copyright (c) 2014 Shoken Fujisaki. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class swift_camera_sampleTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------