(_ value: V, protocol: P.Type, adopter: (V, P) -> Void, from: UIResponder) {
21 | if let impl = findProtocolImplementation(`protocol`, from: from) {
22 | adopter(value, impl)
23 | return
24 | }
25 |
26 | next?.relayValue(value, protocol: `protocol`, adopter: adopter, from: from)
27 | }
28 |
29 | private func findProtocolImplementation(_ protocol: P.Type, from: UIResponder) -> P? {
30 | switch self {
31 | case let navi as UINavigationController:
32 | for viewController in navi.viewControllers where viewController != from {
33 | guard let impl = viewController as? P else {
34 | continue
35 | }
36 | return impl
37 | }
38 | return self as? P
39 | case let tab as UITabBarController:
40 | for viewController in tab.viewControllers ?? [] where viewController != from {
41 | guard let impl = viewController as? P else {
42 | continue
43 | }
44 | return impl
45 | }
46 | return self as? P
47 | default:
48 | return self as? P
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Lib/SegueContext/SegueCallback.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SegueCallback.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import UIKit
8 |
9 | // MARK: - HasCallback
10 |
11 | protocol HasCallback {
12 | associatedtype CallbackType
13 | typealias Callback = (CallbackType) -> Void
14 |
15 | var callback: Callback? { get }
16 | }
17 |
18 | // MARK: - UIResponder
19 |
20 | extension UIResponder {
21 | fileprivate var callbackKey: String { return #function }
22 | }
23 |
24 | extension HasCallback where Self: UIResponder {
25 | var callback: Callback? {
26 | return associatedObjects[callbackKey] as? Callback
27 | }
28 | }
29 |
30 | extension UIResponder {
31 | func bindCallback(type: V.Type, to responder: UIResponder?, callback newCallback: @escaping (V) -> Void) {
32 | switch responder {
33 | case let navi as UINavigationController:
34 | for viewController in navi.viewControllers {
35 | bindCallback(type: type, to: viewController, callback: newCallback)
36 | }
37 | case let tab as UITabBarController:
38 | for viewController in tab.viewControllers ?? [] {
39 | bindCallback(type: type, to: viewController, callback: newCallback)
40 | }
41 | default:
42 | responder?.associatedObjects[callbackKey] = newCallback
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Lib/SegueContext/SegueContext.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SegueContext.swift
3 | //
4 | // Created by ToKoRo on 2017-08-18.
5 | //
6 |
7 | import UIKit
8 |
9 | // MARK: - ContextHandler
10 |
11 | protocol ContextHandler {
12 | associatedtype ContextType
13 |
14 | var context: ContextType? { get }
15 | var contextSender: UIResponder? { get }
16 | }
17 |
18 | // MARK: - UIResponder
19 |
20 | extension UIResponder: HasAssociatedObjects {
21 | fileprivate var contextKey: String { return #function }
22 | fileprivate var contextSenderKey: String { return #function }
23 | }
24 |
25 | extension ContextHandler where Self: UIResponder {
26 | var context: ContextType? {
27 | return associatedObjects[contextKey] as? ContextType
28 | }
29 |
30 | var contextSender: UIResponder? {
31 | return associatedObjects[contextSenderKey] as? UIResponder
32 | }
33 | }
34 |
35 | extension UIResponder {
36 | func sendContext(_ context: Any?, to handler: UIResponder?) {
37 | switch handler {
38 | case let navi as UINavigationController:
39 | for viewController in navi.viewControllers {
40 | sendContext(context, to: viewController)
41 | }
42 | case let tab as UITabBarController:
43 | for viewController in tab.viewControllers ?? [] {
44 | sendContext(context, to: viewController)
45 | }
46 | default:
47 | handler?.associatedObjects[contextSenderKey] = self
48 | handler?.associatedObjects[contextKey] = context
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/AccessoryActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AccessoryActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol AccessoryActionHandler {
10 | func handleRemove(_ accessory: HMAccessory)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/AccessorySelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AccessorySelector.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol AccessorySelector {
10 | func selectAccessory(_ accessory: HMAccessory)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/AccessoryStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AccessoryStore.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol AccessoryStore {
10 | var accessoryStoreKind: AccessoryStoreKind { get }
11 | var accessories: [HMAccessory] { get }
12 | }
13 |
14 | enum AccessoryStoreKind {
15 | case home(HMHome)
16 | case room(HMRoom)
17 | case identifiers(AccessoryIdentifiers)
18 | }
19 |
20 | // MARK: - HMHome
21 |
22 | extension HMHome: AccessoryStore {
23 | var accessoryStoreKind: AccessoryStoreKind { return .home(self) }
24 | }
25 |
26 | // MARK: - HMRoom
27 |
28 | extension HMRoom: AccessoryStore {
29 | var accessoryStoreKind: AccessoryStoreKind { return .room(self) }
30 | }
31 |
32 | // MARK: - AccessoryIdentifiers
33 |
34 | struct AccessoryIdentifiers {
35 | let identifiers: [UUID]
36 | }
37 |
38 | extension AccessoryIdentifiers: AccessoryStore {
39 | var accessoryStoreKind: AccessoryStoreKind { return .identifiers(self) }
40 |
41 | var accessories: [HMAccessory] {
42 | var accessories: [HMAccessory] = []
43 | let homeManager = HMHomeManager.shared
44 | for home in homeManager.homes {
45 | for accessory in home.accessories where identifiers.contains(accessory.uniqueIdentifier) {
46 | accessories.append(accessory)
47 | }
48 | }
49 | return accessories
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionActionHandler {
10 | func handleRemove(_ action: HMAction)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionSelector {
10 | func selectAction(_ action: HMAction)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionSetActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionSetActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionSetActionHandler {
10 | func handleExecute(_ actionSet: HMActionSet)
11 | func handleRemove(_ actionSet: HMActionSet)
12 | }
13 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionSetSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionSetSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionSetSelector {
10 | func selectActionSet(_ actionSet: HMActionSet)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionSetStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionSetStore.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionSetStore {
10 | var actionSetStoreKind: ActionSetStoreKind { get }
11 | var actionSets: [HMActionSet] { get }
12 | }
13 |
14 | enum ActionSetStoreKind {
15 | case home(HMHome)
16 | case trigger(HMTrigger)
17 | }
18 |
19 | // MARK: - HMHome
20 |
21 | extension HMHome: ActionSetStore {
22 | var actionSetStoreKind: ActionSetStoreKind { return .home(self) }
23 | }
24 |
25 | // MARK: - HMTrigger
26 |
27 | extension HMTrigger: ActionSetStore {
28 | var actionSetStoreKind: ActionSetStoreKind { return .trigger(self) }
29 | }
30 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ActionStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ActionStore.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ActionStore {
10 | var actionStoreKind: ActionStoreKind { get }
11 | var actions: Set { get }
12 | }
13 |
14 | enum ActionStoreKind {
15 | case actionSet(HMActionSet)
16 | }
17 |
18 | // MARK: - HMActionSet
19 |
20 | extension HMActionSet: ActionStore {
21 | var actionStoreKind: ActionStoreKind { return .actionSet(self) }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/CharacteristicSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CharacteristicSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol CharacteristicSelector {
10 | func selectCharacteristic(_ characteristic: HMCharacteristic)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/CharacteristicStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CharacteristicStore.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol CharacteristicStore {
10 | var characteristicStoreKind: CharacteristicStoreKind { get }
11 | var characteristics: [HMCharacteristic] { get }
12 | }
13 |
14 | enum CharacteristicStoreKind {
15 | case service(HMService)
16 | case accessory(HMAccessory)
17 | case home(HMHome)
18 | }
19 |
20 | // MARK: - HMService
21 |
22 | extension HMService: CharacteristicStore {
23 | var characteristicStoreKind: CharacteristicStoreKind { return .service(self) }
24 | }
25 |
26 | // MARK: - HMAccessory
27 |
28 | extension HMAccessory: CharacteristicStore {
29 | var characteristicStoreKind: CharacteristicStoreKind { return .accessory(self) }
30 | var characteristics: [HMCharacteristic] { return allWritableCharacteristics }
31 | }
32 |
33 | // MARK: - HMHome
34 |
35 | extension HMHome: CharacteristicStore {
36 | var characteristicStoreKind: CharacteristicStoreKind { return .home(self) }
37 | var characteristics: [HMCharacteristic] { return allWritableCharacteristics }
38 | }
39 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/HomeActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HomeActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-08-20.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol HomeActionHandler {
10 | func handleRemove(_ home: HMHome)
11 | func handleMakePrimary(_ home: HMHome)
12 | }
13 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/RoomActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RoomActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol RoomActionHandler {
10 | func handleRemove(_ room: HMRoom)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/RoomSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RoomSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol RoomSelector {
10 | func selectRoom(_ room: HMRoom)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/RoomStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RoomStore.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol RoomStore {
10 | var roomStoreKind: RoomStoreKind { get }
11 | var rooms: [HMRoom] { get }
12 | }
13 |
14 | enum RoomStoreKind {
15 | case home(HMHome)
16 | case zone(HMZone)
17 | }
18 |
19 | // MARK: - HMHome
20 |
21 | extension HMHome: RoomStore {
22 | var roomStoreKind: RoomStoreKind { return .home(self) }
23 | }
24 |
25 | // MARK: - HMZone
26 |
27 | extension HMZone: RoomStore {
28 | var roomStoreKind: RoomStoreKind { return .zone(self) }
29 | }
30 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ServiceActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServiceActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ServiceActionHandler {
10 | func handleRemove(_ service: HMService)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ServiceGroupActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServiceGroupActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ServiceGroupActionHandler {
10 | func handleRemove(_ serviceGroup: HMServiceGroup)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ServiceSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServiceSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ServiceSelector {
10 | func selectService(_ service: HMService)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ServiceStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServiceStore.swift
3 | //
4 | // Created by ToKoRo on 2017-09-02.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ServiceStore {
10 | var serviceStoreKind: ServiceStoreKind { get }
11 | var services: [HMService] { get }
12 | var isServiceAddable: Bool { get }
13 | var isServiceRemovable: Bool { get }
14 | }
15 |
16 | enum ServiceStoreKind {
17 | case accessory(HMAccessory)
18 | case serviceGroup(HMServiceGroup)
19 | case home(HMHome)
20 | }
21 |
22 | // MARK: - HMAccessory
23 |
24 | extension HMAccessory: ServiceStore {
25 | var serviceStoreKind: ServiceStoreKind { return .accessory(self) }
26 | var isServiceAddable: Bool { return false }
27 | var isServiceRemovable: Bool { return false }
28 | }
29 |
30 | // MARK: - HMServiceGroup
31 |
32 | extension HMServiceGroup: ServiceStore {
33 | var serviceStoreKind: ServiceStoreKind { return .serviceGroup(self) }
34 | var isServiceAddable: Bool { return true }
35 | var isServiceRemovable: Bool { return true }
36 | }
37 |
38 | // MARK: - HMHome
39 |
40 | extension HMHome: ServiceStore {
41 | var serviceStoreKind: ServiceStoreKind { return .home(self) }
42 | var isServiceAddable: Bool { return false }
43 | var isServiceRemovable: Bool { return false }
44 | var services: [HMService] { return allServices }
45 | }
46 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/TriggerActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TriggerActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol TriggerActionHandler {
10 | func handleRemove(_ trigger: HMTrigger)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/TriggerSelector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TriggerSelector.swift
3 | //
4 | // Created by ToKoRo on 2017-09-03.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol TriggerSelector {
10 | func selectTrigger(_ trigger: HMTrigger)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Code/Protocol/ZoneActionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ZoneActionHandler.swift
3 | //
4 | // Created by ToKoRo on 2017-08-27.
5 | //
6 |
7 | import HomeKit
8 |
9 | protocol ZoneActionHandler {
10 | func handleRemove(_ zone: HMZone)
11 | }
12 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/HomeKitSample.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.homekit
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Resource/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/App/Resource/Assets.xcassets/Image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "scale" : "3x"
14 | }
15 | ],
16 | "info" : {
17 | "version" : 1,
18 | "author" : "xcode"
19 | }
20 | }
--------------------------------------------------------------------------------
/chapter_12/HomeKitSample/HomeKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // MetalImageRender
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/09/10.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "highsierra@3x.jpg",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UIStatusBarHidden
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/chapter_13/01_MetalImageRender/MetalImageRender/highsierra@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/01_MetalImageRender/MetalImageRender/highsierra@3x.jpg
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // MetalShaderColorFill
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/09/10.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UIStatusBarHidden
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Shaders.metal:
--------------------------------------------------------------------------------
1 | //
2 | // Shaders.metal
3 | // MetalShaderColorFill
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/09/23.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | #include
10 | using namespace metal;
11 |
12 | struct ColorInOut
13 | {
14 | float4 position [[ position ]];
15 | };
16 |
17 | vertex ColorInOut vertexShader(device float4 *positions [[ buffer(0) ]],
18 | uint vid [[ vertex_id ]])
19 | {
20 | ColorInOut out;
21 | out.position = positions[vid];
22 | return out;
23 | }
24 |
25 | fragment float4 fragmentShader(ColorInOut in [[ stage_in ]])
26 | {
27 | return float4(1,0,0,1);
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/highsierra@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/highsierra@3x.jpg
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // MetalShaderImageRender
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/09/10.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "highsierra@3x.jpg",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UIStatusBarHidden
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Shaders.metal:
--------------------------------------------------------------------------------
1 | //
2 | // Shaders.metal
3 | // MetalShaderImageRender
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/09/23.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | #include
10 | using namespace metal;
11 |
12 | struct ColorInOut
13 | {
14 | float4 position [[ position ]];
15 | float2 texCoords;
16 | };
17 |
18 | vertex ColorInOut vertexShader(device float4 *positions [[ buffer(0) ]],
19 | device float2 *texCoords [[ buffer(1) ]],
20 | uint vid [[ vertex_id ]])
21 | {
22 | ColorInOut out;
23 | out.position = positions[vid];
24 | out.texCoords = texCoords[vid];
25 | return out;
26 | }
27 |
28 | fragment float4 fragmentShader(ColorInOut in [[ stage_in ]],
29 | texture2d texture [[ texture(0) ]])
30 | {
31 | constexpr sampler colorSampler;
32 | float4 color = texture.sample(colorSampler, in.texCoords);
33 | return color;
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/highsierra@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/highsierra@3x.jpg
--------------------------------------------------------------------------------
/chapter_13/04_ARMetal1/ARMetal/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ARMetal1
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/07/17.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/chapter_13/04_ARMetal1/ARMetal1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/05_ARMetal2/ARMetal/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ARMetal2
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/07/17.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/chapter_13/05_ARMetal2/ARMetal2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/06_ARMetalArgumentBuffers/ARMetalArgumentBuffers.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_13/06_ARMetalArgumentBuffers/ARMetalArgumentBuffers/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ARMetalArgumentBuffers
4 | //
5 | // Created by Shuichi Tsutsumi on 2017/07/17.
6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | return true
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/chapter_13/common/SceneKitUtils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SceneKitUtils.swift
3 | //
4 | // Created by Shuichi Tsutsumi on 2017/09/04.
5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
6 | //
7 |
8 | import SceneKit
9 |
10 | func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 {
11 | return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z)
12 | }
13 |
14 | func += (left: inout SCNVector3, right: SCNVector3) {
15 | left = left + right
16 | }
17 |
18 | func - (left: SCNVector3, right: SCNVector3) -> SCNVector3 {
19 | return SCNVector3Make(left.x - right.x, left.y - right.y, left.z - right.z)
20 | }
21 |
22 | func * (vector: SCNVector3, scalar: Float) -> SCNVector3 {
23 | return SCNVector3Make(vector.x * scalar, vector.y * scalar, vector.z * scalar)
24 | }
25 |
26 | func / (left: SCNVector3, right: Float) -> SCNVector3 {
27 | return SCNVector3Make(left.x / right, left.y / right, left.z / right)
28 | }
29 |
30 | func /= (left: inout SCNVector3, right: Float) {
31 | left = left / right
32 | }
33 |
34 | extension SCNVector3 {
35 | func length() -> Float {
36 | return sqrtf(x * x + y * y + z * z)
37 | }
38 | }
39 |
40 | extension matrix_float4x4 {
41 | func position() -> SCNVector3 {
42 | let mat = SCNMatrix4(self)
43 | return SCNVector3(mat.m41, mat.m42, mat.m43)
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/chapter_13/common/TrackingState+Description.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TrackingState+Description.swift
3 | //
4 | // Created by Shuichi Tsutsumi on 2017/08/25.
5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved.
6 | //
7 |
8 | import ARKit
9 |
10 | extension ARCamera.TrackingState {
11 | public var description: String {
12 | switch self {
13 | case .notAvailable:
14 | return "TRACKING UNAVAILABLE"
15 | case .normal:
16 | return "TRACKING NORMAL"
17 | case .limited(let reason):
18 | switch reason {
19 | case .excessiveMotion:
20 | return "TRACKING LIMITED\nToo much camera movement"
21 | case .insufficientFeatures:
22 | return "TRACKING LIMITED\nNot enough surface detail"
23 | case .initializing:
24 | return "Tracking LIMITED\nInitialization in progress."
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chapter_13/models.scnassets/duck/duck-license.txt:
--------------------------------------------------------------------------------
1 | ---UPDATED 2/21/2007
2 | Scaled down the duck to a more reasonable size, removed physics scene, removed extra "dummy" transforms and pivot points, added camera and light.
3 | ---
4 |
5 | This model is a typical bathtub rubber duck. It uses a single texture.
6 |
7 | One version uses a polylist the other is triangles only.
8 |
9 | The model has been stripped of all tags and should be COLLADA 1.4.1 compliant.
10 |
11 | For additional information post messages on www.collada.org or mail collada@collada.org
12 |
13 | These models are Copyright 2006 Sony Computer Entertainment Inc. and are distributed under the terms of the SCEA Shared Source License, available at http://research.scea.com/scea_shared_source_license.html
--------------------------------------------------------------------------------
/chapter_13/models.scnassets/duck/duck.scn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/models.scnassets/duck/duck.scn
--------------------------------------------------------------------------------
/chapter_13/models.scnassets/duck/textures/duckCM.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/models.scnassets/duck/textures/duckCM.tga
--------------------------------------------------------------------------------
/chapter_14/AVAudioEnginePlayWithReverb.playground/Contents.swift:
--------------------------------------------------------------------------------
1 | import AVFoundation
2 | import PlaygroundSupport
3 |
4 | let sourceFileURL = Bundle.main.url(forResource: "source", withExtension: "caf")!
5 | let sourceFile = try! AVAudioFile(forReading: sourceFileURL)
6 | let format = sourceFile.processingFormat
7 |
8 | let engine = AVAudioEngine()
9 |
10 | //Nodeを準備する
11 | let player = AVAudioPlayerNode()
12 | let reverb = AVAudioUnitReverb()
13 |
14 | //AVAudioEngineに関連付けする
15 | engine.attach(player)
16 | engine.attach(reverb)
17 |
18 | // リバーブのパラメーターをセットする。ここでは中規模ホールの残響のプリセットを読み込んでいる
19 | reverb.loadFactoryPreset(.mediumHall)
20 | reverb.wetDryMix = 50
21 |
22 | // Audio Unit(のNode)を接続する。
23 | // player -> reverb -> mainMixer の順に接続している
24 | engine.connect(player, to: reverb, format: format)
25 | engine.connect(reverb, to: engine.mainMixerNode, format: format)
26 |
27 | // 再生するオーディオファイルをセット
28 | player.scheduleFile(sourceFile, at: nil)
29 |
30 | // 再生を開始
31 | try! engine.start()
32 | player.play()
33 |
34 | PlaygroundPage.current.needsIndefiniteExecution = true
35 |
--------------------------------------------------------------------------------
/chapter_14/AVAudioEnginePlayWithReverb.playground/Resources/source.caf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AVAudioEnginePlayWithReverb.playground/Resources/source.caf
--------------------------------------------------------------------------------
/chapter_14/AVAudioEnginePlayWithReverb.playground/contents.xcplayground:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2Test/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2Test/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // AirPlay2Test
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import AVKit
11 |
12 | class ViewController: UIViewController {
13 |
14 | let sampleBufferAudioPlayer = SampleBufferAudioPlayer()
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | do {
20 | let audioSession = AVAudioSession.sharedInstance()
21 | try audioSession.setCategory(AVAudioSessionCategoryPlayback,
22 | mode: AVAudioSessionModeDefault,
23 | routeSharingPolicy: .longForm)
24 |
25 | try audioSession.setActive(true)
26 | } catch {
27 | fatalError("\(error)")
28 | }
29 |
30 | let routePickerView = AVRoutePickerView()
31 | self.view.addSubview(routePickerView)
32 | routePickerView.translatesAutoresizingMaskIntoConstraints = false
33 | routePickerView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
34 | routePickerView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
35 |
36 | sampleBufferAudioPlayer.play()
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2Test/source.caf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2/AirPlay2Test/source.caf
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2TestTests/AirPlay2TestTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AirPlay2TestTests.swift
3 | // AirPlay2TestTests
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import AirPlay2Test
11 |
12 | class AirPlay2TestTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | // Use XCTAssert and related functions to verify your tests produce the correct results.
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measure {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2TestTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2TestUITests/AirPlay2TestUITests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AirPlay2TestUITests.swift
3 | // AirPlay2TestUITests
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class AirPlay2TestUITests: XCTestCase {
12 |
13 | override func setUp() {
14 | super.setUp()
15 |
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 |
18 | // In UI tests it is usually best to stop immediately when a failure occurs.
19 | continueAfterFailure = false
20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
21 | XCUIApplication().launch()
22 |
23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
24 | }
25 |
26 | override func tearDown() {
27 | // Put teardown code here. This method is called after the invocation of each test method in the class.
28 | super.tearDown()
29 | }
30 |
31 | func testExample() {
32 | // Use recording to get started writing UI tests.
33 | // Use XCTAssert and related functions to verify your tests produce the correct results.
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2/AirPlay2TestUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/AirPlay2Test-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 |
6 | #import "Utility.h"
7 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // AirPlay2Test
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import AVKit
11 |
12 | class ViewController: UIViewController {
13 |
14 | let sampleBufferAudioPlayer = SampleBufferAudioPlayer()
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | do {
20 | let audioSession = AVAudioSession.sharedInstance()
21 | try audioSession.setCategory(AVAudioSessionCategoryPlayback,
22 | mode: AVAudioSessionModeDefault,
23 | routeSharingPolicy: .longForm)
24 |
25 | try audioSession.setActive(true)
26 | } catch {
27 | fatalError("\(error)")
28 | }
29 |
30 | let routePickerView = AVRoutePickerView()
31 | self.view.addSubview(routePickerView)
32 | routePickerView.translatesAutoresizingMaskIntoConstraints = false
33 | routePickerView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
34 | routePickerView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
35 |
36 | sampleBufferAudioPlayer.play()
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/mixLoop.caf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/mixLoop.caf
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/podcast #012.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/podcast #012.m4a
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestTests/AirPlay2TestTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AirPlay2TestTests.swift
3 | // AirPlay2TestTests
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import AirPlay2Test
11 |
12 | class AirPlay2TestTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | // Use XCTAssert and related functions to verify your tests produce the correct results.
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measure {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestUITests/AirPlay2TestUITests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AirPlay2TestUITests.swift
3 | // AirPlay2TestUITests
4 | //
5 | // Created by 7gano on 2017/07/25.
6 | // Copyright © 2017 ROLLCAKE. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class AirPlay2TestUITests: XCTestCase {
12 |
13 | override func setUp() {
14 | super.setUp()
15 |
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 |
18 | // In UI tests it is usually best to stop immediately when a failure occurs.
19 | continueAfterFailure = false
20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
21 | XCUIApplication().launch()
22 |
23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
24 | }
25 |
26 | override func tearDown() {
27 | // Put teardown code here. This method is called after the invocation of each test method in the class.
28 | super.tearDown()
29 | }
30 |
31 | func testExample() {
32 | // Use recording to get started writing UI tests.
33 | // Use XCTAssert and related functions to verify your tests produce the correct results.
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapter_14/AudioEngineManualRendering.playground/Resources/source.caf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AudioEngineManualRendering.playground/Resources/source.caf
--------------------------------------------------------------------------------
/chapter_14/AudioEngineManualRendering.playground/contents.xcplayground:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------