├── .gitignore
├── LICENSE
├── README.md
├── Voucher iOS App
├── AppDelegate.swift
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Info.plist
└── ViewController.swift
├── Voucher tvOS App
├── AppDelegate.swift
├── Assets.xcassets
│ ├── App Icon & Top Shelf Image.brandassets
│ │ ├── App Icon - Large.imagestack
│ │ │ ├── Back.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── Front.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ └── Middle.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ ├── App Icon - Small.imagestack
│ │ │ ├── Back.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── Front.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ └── Middle.imagestacklayer
│ │ │ │ ├── Content.imageset
│ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── Top Shelf Image.imageset
│ │ │ └── Contents.json
│ ├── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
├── AuthViewController.swift
├── Base.lproj
│ └── Main.storyboard
├── Info.plist
└── RootViewController.swift
├── Voucher.podspec
├── Voucher.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcshareddata
│ └── xcschemes
│ ├── Voucher iOS.xcscheme
│ └── Voucher tvOS.xcscheme
├── Voucher
├── Client
│ ├── VoucherClient.h
│ └── VoucherClient.m
├── Info.plist
├── Server
│ ├── VoucherServer.h
│ └── VoucherServer.m
├── Voucher.h
├── VoucherCommon.h
├── VoucherStreamsController.h
└── VoucherStreamsController.m
└── VoucherTests
├── Info.plist
└── VoucherTests.m
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | *.xccheckout
13 | xcuserdata
14 | profile
15 | *.moved-aside
16 | DerivedData
17 | .idea/
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Riz
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 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Voucher
2 |
3 | The new Apple TV is amazing but the keyboard input leaves a lot to be desired. Instead of making your users type credentials into their TV, you can use Voucher to let them easily sign into the TV app using your iOS app.
4 |
5 | ### How Does It Work?
6 |
7 | Voucher uses [Bonjour](https://developer.apple.com/bonjour/), which is a technology to discover other devices on your network, and what they can do. When active, Voucher on tvOS starts looking in your local network and over [AWDL (Apple Wireless Direct Link)](http://stackoverflow.com/questions/19587701/what-is-awdl-apple-wireless-direct-link-and-how-does-it-work) for any Voucher Server, on iOS.
8 |
9 | Once it finds a Voucher Server, it asks it for authentication. Here's the demo app:
10 |
11 |
12 | The demo iOS app can then show a notification to the user (you can show whatever UI you want, or even no UI):
13 |
14 |
15 | If the user accepts, then the iOS app can send some authentication data back to the tvOS app (in this case, an auth token string)
16 |
17 |
18 | ## Installation
19 |
20 | Voucher is available through [Carthage](https://github.com/Carthage/Carthage) and [CocoaPods](https://cocoapods.org). You can also manually install it, if that's your jam.
21 |
22 | ### Carthage
23 | ```
24 | github "rsattar/Voucher"
25 | ```
26 |
27 | ### CocoaPods
28 | ```
29 | pod 'Voucher'
30 | ```
31 |
32 | ### Manual
33 | - Clone the repo to your computer
34 | - Copy only the source files in `Voucher` subfolder over to your project
35 |
36 |
37 | ## Using Voucher
38 |
39 | In your tvOS app, when the user wants to authenticate, you should create a `VoucherClient` instance and start it:
40 |
41 | ### tvOS (Requesting Auth)
42 | When the user triggers a "Login" button, your app should display some UI instructing them to open their iOS App to finish logging in, and then start the voucher client, like below:
43 |
44 | ```swift
45 | import Voucher
46 |
47 | func startVoucherClient() {
48 | let uniqueId = "SomethingUnique";
49 | self.voucher = VoucherClient(uniqueSharedId: uniqueId)
50 |
51 | self.voucher.startSearchingWithCompletion { [unowned self] authData, displayName, error in
52 |
53 | // (authData is of type NSData)
54 | if authData != nil {
55 | // User granted permission on iOS app!
56 | self.authenticationSucceeded(authData!, from: displayName)
57 | } else {
58 | self.authenticationFailed()
59 | }
60 | }
61 | }
62 |
63 | ```
64 |
65 |
66 | ### iOS (Providing Auth)
67 | If your iOS app has auth credentials, it should start a Voucher Server, so it can answer any requests for a login. I'd recommend starting the server when (and if) the user is logged in.
68 |
69 | ```swift
70 | import Voucher
71 |
72 | func startVoucherServer() {
73 | let uniqueId = "SomethingUnique"
74 | self.server = VoucherServer(uniqueSharedId: uniqueId)
75 |
76 | self.server.startAdvertisingWithRequestHandler { (displayName, responseHandler) -> Void in
77 |
78 | let alertController = UIAlertController(title: "Allow Auth?", message: "Allow \"\(displayName)\" access to your login?", preferredStyle: .Alert)
79 | alertController.addAction(UIAlertAction(title: "Not Now", style: .Cancel, handler: { action in
80 | responseHandler(nil, nil)
81 | }))
82 |
83 | alertController.addAction(UIAlertAction(title: "Allow", style: .Default, handler: { action in
84 | let authData = "THIS IS AN AUTH TOKEN".dataUsingEncoding(NSUTF8StringEncoding)!
85 | responseHandler(authData, nil)
86 | }))
87 |
88 | self.presentViewController(alertController, animated: true, completion: nil)
89 |
90 | }
91 | }
92 |
93 | ```
94 |
95 | ## Recommendations
96 |
97 | ### Use tokens, not passwords
98 | While you can send whatever data you like back to tvOS, you should you pass back an **OAuth** token, or better yet, generate some kind of a *single-use token* on your server and send that. [Cluster](https://cluster.co), for example, uses single-use tokens to do auto-login from web to iOS app. Check out this [Medium post](https://library.launchkit.io/how-ios-9-s-safari-view-controller-could-completely-change-your-app-s-onboarding-experience-2bcf2305137f?source=your-stories) that shows how I do it! The same model can apply for iOS to tvOS logins.
99 |
100 | ### Voucher can't be the only login option
101 | In your login screen, you must still show the manual entry UI according to the [App Store Submission Guidelines](http://www.appstorereviewguidelineshistory.com/articles/2015-10-21-guidelines-updated-for-tvos-apps/) (Section 2.27). Add messaging that, in addition to the on screen form, the user can simply open the iOS app to login.
102 |
103 | ## Todo / Things I'd Love Your Help With!
104 | * Encryption? Currently Voucher *does not* encrypt any data between the server and the client, so I suppose if someone wanted your credentials (See **Recommendations** section above), they could have a packet sniffer on your local network and access your credentials.
105 |
106 | * Make Voucher Server work on `OS X`, and even `tvOS`! Would probably just need new framework targets, and additional test apps.
107 |
108 | ## Further Reading
109 | Check out [Benny Wong](https://github.com/bdotdub)'s post on [why Apple TV sign in sucks](https://medium.com/@bdotdub/signing-into-apps-on-apple-tv-sucks-d36fd00e6712). He also has a [demo tvOS Authing project](https://github.com/bdotdub/TriplePlay), which you should check out!
110 |
111 |
112 | ## Requirements
113 | * iOS 7.0 and above
114 | * tvOS 9.0
115 | * Xcode 8
116 |
117 |
118 | ## License
119 | `Voucher` is available using an MIT license. See the LICENSE file for more info.
120 |
121 | ## I'd Love to Know If You're Using Voucher!
122 | [Post to this Github "issue" I made to help us track who's using Voucher](https://github.com/rsattar/Voucher/issues/2) :+1:
123 |
--------------------------------------------------------------------------------
/Voucher iOS App/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Voucher iOS App
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Voucher
11 |
12 | @UIApplicationMain
13 | class AppDelegate: UIResponder, UIApplicationDelegate {
14 |
15 | var window: UIWindow?
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Voucher iOS App/Assets.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" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/Voucher iOS App/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Voucher iOS App/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/Voucher iOS App/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Voucher iOS App/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Voucher iOS App
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Voucher
11 |
12 | class ViewController: UIViewController, VoucherServerDelegate {
13 |
14 | var server: VoucherServer?
15 |
16 | @IBOutlet var serverStatusLabel: UILabel!
17 | @IBOutlet var connectionStatusLabel: UILabel!
18 |
19 | deinit {
20 | self.server?.stop()
21 | self.server?.delegate = nil
22 | self.server = nil
23 | }
24 |
25 | override func viewDidLoad() {
26 | super.viewDidLoad()
27 | let uniqueId = "VoucherTest"
28 | self.server = VoucherServer(uniqueSharedId: uniqueId)
29 | self.server?.delegate = self
30 | }
31 |
32 | override func didReceiveMemoryWarning() {
33 | super.didReceiveMemoryWarning()
34 | // Dispose of any resources that can be recreated.
35 | }
36 |
37 | override func viewDidAppear(_ animated: Bool) {
38 | super.viewDidAppear(animated)
39 |
40 | self.server?.startAdvertising { (displayName, responseHandler) -> Void in
41 |
42 | let alertController = UIAlertController(title: "Allow Auth?", message: "Allow \"\(displayName)\" access to your login?", preferredStyle: .alert)
43 | alertController.addAction(UIAlertAction(title: "Not Now", style: .cancel, handler: { action in
44 | responseHandler(nil, nil)
45 | }))
46 |
47 | alertController.addAction(UIAlertAction(title: "Allow", style: .default, handler: { action in
48 | // For our authData, use a token string (to simulate an OAuth token, for example)
49 | let authData = "THIS IS AN AUTH TOKEN".data(using: String.Encoding.utf8)!
50 | responseHandler(authData, nil)
51 | }))
52 |
53 | self.present(alertController, animated: true, completion: nil)
54 |
55 | }
56 | }
57 |
58 | override func viewWillDisappear(_ animated: Bool) {
59 | super.viewWillDisappear(animated)
60 |
61 | self.server?.stop()
62 | }
63 |
64 | // MARK: - VoucherServerDelegate
65 |
66 | func voucherServer(_ server: VoucherServer, didUpdateAdvertising isAdvertising: Bool) {
67 | var text = "❌ Server Offline."
68 | if (isAdvertising) {
69 | text = "✅ Server Online."
70 | }
71 | self.serverStatusLabel.text = text
72 | self.connectionStatusLabel.isHidden = !isAdvertising
73 | }
74 |
75 | func voucherServer(_ server: VoucherServer, didUpdateConnectionToClient isConnectedToClient: Bool) {
76 | var text = "📡 Waiting for Connection..."
77 | if (isConnectedToClient) {
78 | text = "✅ Connected."
79 | }
80 | self.connectionStatusLabel.text = text
81 | }
82 |
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/Voucher tvOS App/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Voucher tvOS App
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | // Override point for customization after application launch.
18 | return true
19 | }
20 |
21 | func applicationWillResignActive(_ application: UIApplication) {
22 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
23 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
24 | }
25 |
26 | func applicationDidEnterBackground(_ application: UIApplication) {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | func applicationWillEnterForeground(_ application: UIApplication) {
32 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
33 | }
34 |
35 | func applicationDidBecomeActive(_ application: UIApplication) {
36 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
37 | }
38 |
39 | func applicationWillTerminate(_ application: UIApplication) {
40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41 | }
42 |
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "layers" : [
3 | {
4 | "filename" : "Front.imagestacklayer"
5 | },
6 | {
7 | "filename" : "Middle.imagestacklayer"
8 | },
9 | {
10 | "filename" : "Back.imagestacklayer"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "layers" : [
3 | {
4 | "filename" : "Front.imagestacklayer"
5 | },
6 | {
7 | "filename" : "Middle.imagestacklayer"
8 | },
9 | {
10 | "filename" : "Back.imagestacklayer"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "assets" : [
3 | {
4 | "size" : "1280x768",
5 | "idiom" : "tv",
6 | "filename" : "App Icon - Large.imagestack",
7 | "role" : "primary-app-icon"
8 | },
9 | {
10 | "size" : "400x240",
11 | "idiom" : "tv",
12 | "filename" : "App Icon - Small.imagestack",
13 | "role" : "primary-app-icon"
14 | },
15 | {
16 | "size" : "1920x720",
17 | "idiom" : "tv",
18 | "filename" : "Top Shelf Image.imageset",
19 | "role" : "top-shelf-image"
20 | }
21 | ],
22 | "info" : {
23 | "version" : 1,
24 | "author" : "xcode"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "landscape",
5 | "idiom" : "tv",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "9.0",
8 | "scale" : "1x"
9 | }
10 | ],
11 | "info" : {
12 | "version" : 1,
13 | "author" : "xcode"
14 | }
15 | }
--------------------------------------------------------------------------------
/Voucher tvOS App/AuthViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AuthViewController.swift
3 | // Voucher tvOS App
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Voucher
11 |
12 | class AuthViewController: UIViewController, VoucherClientDelegate {
13 |
14 | var delegate: AuthViewControllerDelegate?
15 | var client: VoucherClient?
16 |
17 | @IBOutlet weak var searchingLabel: UILabel!
18 | @IBOutlet weak var connectionLabel: UILabel!
19 |
20 | deinit {
21 | self.client?.stop()
22 | self.client?.delegate = nil
23 | self.client = nil
24 | }
25 |
26 | override func viewDidLoad() {
27 | super.viewDidLoad()
28 |
29 | let uniqueId = "VoucherTest";
30 | self.client = VoucherClient(uniqueSharedId: uniqueId)
31 | self.client?.delegate = self
32 | }
33 |
34 | override func viewWillAppear(_ animated: Bool) {
35 | super.viewWillAppear(animated)
36 |
37 |
38 | self.client?.startSearching { [unowned self] (authData, displayName, error) -> Void in
39 |
40 | defer {
41 | self.client?.stop()
42 | }
43 |
44 | guard let authData = authData, let displayName = displayName else {
45 | if let error = error {
46 | NSLog("Encountered error retrieving data: \(error)")
47 | }
48 | self.onNoDataReceived(error as NSError?)
49 | return
50 | }
51 |
52 | self.onAuthDataReceived(authData, responderName: displayName)
53 |
54 | }
55 | }
56 |
57 | override func viewDidDisappear(_ animated: Bool) {
58 | super.viewDidDisappear(animated)
59 | self.client?.stop()
60 | }
61 |
62 | func onNoDataReceived(_ error: NSError?) {
63 | let alert = UIAlertController(title: "Authentication Failed", message: "The iOS App denied our authentication request.", preferredStyle: .alert)
64 | alert.addAction(UIAlertAction(title: "Bummer!", style: .default, handler: { [unowned self] action in
65 | self.delegate?.authController(self, didSucceed: false)
66 | }))
67 | self.present(alert, animated: true, completion: nil)
68 | }
69 |
70 | func onAuthDataReceived(_ authData: Data, responderName:String) {
71 | // Treat the auth data as an string-based auth token
72 | let tokenString = String(data: authData, encoding: String.Encoding.utf8)!
73 | let alert = UIAlertController(title: "Received Auth Data!", message: "Received data, '\(tokenString)' from '\(responderName)'", preferredStyle: .alert)
74 | alert.addAction(UIAlertAction(title: "Awesome!", style: .default, handler: { [unowned self] action in
75 | self.delegate?.authController(self, didSucceed: true)
76 | }))
77 | self.present(alert, animated: true, completion: nil)
78 | }
79 |
80 | override func didReceiveMemoryWarning() {
81 | super.didReceiveMemoryWarning()
82 | // Dispose of any resources that can be recreated.
83 | }
84 |
85 | // MARK: - VoucherClientDelegate
86 |
87 | func voucherClient(_ client: VoucherClient, didUpdateSearching isSearching: Bool) {
88 | if isSearching {
89 | self.searchingLabel.text = "📡 Searching for Voucher Servers..."
90 | } else {
91 | self.searchingLabel.text = "❌ Not Searching."
92 | }
93 | }
94 |
95 | func voucherClient(_ client: VoucherClient, didUpdateConnectionToServer isConnectedToServer: Bool, serverName: String?) {
96 | if isConnectedToServer {
97 | self.connectionLabel.text = "✅ Connected to '\(serverName!)'"
98 | } else {
99 | self.connectionLabel.text = "😴 Not Connected Yet."
100 | }
101 | }
102 | }
103 |
104 | protocol AuthViewControllerDelegate {
105 | func authController(_ controller:AuthViewController, didSucceed succeeded:Bool)
106 | }
107 |
108 |
--------------------------------------------------------------------------------
/Voucher tvOS App/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/Voucher tvOS App/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 | arm64
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Voucher tvOS App/RootViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RootViewController.swift
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/9/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class RootViewController: UIViewController, AuthViewControllerDelegate {
12 |
13 | var isAuthenticated: Bool = false {
14 | didSet {
15 | self.authenticationUI.isHidden = self.isAuthenticated
16 | self.clearAuthenticationButton.isHidden = !self.isAuthenticated
17 | if (isAuthenticated) {
18 | self.authenticationLabel.text = "Authenticated!"
19 | } else {
20 | self.authenticationLabel.text = "Not Authenticated"
21 | }
22 | self.view.setNeedsLayout()
23 | }
24 | }
25 |
26 | @IBOutlet weak var authenticationLabel: UILabel!
27 | @IBOutlet weak var clearAuthenticationButton: UIButton!
28 | @IBOutlet weak var authenticationUI: UIView!
29 |
30 |
31 | override func viewDidLoad() {
32 | super.viewDidLoad()
33 |
34 | self.isAuthenticated = false
35 | }
36 |
37 | override func didReceiveMemoryWarning() {
38 | super.didReceiveMemoryWarning()
39 | // Dispose of any resources that can be recreated.
40 | }
41 |
42 | // MARK: - Navigation
43 |
44 | // In a storyboard-based application, you will often want to do a little preparation before navigation
45 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
46 | // Get the new view controller using segue.destinationViewController.
47 | // Pass the selected object to the new view controller.
48 | guard let segueIdentifier = segue.identifier else {
49 | return
50 | }
51 |
52 | if segueIdentifier == "showVoucher" {
53 | let viewController = segue.destination as! AuthViewController
54 | viewController.delegate = self
55 |
56 | }
57 | }
58 |
59 | @IBAction func onClearDataTriggered(_ sender: UIButton) {
60 | self.isAuthenticated = false
61 | }
62 |
63 | // MARK: - AuthViewControllerDelegate
64 | func authController(_ controller: AuthViewController, didSucceed succeeded: Bool) {
65 | self.isAuthenticated = succeeded
66 | self.dismiss(animated: true, completion: nil)
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Voucher.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 |
3 | s.name = "Voucher"
4 | s.version = "0.2.0"
5 | s.summary = "A simple library to make authenticating tvOS apps easy via their iOS counterparts using Bonjour."
6 |
7 | # This description is used to generate tags and improve search results.
8 | # * Think: What does it do? Why did you write it? What is the focus?
9 | # * Try to keep it short, snappy and to the point.
10 | # * Write the description between the DESC delimiters below.
11 | # * Finally, don't worry about the indent, CocoaPods strips it!
12 | s.description = <<-DESC
13 | Voucher lets the user login easily on a tvOS app, provided they already
14 | have the iOS app. Their iOS app receives a request from the tvOS app, which
15 | they can grant, and the iOS app can send useful authentication data back to
16 | the tvOS app.
17 |
18 | Until Apple "fixes" this issue by creating better login options. This is a nice
19 | option to include in your tvOS and iOS apps, because it makes login painless!
20 | DESC
21 |
22 | s.homepage = "https://github.com/rsattar/Voucher"
23 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
24 |
25 | s.license = { :type => "MIT", :file => "LICENSE" }
26 |
27 | s.author = { "Rizwan Sattar" => "rsattar@gmail.com" }
28 | s.social_media_url = "http://twitter.com/rizzledizzle"
29 |
30 | s.platform = ['ios', 'tvos']
31 | s.ios.deployment_target = "7.0"
32 | s.tvos.deployment_target = "9.0"
33 |
34 | s.source = { :git => "https://github.com/rsattar/Voucher.git", :tag => s.version.to_s }
35 |
36 | s.source_files = "Voucher", "Voucher/**/*.{h,m}"
37 |
38 | end
39 |
--------------------------------------------------------------------------------
/Voucher.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 653F0C3E1BF18CE900ED30D0 /* VoucherClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C341BF18CE900ED30D0 /* VoucherClient.h */; settings = {ATTRIBUTES = (Public, ); }; };
11 | 653F0C3F1BF18CE900ED30D0 /* VoucherClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C341BF18CE900ED30D0 /* VoucherClient.h */; settings = {ATTRIBUTES = (Public, ); }; };
12 | 653F0C401BF18CE900ED30D0 /* VoucherClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C351BF18CE900ED30D0 /* VoucherClient.m */; };
13 | 653F0C411BF18CE900ED30D0 /* VoucherClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C351BF18CE900ED30D0 /* VoucherClient.m */; };
14 | 653F0C441BF18CE900ED30D0 /* VoucherServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C381BF18CE900ED30D0 /* VoucherServer.h */; settings = {ATTRIBUTES = (Public, ); }; };
15 | 653F0C451BF18CE900ED30D0 /* VoucherServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C381BF18CE900ED30D0 /* VoucherServer.h */; settings = {ATTRIBUTES = (Public, ); }; };
16 | 653F0C461BF18CE900ED30D0 /* VoucherServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C391BF18CE900ED30D0 /* VoucherServer.m */; };
17 | 653F0C471BF18CE900ED30D0 /* VoucherServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C391BF18CE900ED30D0 /* VoucherServer.m */; };
18 | 653F0C481BF18CE900ED30D0 /* Voucher.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3A1BF18CE900ED30D0 /* Voucher.h */; settings = {ATTRIBUTES = (Public, ); }; };
19 | 653F0C491BF18CE900ED30D0 /* Voucher.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3A1BF18CE900ED30D0 /* Voucher.h */; settings = {ATTRIBUTES = (Public, ); }; };
20 | 653F0C4A1BF18CE900ED30D0 /* VoucherCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3B1BF18CE900ED30D0 /* VoucherCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };
21 | 653F0C4B1BF18CE900ED30D0 /* VoucherCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3B1BF18CE900ED30D0 /* VoucherCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };
22 | 653F0C4C1BF18CE900ED30D0 /* VoucherStreamsController.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3C1BF18CE900ED30D0 /* VoucherStreamsController.h */; settings = {ATTRIBUTES = (Public, ); }; };
23 | 653F0C4D1BF18CE900ED30D0 /* VoucherStreamsController.h in Headers */ = {isa = PBXBuildFile; fileRef = 653F0C3C1BF18CE900ED30D0 /* VoucherStreamsController.h */; settings = {ATTRIBUTES = (Public, ); }; };
24 | 653F0C4E1BF18CE900ED30D0 /* VoucherStreamsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C3D1BF18CE900ED30D0 /* VoucherStreamsController.m */; };
25 | 653F0C4F1BF18CE900ED30D0 /* VoucherStreamsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C3D1BF18CE900ED30D0 /* VoucherStreamsController.m */; };
26 | 653F0C661BF18DB900ED30D0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 653F0C531BF18D7B00ED30D0 /* LaunchScreen.storyboard */; };
27 | 653F0C671BF18DBC00ED30D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653F0C521BF18D7B00ED30D0 /* Assets.xcassets */; };
28 | 653F0C681BF18DC000ED30D0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 653F0C551BF18D7B00ED30D0 /* Main.storyboard */; };
29 | 653F0C691BF18DC300ED30D0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C581BF18D7B00ED30D0 /* ViewController.swift */; };
30 | 653F0C6A1BF18DC600ED30D0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C511BF18D7B00ED30D0 /* AppDelegate.swift */; };
31 | 653F0C721BF18E3900ED30D0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C6C1BF18E3900ED30D0 /* AppDelegate.swift */; };
32 | 653F0C731BF18E3900ED30D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653F0C6D1BF18E3900ED30D0 /* Assets.xcassets */; };
33 | 653F0C741BF18E3900ED30D0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 653F0C6E1BF18E3900ED30D0 /* Main.storyboard */; };
34 | 653F0C761BF18E3900ED30D0 /* AuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C711BF18E3900ED30D0 /* AuthViewController.swift */; };
35 | 653F0C7A1BF18EB400ED30D0 /* VoucherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C781BF18EB400ED30D0 /* VoucherTests.m */; };
36 | 653F0C841BF1CF1200ED30D0 /* Voucher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659AF1741BEEF1510031B3A5 /* Voucher.framework */; };
37 | 653F0C851BF1CF1200ED30D0 /* Voucher.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 659AF1741BEEF1510031B3A5 /* Voucher.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
38 | 653F0C891BF1CF2200ED30D0 /* Voucher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659AF1971BEEF1A30031B3A5 /* Voucher.framework */; };
39 | 653F0C8A1BF1CF2200ED30D0 /* Voucher.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 659AF1971BEEF1A30031B3A5 /* Voucher.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
40 | 653F0C8F1BF1D97900ED30D0 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653F0C8E1BF1D97900ED30D0 /* RootViewController.swift */; };
41 | 659AF17F1BEEF1510031B3A5 /* Voucher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659AF1741BEEF1510031B3A5 /* Voucher.framework */; };
42 | /* End PBXBuildFile section */
43 |
44 | /* Begin PBXContainerItemProxy section */
45 | 653F0C861BF1CF1300ED30D0 /* PBXContainerItemProxy */ = {
46 | isa = PBXContainerItemProxy;
47 | containerPortal = 659AF16B1BEEF1510031B3A5 /* Project object */;
48 | proxyType = 1;
49 | remoteGlobalIDString = 659AF1731BEEF1510031B3A5;
50 | remoteInfo = "Voucher iOS";
51 | };
52 | 653F0C8B1BF1CF2200ED30D0 /* PBXContainerItemProxy */ = {
53 | isa = PBXContainerItemProxy;
54 | containerPortal = 659AF16B1BEEF1510031B3A5 /* Project object */;
55 | proxyType = 1;
56 | remoteGlobalIDString = 659AF18E1BEEF1A30031B3A5;
57 | remoteInfo = "Voucher tvOS";
58 | };
59 | 659AF1801BEEF1510031B3A5 /* PBXContainerItemProxy */ = {
60 | isa = PBXContainerItemProxy;
61 | containerPortal = 659AF16B1BEEF1510031B3A5 /* Project object */;
62 | proxyType = 1;
63 | remoteGlobalIDString = 659AF1731BEEF1510031B3A5;
64 | remoteInfo = Hauth;
65 | };
66 | /* End PBXContainerItemProxy section */
67 |
68 | /* Begin PBXCopyFilesBuildPhase section */
69 | 653F0C881BF1CF1300ED30D0 /* Embed Frameworks */ = {
70 | isa = PBXCopyFilesBuildPhase;
71 | buildActionMask = 2147483647;
72 | dstPath = "";
73 | dstSubfolderSpec = 10;
74 | files = (
75 | 653F0C851BF1CF1200ED30D0 /* Voucher.framework in Embed Frameworks */,
76 | );
77 | name = "Embed Frameworks";
78 | runOnlyForDeploymentPostprocessing = 0;
79 | };
80 | 653F0C8D1BF1CF2200ED30D0 /* Embed Frameworks */ = {
81 | isa = PBXCopyFilesBuildPhase;
82 | buildActionMask = 2147483647;
83 | dstPath = "";
84 | dstSubfolderSpec = 10;
85 | files = (
86 | 653F0C8A1BF1CF2200ED30D0 /* Voucher.framework in Embed Frameworks */,
87 | );
88 | name = "Embed Frameworks";
89 | runOnlyForDeploymentPostprocessing = 0;
90 | };
91 | /* End PBXCopyFilesBuildPhase section */
92 |
93 | /* Begin PBXFileReference section */
94 | 653F0C341BF18CE900ED30D0 /* VoucherClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoucherClient.h; sourceTree = ""; };
95 | 653F0C351BF18CE900ED30D0 /* VoucherClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VoucherClient.m; sourceTree = ""; };
96 | 653F0C361BF18CE900ED30D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Voucher/Info.plist; sourceTree = SOURCE_ROOT; };
97 | 653F0C381BF18CE900ED30D0 /* VoucherServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoucherServer.h; sourceTree = ""; };
98 | 653F0C391BF18CE900ED30D0 /* VoucherServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VoucherServer.m; sourceTree = ""; };
99 | 653F0C3A1BF18CE900ED30D0 /* Voucher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Voucher.h; path = Voucher/Voucher.h; sourceTree = SOURCE_ROOT; };
100 | 653F0C3B1BF18CE900ED30D0 /* VoucherCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VoucherCommon.h; path = Voucher/VoucherCommon.h; sourceTree = SOURCE_ROOT; };
101 | 653F0C3C1BF18CE900ED30D0 /* VoucherStreamsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VoucherStreamsController.h; path = Voucher/VoucherStreamsController.h; sourceTree = SOURCE_ROOT; };
102 | 653F0C3D1BF18CE900ED30D0 /* VoucherStreamsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VoucherStreamsController.m; path = Voucher/VoucherStreamsController.m; sourceTree = SOURCE_ROOT; };
103 | 653F0C511BF18D7B00ED30D0 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
104 | 653F0C521BF18D7B00ED30D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
105 | 653F0C541BF18D7B00ED30D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
106 | 653F0C561BF18D7B00ED30D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
107 | 653F0C571BF18D7B00ED30D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
108 | 653F0C581BF18D7B00ED30D0 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
109 | 653F0C6C1BF18E3900ED30D0 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
110 | 653F0C6D1BF18E3900ED30D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
111 | 653F0C6F1BF18E3900ED30D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
112 | 653F0C701BF18E3900ED30D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
113 | 653F0C711BF18E3900ED30D0 /* AuthViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthViewController.swift; sourceTree = ""; };
114 | 653F0C781BF18EB400ED30D0 /* VoucherTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VoucherTests.m; sourceTree = ""; };
115 | 653F0C791BF18EB400ED30D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
116 | 653F0C8E1BF1D97900ED30D0 /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = ""; };
117 | 659AF1741BEEF1510031B3A5 /* Voucher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Voucher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
118 | 659AF17E1BEEF1510031B3A5 /* Voucher.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Voucher.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
119 | 659AF1971BEEF1A30031B3A5 /* Voucher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Voucher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
120 | 659AF1CA1BEF1D3E0031B3A5 /* Voucher iOS App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Voucher iOS App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
121 | 659AF1E01BEF1D530031B3A5 /* Voucher tvOS App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Voucher tvOS App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
122 | /* End PBXFileReference section */
123 |
124 | /* Begin PBXFrameworksBuildPhase section */
125 | 659AF1701BEEF1510031B3A5 /* Frameworks */ = {
126 | isa = PBXFrameworksBuildPhase;
127 | buildActionMask = 2147483647;
128 | files = (
129 | );
130 | runOnlyForDeploymentPostprocessing = 0;
131 | };
132 | 659AF17B1BEEF1510031B3A5 /* Frameworks */ = {
133 | isa = PBXFrameworksBuildPhase;
134 | buildActionMask = 2147483647;
135 | files = (
136 | 659AF17F1BEEF1510031B3A5 /* Voucher.framework in Frameworks */,
137 | );
138 | runOnlyForDeploymentPostprocessing = 0;
139 | };
140 | 659AF1901BEEF1A30031B3A5 /* Frameworks */ = {
141 | isa = PBXFrameworksBuildPhase;
142 | buildActionMask = 2147483647;
143 | files = (
144 | );
145 | runOnlyForDeploymentPostprocessing = 0;
146 | };
147 | 659AF1C71BEF1D3E0031B3A5 /* Frameworks */ = {
148 | isa = PBXFrameworksBuildPhase;
149 | buildActionMask = 2147483647;
150 | files = (
151 | 653F0C841BF1CF1200ED30D0 /* Voucher.framework in Frameworks */,
152 | );
153 | runOnlyForDeploymentPostprocessing = 0;
154 | };
155 | 659AF1DD1BEF1D530031B3A5 /* Frameworks */ = {
156 | isa = PBXFrameworksBuildPhase;
157 | buildActionMask = 2147483647;
158 | files = (
159 | 653F0C891BF1CF2200ED30D0 /* Voucher.framework in Frameworks */,
160 | );
161 | runOnlyForDeploymentPostprocessing = 0;
162 | };
163 | /* End PBXFrameworksBuildPhase section */
164 |
165 | /* Begin PBXGroup section */
166 | 653F0C331BF18CE900ED30D0 /* Client */ = {
167 | isa = PBXGroup;
168 | children = (
169 | 653F0C341BF18CE900ED30D0 /* VoucherClient.h */,
170 | 653F0C351BF18CE900ED30D0 /* VoucherClient.m */,
171 | );
172 | name = Client;
173 | path = Voucher/Client;
174 | sourceTree = SOURCE_ROOT;
175 | };
176 | 653F0C371BF18CE900ED30D0 /* Server */ = {
177 | isa = PBXGroup;
178 | children = (
179 | 653F0C381BF18CE900ED30D0 /* VoucherServer.h */,
180 | 653F0C391BF18CE900ED30D0 /* VoucherServer.m */,
181 | );
182 | name = Server;
183 | path = Voucher/Server;
184 | sourceTree = SOURCE_ROOT;
185 | };
186 | 653F0C501BF18D7B00ED30D0 /* Voucher iOS App */ = {
187 | isa = PBXGroup;
188 | children = (
189 | 653F0C511BF18D7B00ED30D0 /* AppDelegate.swift */,
190 | 653F0C581BF18D7B00ED30D0 /* ViewController.swift */,
191 | 653F0C551BF18D7B00ED30D0 /* Main.storyboard */,
192 | 653F0C521BF18D7B00ED30D0 /* Assets.xcassets */,
193 | 653F0C531BF18D7B00ED30D0 /* LaunchScreen.storyboard */,
194 | 653F0C571BF18D7B00ED30D0 /* Info.plist */,
195 | );
196 | path = "Voucher iOS App";
197 | sourceTree = "";
198 | };
199 | 653F0C6B1BF18E3900ED30D0 /* Voucher tvOS App */ = {
200 | isa = PBXGroup;
201 | children = (
202 | 653F0C6C1BF18E3900ED30D0 /* AppDelegate.swift */,
203 | 653F0C6D1BF18E3900ED30D0 /* Assets.xcassets */,
204 | 653F0C6E1BF18E3900ED30D0 /* Main.storyboard */,
205 | 653F0C701BF18E3900ED30D0 /* Info.plist */,
206 | 653F0C711BF18E3900ED30D0 /* AuthViewController.swift */,
207 | 653F0C8E1BF1D97900ED30D0 /* RootViewController.swift */,
208 | );
209 | path = "Voucher tvOS App";
210 | sourceTree = "";
211 | };
212 | 653F0C771BF18EB400ED30D0 /* VoucherTests */ = {
213 | isa = PBXGroup;
214 | children = (
215 | 653F0C781BF18EB400ED30D0 /* VoucherTests.m */,
216 | 653F0C791BF18EB400ED30D0 /* Info.plist */,
217 | );
218 | path = VoucherTests;
219 | sourceTree = "";
220 | };
221 | 659AF16A1BEEF1510031B3A5 = {
222 | isa = PBXGroup;
223 | children = (
224 | 659AF1761BEEF1510031B3A5 /* Voucher */,
225 | 653F0C771BF18EB400ED30D0 /* VoucherTests */,
226 | 653F0C501BF18D7B00ED30D0 /* Voucher iOS App */,
227 | 653F0C6B1BF18E3900ED30D0 /* Voucher tvOS App */,
228 | 659AF1751BEEF1510031B3A5 /* Products */,
229 | );
230 | sourceTree = "";
231 | };
232 | 659AF1751BEEF1510031B3A5 /* Products */ = {
233 | isa = PBXGroup;
234 | children = (
235 | 659AF1741BEEF1510031B3A5 /* Voucher.framework */,
236 | 659AF17E1BEEF1510031B3A5 /* Voucher.xctest */,
237 | 659AF1971BEEF1A30031B3A5 /* Voucher.framework */,
238 | 659AF1CA1BEF1D3E0031B3A5 /* Voucher iOS App.app */,
239 | 659AF1E01BEF1D530031B3A5 /* Voucher tvOS App.app */,
240 | );
241 | name = Products;
242 | sourceTree = "";
243 | };
244 | 659AF1761BEEF1510031B3A5 /* Voucher */ = {
245 | isa = PBXGroup;
246 | children = (
247 | 653F0C331BF18CE900ED30D0 /* Client */,
248 | 653F0C371BF18CE900ED30D0 /* Server */,
249 | 653F0C361BF18CE900ED30D0 /* Info.plist */,
250 | 653F0C3A1BF18CE900ED30D0 /* Voucher.h */,
251 | 653F0C3B1BF18CE900ED30D0 /* VoucherCommon.h */,
252 | 653F0C3C1BF18CE900ED30D0 /* VoucherStreamsController.h */,
253 | 653F0C3D1BF18CE900ED30D0 /* VoucherStreamsController.m */,
254 | );
255 | name = Voucher;
256 | path = Hauth;
257 | sourceTree = "";
258 | };
259 | /* End PBXGroup section */
260 |
261 | /* Begin PBXHeadersBuildPhase section */
262 | 659AF1711BEEF1510031B3A5 /* Headers */ = {
263 | isa = PBXHeadersBuildPhase;
264 | buildActionMask = 2147483647;
265 | files = (
266 | 653F0C441BF18CE900ED30D0 /* VoucherServer.h in Headers */,
267 | 653F0C3E1BF18CE900ED30D0 /* VoucherClient.h in Headers */,
268 | 653F0C4C1BF18CE900ED30D0 /* VoucherStreamsController.h in Headers */,
269 | 653F0C4A1BF18CE900ED30D0 /* VoucherCommon.h in Headers */,
270 | 653F0C481BF18CE900ED30D0 /* Voucher.h in Headers */,
271 | );
272 | runOnlyForDeploymentPostprocessing = 0;
273 | };
274 | 659AF1911BEEF1A30031B3A5 /* Headers */ = {
275 | isa = PBXHeadersBuildPhase;
276 | buildActionMask = 2147483647;
277 | files = (
278 | 653F0C451BF18CE900ED30D0 /* VoucherServer.h in Headers */,
279 | 653F0C3F1BF18CE900ED30D0 /* VoucherClient.h in Headers */,
280 | 653F0C4D1BF18CE900ED30D0 /* VoucherStreamsController.h in Headers */,
281 | 653F0C4B1BF18CE900ED30D0 /* VoucherCommon.h in Headers */,
282 | 653F0C491BF18CE900ED30D0 /* Voucher.h in Headers */,
283 | );
284 | runOnlyForDeploymentPostprocessing = 0;
285 | };
286 | /* End PBXHeadersBuildPhase section */
287 |
288 | /* Begin PBXNativeTarget section */
289 | 659AF1731BEEF1510031B3A5 /* Voucher iOS */ = {
290 | isa = PBXNativeTarget;
291 | buildConfigurationList = 659AF1881BEEF1510031B3A5 /* Build configuration list for PBXNativeTarget "Voucher iOS" */;
292 | buildPhases = (
293 | 659AF16F1BEEF1510031B3A5 /* Sources */,
294 | 659AF1701BEEF1510031B3A5 /* Frameworks */,
295 | 659AF1711BEEF1510031B3A5 /* Headers */,
296 | 659AF1721BEEF1510031B3A5 /* Resources */,
297 | );
298 | buildRules = (
299 | );
300 | dependencies = (
301 | );
302 | name = "Voucher iOS";
303 | productName = Hauth;
304 | productReference = 659AF1741BEEF1510031B3A5 /* Voucher.framework */;
305 | productType = "com.apple.product-type.framework";
306 | };
307 | 659AF17D1BEEF1510031B3A5 /* VoucherTests */ = {
308 | isa = PBXNativeTarget;
309 | buildConfigurationList = 659AF18B1BEEF1510031B3A5 /* Build configuration list for PBXNativeTarget "VoucherTests" */;
310 | buildPhases = (
311 | 659AF17A1BEEF1510031B3A5 /* Sources */,
312 | 659AF17B1BEEF1510031B3A5 /* Frameworks */,
313 | 659AF17C1BEEF1510031B3A5 /* Resources */,
314 | );
315 | buildRules = (
316 | );
317 | dependencies = (
318 | 659AF1811BEEF1510031B3A5 /* PBXTargetDependency */,
319 | );
320 | name = VoucherTests;
321 | productName = HauthTests;
322 | productReference = 659AF17E1BEEF1510031B3A5 /* Voucher.xctest */;
323 | productType = "com.apple.product-type.bundle.unit-test";
324 | };
325 | 659AF18E1BEEF1A30031B3A5 /* Voucher tvOS */ = {
326 | isa = PBXNativeTarget;
327 | buildConfigurationList = 659AF1941BEEF1A30031B3A5 /* Build configuration list for PBXNativeTarget "Voucher tvOS" */;
328 | buildPhases = (
329 | 659AF18F1BEEF1A30031B3A5 /* Sources */,
330 | 659AF1901BEEF1A30031B3A5 /* Frameworks */,
331 | 659AF1911BEEF1A30031B3A5 /* Headers */,
332 | 659AF1931BEEF1A30031B3A5 /* Resources */,
333 | );
334 | buildRules = (
335 | );
336 | dependencies = (
337 | );
338 | name = "Voucher tvOS";
339 | productName = Hauth;
340 | productReference = 659AF1971BEEF1A30031B3A5 /* Voucher.framework */;
341 | productType = "com.apple.product-type.framework";
342 | };
343 | 659AF1C91BEF1D3E0031B3A5 /* Voucher iOS App */ = {
344 | isa = PBXNativeTarget;
345 | buildConfigurationList = 659AF1DB1BEF1D3E0031B3A5 /* Build configuration list for PBXNativeTarget "Voucher iOS App" */;
346 | buildPhases = (
347 | 659AF1C61BEF1D3E0031B3A5 /* Sources */,
348 | 659AF1C71BEF1D3E0031B3A5 /* Frameworks */,
349 | 659AF1C81BEF1D3E0031B3A5 /* Resources */,
350 | 653F0C881BF1CF1300ED30D0 /* Embed Frameworks */,
351 | );
352 | buildRules = (
353 | );
354 | dependencies = (
355 | 653F0C871BF1CF1300ED30D0 /* PBXTargetDependency */,
356 | );
357 | name = "Voucher iOS App";
358 | productName = "Hauth iOS App";
359 | productReference = 659AF1CA1BEF1D3E0031B3A5 /* Voucher iOS App.app */;
360 | productType = "com.apple.product-type.application";
361 | };
362 | 659AF1DF1BEF1D530031B3A5 /* Voucher tvOS App */ = {
363 | isa = PBXNativeTarget;
364 | buildConfigurationList = 659AF1EC1BEF1D540031B3A5 /* Build configuration list for PBXNativeTarget "Voucher tvOS App" */;
365 | buildPhases = (
366 | 659AF1DC1BEF1D530031B3A5 /* Sources */,
367 | 659AF1DD1BEF1D530031B3A5 /* Frameworks */,
368 | 659AF1DE1BEF1D530031B3A5 /* Resources */,
369 | 653F0C8D1BF1CF2200ED30D0 /* Embed Frameworks */,
370 | );
371 | buildRules = (
372 | );
373 | dependencies = (
374 | 653F0C8C1BF1CF2200ED30D0 /* PBXTargetDependency */,
375 | );
376 | name = "Voucher tvOS App";
377 | productName = "Hauth tvOS App";
378 | productReference = 659AF1E01BEF1D530031B3A5 /* Voucher tvOS App.app */;
379 | productType = "com.apple.product-type.application";
380 | };
381 | /* End PBXNativeTarget section */
382 |
383 | /* Begin PBXProject section */
384 | 659AF16B1BEEF1510031B3A5 /* Project object */ = {
385 | isa = PBXProject;
386 | attributes = {
387 | LastSwiftUpdateCheck = 0710;
388 | LastUpgradeCheck = 0820;
389 | ORGANIZATIONNAME = "Rizwan Sattar";
390 | TargetAttributes = {
391 | 659AF1731BEEF1510031B3A5 = {
392 | CreatedOnToolsVersion = 7.1;
393 | DevelopmentTeam = 99M2UD9XXB;
394 | LastSwiftMigration = 0820;
395 | };
396 | 659AF17D1BEEF1510031B3A5 = {
397 | CreatedOnToolsVersion = 7.1;
398 | };
399 | 659AF18E1BEEF1A30031B3A5 = {
400 | DevelopmentTeam = 99M2UD9XXB;
401 | LastSwiftMigration = 0820;
402 | };
403 | 659AF1C91BEF1D3E0031B3A5 = {
404 | CreatedOnToolsVersion = 7.1;
405 | DevelopmentTeam = 99M2UD9XXB;
406 | LastSwiftMigration = 0820;
407 | };
408 | 659AF1DF1BEF1D530031B3A5 = {
409 | CreatedOnToolsVersion = 7.1;
410 | DevelopmentTeam = 99M2UD9XXB;
411 | LastSwiftMigration = 0820;
412 | };
413 | };
414 | };
415 | buildConfigurationList = 659AF16E1BEEF1510031B3A5 /* Build configuration list for PBXProject "Voucher" */;
416 | compatibilityVersion = "Xcode 3.2";
417 | developmentRegion = English;
418 | hasScannedForEncodings = 0;
419 | knownRegions = (
420 | en,
421 | Base,
422 | );
423 | mainGroup = 659AF16A1BEEF1510031B3A5;
424 | productRefGroup = 659AF1751BEEF1510031B3A5 /* Products */;
425 | projectDirPath = "";
426 | projectRoot = "";
427 | targets = (
428 | 659AF1731BEEF1510031B3A5 /* Voucher iOS */,
429 | 659AF18E1BEEF1A30031B3A5 /* Voucher tvOS */,
430 | 659AF17D1BEEF1510031B3A5 /* VoucherTests */,
431 | 659AF1C91BEF1D3E0031B3A5 /* Voucher iOS App */,
432 | 659AF1DF1BEF1D530031B3A5 /* Voucher tvOS App */,
433 | );
434 | };
435 | /* End PBXProject section */
436 |
437 | /* Begin PBXResourcesBuildPhase section */
438 | 659AF1721BEEF1510031B3A5 /* Resources */ = {
439 | isa = PBXResourcesBuildPhase;
440 | buildActionMask = 2147483647;
441 | files = (
442 | );
443 | runOnlyForDeploymentPostprocessing = 0;
444 | };
445 | 659AF17C1BEEF1510031B3A5 /* Resources */ = {
446 | isa = PBXResourcesBuildPhase;
447 | buildActionMask = 2147483647;
448 | files = (
449 | );
450 | runOnlyForDeploymentPostprocessing = 0;
451 | };
452 | 659AF1931BEEF1A30031B3A5 /* Resources */ = {
453 | isa = PBXResourcesBuildPhase;
454 | buildActionMask = 2147483647;
455 | files = (
456 | );
457 | runOnlyForDeploymentPostprocessing = 0;
458 | };
459 | 659AF1C81BEF1D3E0031B3A5 /* Resources */ = {
460 | isa = PBXResourcesBuildPhase;
461 | buildActionMask = 2147483647;
462 | files = (
463 | 653F0C671BF18DBC00ED30D0 /* Assets.xcassets in Resources */,
464 | 653F0C661BF18DB900ED30D0 /* LaunchScreen.storyboard in Resources */,
465 | 653F0C681BF18DC000ED30D0 /* Main.storyboard in Resources */,
466 | );
467 | runOnlyForDeploymentPostprocessing = 0;
468 | };
469 | 659AF1DE1BEF1D530031B3A5 /* Resources */ = {
470 | isa = PBXResourcesBuildPhase;
471 | buildActionMask = 2147483647;
472 | files = (
473 | 653F0C731BF18E3900ED30D0 /* Assets.xcassets in Resources */,
474 | 653F0C741BF18E3900ED30D0 /* Main.storyboard in Resources */,
475 | );
476 | runOnlyForDeploymentPostprocessing = 0;
477 | };
478 | /* End PBXResourcesBuildPhase section */
479 |
480 | /* Begin PBXSourcesBuildPhase section */
481 | 659AF16F1BEEF1510031B3A5 /* Sources */ = {
482 | isa = PBXSourcesBuildPhase;
483 | buildActionMask = 2147483647;
484 | files = (
485 | 653F0C4E1BF18CE900ED30D0 /* VoucherStreamsController.m in Sources */,
486 | 653F0C401BF18CE900ED30D0 /* VoucherClient.m in Sources */,
487 | 653F0C461BF18CE900ED30D0 /* VoucherServer.m in Sources */,
488 | );
489 | runOnlyForDeploymentPostprocessing = 0;
490 | };
491 | 659AF17A1BEEF1510031B3A5 /* Sources */ = {
492 | isa = PBXSourcesBuildPhase;
493 | buildActionMask = 2147483647;
494 | files = (
495 | 653F0C7A1BF18EB400ED30D0 /* VoucherTests.m in Sources */,
496 | );
497 | runOnlyForDeploymentPostprocessing = 0;
498 | };
499 | 659AF18F1BEEF1A30031B3A5 /* Sources */ = {
500 | isa = PBXSourcesBuildPhase;
501 | buildActionMask = 2147483647;
502 | files = (
503 | 653F0C4F1BF18CE900ED30D0 /* VoucherStreamsController.m in Sources */,
504 | 653F0C411BF18CE900ED30D0 /* VoucherClient.m in Sources */,
505 | 653F0C471BF18CE900ED30D0 /* VoucherServer.m in Sources */,
506 | );
507 | runOnlyForDeploymentPostprocessing = 0;
508 | };
509 | 659AF1C61BEF1D3E0031B3A5 /* Sources */ = {
510 | isa = PBXSourcesBuildPhase;
511 | buildActionMask = 2147483647;
512 | files = (
513 | 653F0C6A1BF18DC600ED30D0 /* AppDelegate.swift in Sources */,
514 | 653F0C691BF18DC300ED30D0 /* ViewController.swift in Sources */,
515 | );
516 | runOnlyForDeploymentPostprocessing = 0;
517 | };
518 | 659AF1DC1BEF1D530031B3A5 /* Sources */ = {
519 | isa = PBXSourcesBuildPhase;
520 | buildActionMask = 2147483647;
521 | files = (
522 | 653F0C721BF18E3900ED30D0 /* AppDelegate.swift in Sources */,
523 | 653F0C761BF18E3900ED30D0 /* AuthViewController.swift in Sources */,
524 | 653F0C8F1BF1D97900ED30D0 /* RootViewController.swift in Sources */,
525 | );
526 | runOnlyForDeploymentPostprocessing = 0;
527 | };
528 | /* End PBXSourcesBuildPhase section */
529 |
530 | /* Begin PBXTargetDependency section */
531 | 653F0C871BF1CF1300ED30D0 /* PBXTargetDependency */ = {
532 | isa = PBXTargetDependency;
533 | target = 659AF1731BEEF1510031B3A5 /* Voucher iOS */;
534 | targetProxy = 653F0C861BF1CF1300ED30D0 /* PBXContainerItemProxy */;
535 | };
536 | 653F0C8C1BF1CF2200ED30D0 /* PBXTargetDependency */ = {
537 | isa = PBXTargetDependency;
538 | target = 659AF18E1BEEF1A30031B3A5 /* Voucher tvOS */;
539 | targetProxy = 653F0C8B1BF1CF2200ED30D0 /* PBXContainerItemProxy */;
540 | };
541 | 659AF1811BEEF1510031B3A5 /* PBXTargetDependency */ = {
542 | isa = PBXTargetDependency;
543 | target = 659AF1731BEEF1510031B3A5 /* Voucher iOS */;
544 | targetProxy = 659AF1801BEEF1510031B3A5 /* PBXContainerItemProxy */;
545 | };
546 | /* End PBXTargetDependency section */
547 |
548 | /* Begin PBXVariantGroup section */
549 | 653F0C531BF18D7B00ED30D0 /* LaunchScreen.storyboard */ = {
550 | isa = PBXVariantGroup;
551 | children = (
552 | 653F0C541BF18D7B00ED30D0 /* Base */,
553 | );
554 | name = LaunchScreen.storyboard;
555 | sourceTree = "";
556 | };
557 | 653F0C551BF18D7B00ED30D0 /* Main.storyboard */ = {
558 | isa = PBXVariantGroup;
559 | children = (
560 | 653F0C561BF18D7B00ED30D0 /* Base */,
561 | );
562 | name = Main.storyboard;
563 | sourceTree = "";
564 | };
565 | 653F0C6E1BF18E3900ED30D0 /* Main.storyboard */ = {
566 | isa = PBXVariantGroup;
567 | children = (
568 | 653F0C6F1BF18E3900ED30D0 /* Base */,
569 | );
570 | name = Main.storyboard;
571 | sourceTree = "";
572 | };
573 | /* End PBXVariantGroup section */
574 |
575 | /* Begin XCBuildConfiguration section */
576 | 659AF1861BEEF1510031B3A5 /* Debug */ = {
577 | isa = XCBuildConfiguration;
578 | buildSettings = {
579 | ALWAYS_SEARCH_USER_PATHS = NO;
580 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
581 | CLANG_CXX_LIBRARY = "libc++";
582 | CLANG_ENABLE_MODULES = YES;
583 | CLANG_ENABLE_OBJC_ARC = YES;
584 | CLANG_WARN_BOOL_CONVERSION = YES;
585 | CLANG_WARN_CONSTANT_CONVERSION = YES;
586 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
587 | CLANG_WARN_EMPTY_BODY = YES;
588 | CLANG_WARN_ENUM_CONVERSION = YES;
589 | CLANG_WARN_INFINITE_RECURSION = YES;
590 | CLANG_WARN_INT_CONVERSION = YES;
591 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
592 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
593 | CLANG_WARN_UNREACHABLE_CODE = YES;
594 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
595 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
596 | COPY_PHASE_STRIP = NO;
597 | CURRENT_PROJECT_VERSION = 1;
598 | DEBUG_INFORMATION_FORMAT = dwarf;
599 | ENABLE_STRICT_OBJC_MSGSEND = YES;
600 | ENABLE_TESTABILITY = YES;
601 | GCC_C_LANGUAGE_STANDARD = gnu99;
602 | GCC_DYNAMIC_NO_PIC = NO;
603 | GCC_NO_COMMON_BLOCKS = YES;
604 | GCC_OPTIMIZATION_LEVEL = 0;
605 | GCC_PREPROCESSOR_DEFINITIONS = (
606 | "DEBUG=1",
607 | "$(inherited)",
608 | );
609 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
610 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
611 | GCC_WARN_UNDECLARED_SELECTOR = YES;
612 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
613 | GCC_WARN_UNUSED_FUNCTION = YES;
614 | GCC_WARN_UNUSED_VARIABLE = YES;
615 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
616 | MTL_ENABLE_DEBUG_INFO = YES;
617 | ONLY_ACTIVE_ARCH = YES;
618 | SDKROOT = iphoneos;
619 | TARGETED_DEVICE_FAMILY = "1,2";
620 | VERSIONING_SYSTEM = "apple-generic";
621 | VERSION_INFO_PREFIX = "";
622 | };
623 | name = Debug;
624 | };
625 | 659AF1871BEEF1510031B3A5 /* Release */ = {
626 | isa = XCBuildConfiguration;
627 | buildSettings = {
628 | ALWAYS_SEARCH_USER_PATHS = NO;
629 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
630 | CLANG_CXX_LIBRARY = "libc++";
631 | CLANG_ENABLE_MODULES = YES;
632 | CLANG_ENABLE_OBJC_ARC = YES;
633 | CLANG_WARN_BOOL_CONVERSION = YES;
634 | CLANG_WARN_CONSTANT_CONVERSION = YES;
635 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
636 | CLANG_WARN_EMPTY_BODY = YES;
637 | CLANG_WARN_ENUM_CONVERSION = YES;
638 | CLANG_WARN_INFINITE_RECURSION = YES;
639 | CLANG_WARN_INT_CONVERSION = YES;
640 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
641 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
642 | CLANG_WARN_UNREACHABLE_CODE = YES;
643 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
644 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
645 | COPY_PHASE_STRIP = NO;
646 | CURRENT_PROJECT_VERSION = 1;
647 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
648 | ENABLE_NS_ASSERTIONS = NO;
649 | ENABLE_STRICT_OBJC_MSGSEND = YES;
650 | GCC_C_LANGUAGE_STANDARD = gnu99;
651 | GCC_NO_COMMON_BLOCKS = YES;
652 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
653 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
654 | GCC_WARN_UNDECLARED_SELECTOR = YES;
655 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
656 | GCC_WARN_UNUSED_FUNCTION = YES;
657 | GCC_WARN_UNUSED_VARIABLE = YES;
658 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
659 | MTL_ENABLE_DEBUG_INFO = NO;
660 | SDKROOT = iphoneos;
661 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
662 | TARGETED_DEVICE_FAMILY = "1,2";
663 | VALIDATE_PRODUCT = YES;
664 | VERSIONING_SYSTEM = "apple-generic";
665 | VERSION_INFO_PREFIX = "";
666 | };
667 | name = Release;
668 | };
669 | 659AF1891BEEF1510031B3A5 /* Debug */ = {
670 | isa = XCBuildConfiguration;
671 | buildSettings = {
672 | CODE_SIGN_IDENTITY = "iPhone Developer";
673 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
674 | DEFINES_MODULE = YES;
675 | DYLIB_COMPATIBILITY_VERSION = 1;
676 | DYLIB_CURRENT_VERSION = 1;
677 | DYLIB_INSTALL_NAME_BASE = "@rpath";
678 | INFOPLIST_FILE = Voucher/Info.plist;
679 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
680 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
681 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
682 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.Voucher;
683 | PRODUCT_NAME = Voucher;
684 | SKIP_INSTALL = YES;
685 | SWIFT_VERSION = 3.0;
686 | };
687 | name = Debug;
688 | };
689 | 659AF18A1BEEF1510031B3A5 /* Release */ = {
690 | isa = XCBuildConfiguration;
691 | buildSettings = {
692 | CODE_SIGN_IDENTITY = "iPhone Distribution";
693 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
694 | DEFINES_MODULE = YES;
695 | DYLIB_COMPATIBILITY_VERSION = 1;
696 | DYLIB_CURRENT_VERSION = 1;
697 | DYLIB_INSTALL_NAME_BASE = "@rpath";
698 | INFOPLIST_FILE = Voucher/Info.plist;
699 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
700 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
701 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
702 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.Voucher;
703 | PRODUCT_NAME = Voucher;
704 | SKIP_INSTALL = YES;
705 | SWIFT_VERSION = 3.0;
706 | };
707 | name = Release;
708 | };
709 | 659AF18C1BEEF1510031B3A5 /* Debug */ = {
710 | isa = XCBuildConfiguration;
711 | buildSettings = {
712 | INFOPLIST_FILE = VoucherTests/Info.plist;
713 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
714 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.VoucherTests;
715 | PRODUCT_NAME = Voucher;
716 | };
717 | name = Debug;
718 | };
719 | 659AF18D1BEEF1510031B3A5 /* Release */ = {
720 | isa = XCBuildConfiguration;
721 | buildSettings = {
722 | INFOPLIST_FILE = VoucherTests/Info.plist;
723 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
724 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.VoucherTests;
725 | PRODUCT_NAME = Voucher;
726 | };
727 | name = Release;
728 | };
729 | 659AF1951BEEF1A30031B3A5 /* Debug */ = {
730 | isa = XCBuildConfiguration;
731 | buildSettings = {
732 | CODE_SIGN_IDENTITY = "iPhone Developer";
733 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
734 | DEFINES_MODULE = YES;
735 | DYLIB_COMPATIBILITY_VERSION = 1;
736 | DYLIB_CURRENT_VERSION = 1;
737 | DYLIB_INSTALL_NAME_BASE = "@rpath";
738 | INFOPLIST_FILE = Voucher/Info.plist;
739 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
740 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
741 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.Voucher;
742 | PRODUCT_NAME = Voucher;
743 | SDKROOT = appletvos;
744 | SKIP_INSTALL = YES;
745 | SWIFT_VERSION = 3.0;
746 | TARGETED_DEVICE_FAMILY = 3;
747 | TVOS_DEPLOYMENT_TARGET = 9.0;
748 | };
749 | name = Debug;
750 | };
751 | 659AF1961BEEF1A30031B3A5 /* Release */ = {
752 | isa = XCBuildConfiguration;
753 | buildSettings = {
754 | CODE_SIGN_IDENTITY = "iPhone Developer";
755 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
756 | DEFINES_MODULE = YES;
757 | DYLIB_COMPATIBILITY_VERSION = 1;
758 | DYLIB_CURRENT_VERSION = 1;
759 | DYLIB_INSTALL_NAME_BASE = "@rpath";
760 | INFOPLIST_FILE = Voucher/Info.plist;
761 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
762 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
763 | PRODUCT_BUNDLE_IDENTIFIER = com.rizwansattar.Voucher;
764 | PRODUCT_NAME = Voucher;
765 | SDKROOT = appletvos;
766 | SKIP_INSTALL = YES;
767 | SWIFT_VERSION = 3.0;
768 | TARGETED_DEVICE_FAMILY = 3;
769 | TVOS_DEPLOYMENT_TARGET = 9.0;
770 | };
771 | name = Release;
772 | };
773 | 659AF1D91BEF1D3E0031B3A5 /* Debug */ = {
774 | isa = XCBuildConfiguration;
775 | buildSettings = {
776 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
777 | CODE_SIGN_IDENTITY = "iPhone Developer";
778 | INFOPLIST_FILE = "Voucher iOS App/Info.plist";
779 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
780 | PRODUCT_BUNDLE_IDENTIFIER = "com.rizwansattar.Voucher-iOS-App";
781 | PRODUCT_NAME = "Voucher iOS App";
782 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
783 | SWIFT_VERSION = 3.0;
784 | };
785 | name = Debug;
786 | };
787 | 659AF1DA1BEF1D3E0031B3A5 /* Release */ = {
788 | isa = XCBuildConfiguration;
789 | buildSettings = {
790 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
791 | CODE_SIGN_IDENTITY = "iPhone Distribution";
792 | INFOPLIST_FILE = "Voucher iOS App/Info.plist";
793 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
794 | PRODUCT_BUNDLE_IDENTIFIER = "com.rizwansattar.Voucher-iOS-App";
795 | PRODUCT_NAME = "Voucher iOS App";
796 | SWIFT_VERSION = 3.0;
797 | };
798 | name = Release;
799 | };
800 | 659AF1ED1BEF1D540031B3A5 /* Debug */ = {
801 | isa = XCBuildConfiguration;
802 | buildSettings = {
803 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
804 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
805 | CODE_SIGN_IDENTITY = "iPhone Developer";
806 | INFOPLIST_FILE = "Voucher tvOS App/Info.plist";
807 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
808 | PRODUCT_BUNDLE_IDENTIFIER = "com.rizwansattar.Voucher-tvOS-App";
809 | PRODUCT_NAME = "Voucher tvOS App";
810 | SDKROOT = appletvos;
811 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
812 | SWIFT_VERSION = 3.0;
813 | TARGETED_DEVICE_FAMILY = 3;
814 | TVOS_DEPLOYMENT_TARGET = 9.0;
815 | };
816 | name = Debug;
817 | };
818 | 659AF1EE1BEF1D540031B3A5 /* Release */ = {
819 | isa = XCBuildConfiguration;
820 | buildSettings = {
821 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
822 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
823 | CODE_SIGN_IDENTITY = "iPhone Developer";
824 | INFOPLIST_FILE = "Voucher tvOS App/Info.plist";
825 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
826 | PRODUCT_BUNDLE_IDENTIFIER = "com.rizwansattar.Voucher-tvOS-App";
827 | PRODUCT_NAME = "Voucher tvOS App";
828 | SDKROOT = appletvos;
829 | SWIFT_VERSION = 3.0;
830 | TARGETED_DEVICE_FAMILY = 3;
831 | TVOS_DEPLOYMENT_TARGET = 9.0;
832 | };
833 | name = Release;
834 | };
835 | /* End XCBuildConfiguration section */
836 |
837 | /* Begin XCConfigurationList section */
838 | 659AF16E1BEEF1510031B3A5 /* Build configuration list for PBXProject "Voucher" */ = {
839 | isa = XCConfigurationList;
840 | buildConfigurations = (
841 | 659AF1861BEEF1510031B3A5 /* Debug */,
842 | 659AF1871BEEF1510031B3A5 /* Release */,
843 | );
844 | defaultConfigurationIsVisible = 0;
845 | defaultConfigurationName = Release;
846 | };
847 | 659AF1881BEEF1510031B3A5 /* Build configuration list for PBXNativeTarget "Voucher iOS" */ = {
848 | isa = XCConfigurationList;
849 | buildConfigurations = (
850 | 659AF1891BEEF1510031B3A5 /* Debug */,
851 | 659AF18A1BEEF1510031B3A5 /* Release */,
852 | );
853 | defaultConfigurationIsVisible = 0;
854 | defaultConfigurationName = Release;
855 | };
856 | 659AF18B1BEEF1510031B3A5 /* Build configuration list for PBXNativeTarget "VoucherTests" */ = {
857 | isa = XCConfigurationList;
858 | buildConfigurations = (
859 | 659AF18C1BEEF1510031B3A5 /* Debug */,
860 | 659AF18D1BEEF1510031B3A5 /* Release */,
861 | );
862 | defaultConfigurationIsVisible = 0;
863 | defaultConfigurationName = Release;
864 | };
865 | 659AF1941BEEF1A30031B3A5 /* Build configuration list for PBXNativeTarget "Voucher tvOS" */ = {
866 | isa = XCConfigurationList;
867 | buildConfigurations = (
868 | 659AF1951BEEF1A30031B3A5 /* Debug */,
869 | 659AF1961BEEF1A30031B3A5 /* Release */,
870 | );
871 | defaultConfigurationIsVisible = 0;
872 | defaultConfigurationName = Release;
873 | };
874 | 659AF1DB1BEF1D3E0031B3A5 /* Build configuration list for PBXNativeTarget "Voucher iOS App" */ = {
875 | isa = XCConfigurationList;
876 | buildConfigurations = (
877 | 659AF1D91BEF1D3E0031B3A5 /* Debug */,
878 | 659AF1DA1BEF1D3E0031B3A5 /* Release */,
879 | );
880 | defaultConfigurationIsVisible = 0;
881 | defaultConfigurationName = Release;
882 | };
883 | 659AF1EC1BEF1D540031B3A5 /* Build configuration list for PBXNativeTarget "Voucher tvOS App" */ = {
884 | isa = XCConfigurationList;
885 | buildConfigurations = (
886 | 659AF1ED1BEF1D540031B3A5 /* Debug */,
887 | 659AF1EE1BEF1D540031B3A5 /* Release */,
888 | );
889 | defaultConfigurationIsVisible = 0;
890 | defaultConfigurationName = Release;
891 | };
892 | /* End XCConfigurationList section */
893 | };
894 | rootObject = 659AF16B1BEEF1510031B3A5 /* Project object */;
895 | }
896 |
--------------------------------------------------------------------------------
/Voucher.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Voucher.xcodeproj/xcshareddata/xcschemes/Voucher iOS.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 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/Voucher.xcodeproj/xcshareddata/xcschemes/Voucher tvOS.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 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Voucher/Client/VoucherClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherClient.h
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "VoucherStreamsController.h"
11 |
12 | @class VoucherClient;
13 | @protocol VoucherClientDelegate
14 |
15 | @optional
16 | - (void)voucherClient:(nonnull VoucherClient *)client didUpdateSearching:(BOOL)isSearching;
17 | - (void)voucherClient:(nonnull VoucherClient *)client didUpdateConnectionToServer:(BOOL)isConnectedToServer serverName:(nullable NSString *)serverName;
18 |
19 | @end
20 |
21 |
22 | typedef void (^VoucherClientCompletionHandler)( NSData * _Nullable authData, NSString * _Nullable responderDisplayName, NSError * _Nullable error);
23 |
24 | @interface VoucherClient : VoucherStreamsController
25 |
26 | @property (weak, nonatomic, nullable) NSObject *delegate;
27 |
28 | @property (readonly, copy, nonatomic, nonnull) NSString *displayName;
29 | @property (readonly, copy, nonatomic, nonnull) NSString *uniqueSharedId;
30 | @property (readonly, assign, nonatomic) BOOL isSearching;
31 |
32 | - (nonnull instancetype)init NS_UNAVAILABLE;
33 | - (nonnull instancetype)initWithUniqueSharedId:(nonnull NSString *)uniqueSharedId displayName:(nullable NSString *)displayName NS_DESIGNATED_INITIALIZER;
34 | - (nonnull instancetype)initWithUniqueSharedId:(nonnull NSString *)uniqueSharedId;
35 |
36 | - (void)startSearchingWithCompletion:(nonnull VoucherClientCompletionHandler)completionHandler;
37 | - (void)stop;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Voucher/Client/VoucherClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherClient.m
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import "VoucherClient.h"
10 | #import "VoucherCommon.h"
11 |
12 | #import // Just needed for deviceName
13 |
14 | @interface VoucherClient ()
15 |
16 | @property (copy, nonatomic) NSString *displayName;
17 | @property (copy, nonatomic) NSString *uniqueSharedId;
18 | @property (assign, nonatomic) BOOL isSearching;
19 | @property (assign, nonatomic) BOOL isConnectedToServer;
20 |
21 | @property (copy, nonatomic) VoucherClientCompletionHandler completionHandler;
22 |
23 | // Browsing
24 | @property (strong, nonatomic) NSNetServiceBrowser *browser;
25 | @property (copy, nonatomic) NSString *serviceName;
26 | @property (strong, nonatomic) NSMutableArray *currentlyAvailableServices;
27 |
28 | @property (strong, nonatomic) NSNetService *server;
29 |
30 | @end
31 |
32 | @implementation VoucherClient
33 |
34 | - (instancetype)initWithUniqueSharedId:(NSString *)uniqueSharedId displayName:(NSString *)displayName
35 | {
36 | self = [super init];
37 | if (self) {
38 | self.uniqueSharedId = uniqueSharedId;
39 | NSString *appString = [self.uniqueSharedId stringByReplacingOccurrencesOfString:@"." withString:@"_"];
40 | self.serviceName = [NSString stringWithFormat:kVoucherServiceNameFormat, appString];
41 | if (displayName.length == 0) {
42 | displayName = [UIDevice currentDevice].name;
43 | }
44 | self.displayName = displayName;
45 | }
46 | return self;
47 | }
48 |
49 | - (instancetype)initWithUniqueSharedId:(NSString *)uniqueSharedId
50 | {
51 | return [self initWithUniqueSharedId:uniqueSharedId displayName:nil];
52 | }
53 |
54 | - (void)dealloc
55 | {
56 | [self stop];
57 | }
58 |
59 | - (void)startSearchingWithCompletion:(VoucherClientCompletionHandler)completionHandler
60 | {
61 | if (self.isSearching) {
62 | [self stopSearching];
63 | }
64 |
65 | self.currentlyAvailableServices = [NSMutableArray arrayWithCapacity:2];
66 |
67 | self.completionHandler = completionHandler;
68 |
69 | self.browser = [[NSNetServiceBrowser alloc] init];
70 | self.browser.includesPeerToPeer = YES;
71 | self.browser.delegate = self;
72 | [self.browser searchForServicesOfType:self.serviceName inDomain:@"local"];
73 | }
74 |
75 | - (void)stop
76 | {
77 | [self disconnectFromServer];
78 | [self stopSearching];
79 | self.completionHandler = nil;
80 | }
81 |
82 | - (void)stopSearching
83 | {
84 | [self.currentlyAvailableServices removeAllObjects];
85 |
86 | [self.browser stop];
87 | self.browser.delegate = nil;
88 | self.browser = nil;
89 | }
90 |
91 |
92 | #pragma mark - Services
93 |
94 | - (void)connectToAvailableServer
95 | {
96 | if (!self.isConnectedToServer && self.currentlyAvailableServices.count > 0) {
97 | NSNetService *service = self.currentlyAvailableServices[0];
98 | [self connectToServer:service];
99 | } else {
100 | NSLog(@"No available server to connect to, yet.");
101 | }
102 | }
103 |
104 | - (void)connectToServer:(NSNetService *)service
105 | {
106 | NSAssert(self.currentlyAvailableServices.count > 0,
107 | @"Tried to select a service when none were available");
108 | if (service == nil) {
109 | service = self.currentlyAvailableServices[0];
110 | }
111 | NSAssert([self.currentlyAvailableServices containsObject:service],
112 | @"Tried to select a service which we don't know about");
113 |
114 | self.server = service;
115 | self.server.delegate = self;
116 |
117 | NSInputStream *inputStream;
118 | NSOutputStream *outputStream;
119 |
120 | BOOL success = [self.server getInputStream:&inputStream outputStream:&outputStream];
121 | if (success) {
122 | self.isConnectedToServer = YES;
123 | self.inputStream = inputStream;
124 | self.outputStream = outputStream;
125 |
126 | [self openStreams];
127 |
128 | [self sendAuthRequest];
129 | }
130 | }
131 |
132 | - (void)disconnectFromServer
133 | {
134 | [self closeStreams];
135 | self.server.delegate = nil;
136 | self.server = nil;
137 | self.isConnectedToServer = NO;
138 | }
139 |
140 | - (void)handleStreamEnd:(NSStream *)stream
141 | {
142 | // On an unexpected ending of the stream, disconnect
143 | // and try and find the next available server (if any)
144 | [super handleStreamEnd:stream];
145 | [self disconnectFromServer];
146 | [self connectToAvailableServer];
147 |
148 | }
149 |
150 | - (void)sendAuthRequest
151 | {
152 | NSDictionary *requestDict = @{@"displayName" : self.displayName};
153 | NSData *requestData = [NSKeyedArchiver archivedDataWithRootObject:requestDict];
154 | [self sendData:requestData];
155 | }
156 |
157 |
158 | - (void)handleReceivedData:(NSData *)data
159 | {
160 | [super handleReceivedData:data];
161 | NSDictionary *responseDict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
162 | NSData *authData = responseDict[@"authData"];
163 | NSString *responderDisplayName = responseDict[@"displayName"];
164 | if (self.completionHandler) {
165 | self.completionHandler(authData, responderDisplayName, nil);
166 | }
167 | [self stop];
168 | }
169 |
170 | #pragma mark - NSNetServiceBrowserDelegate
171 |
172 | /* Sent to the NSNetServiceBrowser instance's delegate before the instance begins a search. The delegate will not receive this message if the instance is unable to begin a search. Instead, the delegate will receive the -netServiceBrowser:didNotSearch: message.
173 | */
174 | - (void)netServiceBrowserWillSearch:(NSNetServiceBrowser *)browser
175 | {
176 | NSLog(@"Browser will search");
177 | self.isSearching = YES;
178 | }
179 |
180 | /* Sent to the NSNetServiceBrowser instance's delegate when the instance's previous running search request has stopped.
181 | */
182 | - (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)browser
183 | {
184 | NSLog(@"Browser did stop search");
185 | self.isSearching = NO;
186 | }
187 |
188 | /* Sent to the NSNetServiceBrowser instance's delegate when an error in searching for domains or services has occurred. The error dictionary will contain two key/value pairs representing the error domain and code (see the NSNetServicesError enumeration above for error code constants). It is possible for an error to occur after a search has been started successfully.
189 | */
190 | - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didNotSearch:(NSDictionary *)errorDict
191 | {
192 | NSLog(@"\nBrowser did not search:");
193 | for (NSString *errorDomain in errorDict) {
194 | NSNumber *errorCode = errorDict[errorDomain];
195 | NSLog(@" '%@': %@", errorDomain, errorCode);
196 | }
197 | self.isSearching = NO;
198 | }
199 |
200 | /* Sent to the NSNetServiceBrowser instance's delegate for each domain discovered. If there are more domains, moreComing will be YES. If for some reason handling discovered domains requires significant processing, accumulating domains until moreComing is NO and then doing the processing in bulk fashion may be desirable.
201 | */
202 | - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didFindDomain:(NSString *)domainString moreComing:(BOOL)moreComing
203 | {
204 | NSLog(@"Browser found domain: %@, more coming: %@", domainString, (moreComing ? @"YES" : @"NO"));
205 | }
206 |
207 | /* Sent to the NSNetServiceBrowser instance's delegate for each service discovered. If there are more services, moreComing will be YES. If for some reason handling discovered services requires significant processing, accumulating services until moreComing is NO and then doing the processing in bulk fashion may be desirable.
208 | */
209 | - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didFindService:(NSNetService *)service moreComing:(BOOL)moreComing
210 | {
211 | NSLog(@"Browser found service: %@, more coming: %@", service.name, (moreComing ? @"YES" : @"NO"));
212 | if (![self.currentlyAvailableServices containsObject:service]) {
213 | [self.currentlyAvailableServices addObject:service];
214 | }
215 | [self connectToAvailableServer];
216 | }
217 |
218 | /* Sent to the NSNetServiceBrowser instance's delegate when a previously discovered domain is no longer available.
219 | */
220 | - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didRemoveDomain:(NSString *)domainString moreComing:(BOOL)moreComing
221 | {
222 | NSLog(@"Browser removed domain: %@, more coming: %@", domainString, (moreComing ? @"YES" : @"NO"));
223 | }
224 |
225 | /* Sent to the NSNetServiceBrowser instance's delegate when a previously discovered service is no longer published.
226 | */
227 | - (void)netServiceBrowser:(NSNetServiceBrowser *)browser didRemoveService:(NSNetService *)service moreComing:(BOOL)moreComing
228 | {
229 | NSLog(@"Browser removed service: %@, more coming: %@", service.name, (moreComing ? @"YES" : @"NO"));
230 | if ([self.currentlyAvailableServices containsObject:service]) {
231 | [self.currentlyAvailableServices removeObject:service];
232 | }
233 | if (!moreComing) {
234 | // No more to remove, now check if our server is one of them, and if so, disconnect, and go back to searching
235 | if (self.server && ![self.currentlyAvailableServices containsObject:self.server]) {
236 | [self disconnectFromServer];
237 | // Connect to next server, if one is available
238 | [self connectToAvailableServer];
239 | }
240 | }
241 | }
242 |
243 | #pragma mark - Setters
244 |
245 | - (void)setIsSearching:(BOOL)isSearching
246 | {
247 | if (_isSearching == isSearching) {
248 | return;
249 | }
250 | _isSearching = isSearching;
251 | if ([self.delegate respondsToSelector:@selector(voucherClient:didUpdateSearching:)]) {
252 | [self.delegate voucherClient:self didUpdateSearching:_isSearching];
253 | }
254 | }
255 |
256 | - (void)setIsConnectedToServer:(BOOL)isConnectedToServer
257 | {
258 | if (_isConnectedToServer == isConnectedToServer) {
259 | return;
260 | }
261 | _isConnectedToServer = isConnectedToServer;
262 | if ([self.delegate respondsToSelector:@selector(voucherClient:didUpdateConnectionToServer:serverName:)]) {
263 | [self.delegate voucherClient:self didUpdateConnectionToServer:_isConnectedToServer serverName:self.server.name];
264 | }
265 | }
266 |
267 | @end
268 |
--------------------------------------------------------------------------------
/Voucher/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
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Voucher/Server/VoucherServer.h:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherServer.h
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "VoucherStreamsController.h"
11 |
12 | @class VoucherServer;
13 | @protocol VoucherServerDelegate
14 |
15 | @optional
16 | - (void)voucherServer:(nonnull VoucherServer *)server didUpdateAdvertising:(BOOL)isAdvertising;
17 | - (void)voucherServer:(nonnull VoucherServer *)server didUpdateConnectionToClient:(BOOL)isConnectedToClient;
18 | @end
19 |
20 |
21 | typedef void (^VoucherServerResponseHandler)(NSData * _Nullable authData, NSError * _Nullable error);
22 | typedef void (^VoucherServerRequestHandler)(NSString * _Nonnull displayName, VoucherServerResponseHandler _Nonnull responseHandler);
23 |
24 | @interface VoucherServer : VoucherStreamsController
25 |
26 | @property (weak, nonatomic, nullable) NSObject *delegate;
27 |
28 | @property (readonly, copy, nonatomic, nonnull) NSString *displayName;
29 | @property (readonly, copy, nonatomic, nonnull) NSString *uniqueSharedId;
30 | @property (readonly, assign, nonatomic) BOOL isAdvertising;
31 | @property (readonly, assign, nonatomic) BOOL isConnectedToClient;
32 |
33 | - (nonnull instancetype)init NS_UNAVAILABLE;
34 | - (nonnull instancetype)initWithUniqueSharedId:(nonnull NSString *)uniqueSharedId displayName:(nullable NSString *)displayName NS_DESIGNATED_INITIALIZER;
35 | - (nonnull instancetype)initWithUniqueSharedId:(nonnull NSString *)uniqueSharedId;
36 |
37 | - (void)startAdvertisingWithRequestHandler:(nonnull VoucherServerRequestHandler)requestHandler;
38 | - (void)stop;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Voucher/Server/VoucherServer.m:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherServer.m
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import "VoucherServer.h"
10 | #import "VoucherCommon.h"
11 |
12 | #import // Just needed for deviceName
13 |
14 | @interface VoucherServer ()
15 |
16 | @property (copy, nonatomic) NSString *displayName;
17 | @property (copy, nonatomic) NSString *uniqueSharedId;
18 | @property (assign, nonatomic) BOOL isAdvertising;
19 | @property (assign, nonatomic) BOOL shouldBeAdvertising;
20 | @property (assign, nonatomic) BOOL isConnectedToClient;
21 |
22 | // Advertising
23 | @property (copy, nonatomic) VoucherServerRequestHandler requestHandler;
24 | @property (strong, nonatomic) NSNetService *server;
25 | @property (copy, nonatomic) NSString *registeredServerName;
26 | @property (copy, nonatomic) NSString *serviceName;
27 | @end
28 |
29 | @implementation VoucherServer
30 |
31 | - (instancetype)initWithUniqueSharedId:(NSString *)uniqueSharedId displayName:(NSString *)displayName
32 | {
33 | self = [super init];
34 | if (self) {
35 | self.uniqueSharedId = uniqueSharedId;
36 | NSString *appString = [self.uniqueSharedId stringByReplacingOccurrencesOfString:@"." withString:@"_"];
37 | self.serviceName = [NSString stringWithFormat:kVoucherServiceNameFormat, appString];
38 | if (displayName.length == 0) {
39 | displayName = [UIDevice currentDevice].name;
40 | }
41 | self.displayName = displayName;
42 | }
43 | return self;
44 | }
45 |
46 | - (instancetype)initWithUniqueSharedId:(NSString *)uniqueSharedId
47 | {
48 | return [self initWithUniqueSharedId:uniqueSharedId displayName:nil];
49 | }
50 |
51 | - (void)dealloc
52 | {
53 | [self stop];
54 | }
55 |
56 | - (void)startAdvertisingWithRequestHandler:(VoucherServerRequestHandler)requestHandler
57 | {
58 | if (self.server != nil) {
59 | [self stopAdvertising];
60 | }
61 |
62 | self.shouldBeAdvertising = YES;
63 | self.requestHandler = requestHandler;
64 |
65 | self.server = [[NSNetService alloc] initWithDomain:@"local"
66 | type:self.serviceName
67 | name:self.displayName];
68 | self.server.includesPeerToPeer = YES;
69 | self.server.delegate = self;
70 | [self.server publishWithOptions:NSNetServiceListenForConnections];
71 |
72 | }
73 |
74 | - (void)stop
75 | {
76 | [self disconnectClient];
77 | [self stopAdvertising];
78 | self.requestHandler = nil;
79 | }
80 |
81 | - (void)stopAdvertising
82 | {
83 | self.shouldBeAdvertising = NO;
84 |
85 | if (self.server != nil) {
86 | [self.server stop];
87 | self.server.delegate = nil;
88 | self.server = nil;
89 | }
90 | self.registeredServerName = nil;
91 | self.isAdvertising = NO;
92 | }
93 |
94 | - (void)disconnectClient
95 | {
96 | [self closeStreams];
97 | }
98 |
99 | - (void)closeStreams
100 | {
101 | [super closeStreams];
102 | self.isConnectedToClient = NO;
103 | }
104 |
105 | - (void)openStreams
106 | {
107 | [super openStreams];
108 | self.isConnectedToClient = YES;
109 | }
110 |
111 |
112 | #pragma mark - Overall Events
113 |
114 |
115 | - (void)handleReceivedData:(NSData *)data
116 | {
117 | // We send/receive information as a NSDictionary written out
118 | // as NSData, so convert from NSData --> NSDictionary
119 | NSDictionary *dict = (NSDictionary *)[NSKeyedUnarchiver unarchiveObjectWithData:data];
120 | [self handleIncomingRequestDictionary:dict];
121 | }
122 |
123 |
124 | - (void)handleIncomingRequestDictionary:(NSDictionary *)requestDict
125 | {
126 | NSLog(@"Received request: \n%@", requestDict);
127 | NSString *displayName = requestDict[@"displayName"];
128 | if (self.requestHandler) {
129 | __weak VoucherServer *_weakSelf = self;
130 | self.requestHandler(displayName, ^(NSData * authData, NSError * error) {
131 |
132 | NSAssert(error == nil, @"Error handling not yet implemented");
133 |
134 | NSDictionary *responseDict = nil;
135 | if (authData.length) {
136 | // App has granted us some data
137 | responseDict = @{@"authData" : authData, @"displayName" : _weakSelf.displayName};
138 | } else {
139 | // Don't send back any response data, except our display name
140 | responseDict = @{@"displayName" : _weakSelf.displayName};
141 | }
142 | NSData *responseData = [NSKeyedArchiver archivedDataWithRootObject:responseDict];
143 | [_weakSelf sendData:responseData];
144 |
145 | });
146 | }
147 | }
148 |
149 |
150 | - (void)handleStreamEnd:(NSStream *)stream
151 | {
152 | [super handleStreamEnd:stream];
153 |
154 | NSLog(@"Encountered unexpected stream end on VoucherServer, restarting server");
155 | // An unexpected error occurred here, so
156 | // restart server (is this the right move here?)
157 | [self startAdvertisingWithRequestHandler:self.requestHandler];
158 | }
159 |
160 |
161 | #pragma mark - NSNetServiceDelegate
162 |
163 |
164 | - (void)netServiceDidPublish:(NSNetService *)sender
165 | {
166 | assert(sender == self.server);
167 | self.isAdvertising = YES;
168 | self.registeredServerName = self.server.name;
169 | NSLog(@"Advertising Voucher Server as: '%@'", self.registeredServerName);
170 | }
171 |
172 | - (void)netService:(NSNetService *)sender didAcceptConnectionWithInputStream:(NSInputStream *)inputStream outputStream:(NSOutputStream *)outputStream
173 | {
174 | // Due to a bug , this method is called on some unspecified
175 | // queue rather than the queue associated with the net service (which in this case
176 | // is the main queue). Work around this by bouncing to the main queue.
177 | [[NSOperationQueue mainQueue] addOperationWithBlock:^{
178 | assert(sender == self.server);
179 | #pragma unused(sender)
180 | assert(inputStream != nil);
181 | assert(outputStream != nil);
182 |
183 | assert( (self.inputStream != nil) == (self.outputStream != nil) ); // should either have both or neither
184 |
185 | if (self.inputStream != nil) {
186 | // We already have a connection, reject this one
187 | [inputStream open];
188 | [inputStream close];
189 | [outputStream open];
190 | [outputStream close];
191 | } else {
192 |
193 | // Latch the input and output sterams and kick off an open.
194 |
195 | self.inputStream = inputStream;
196 | self.outputStream = outputStream;
197 |
198 | [self openStreams];
199 | }
200 | }];
201 | }
202 |
203 | - (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict
204 | // This is called when the server stops of its own accord. The only reason
205 | // that might happen is if the Bonjour registration fails when we reregister
206 | // the server, and that's hard to trigger because we use auto-rename. I've
207 | // left an assert here so that, if this does happen, we can figure out why it
208 | // happens and then decide how best to handle it.
209 | {
210 | assert(sender == self.server);
211 | self.isAdvertising = NO;
212 | // This will also get called if, while the server is published, the app
213 | // (iOS) goes to the background, then comes back.
214 | // This fails with a NSNetServicesUnknownError (-72000). For Voucher,
215 | // we want to get the server back up and running, if we already thought
216 | // we were
217 | #pragma unused(sender)
218 | NSNetServicesError errorCode = [errorDict[NSNetServicesErrorCode] integerValue];
219 | NSLog(@"Voucher Server stopped publishing, due to error: %ld", (long)errorCode);
220 | if (errorCode == NSNetServicesUnknownError) {
221 | if (self.shouldBeAdvertising) {
222 | NSLog(@"Restarting Voucher Server...");
223 | [self startAdvertisingWithRequestHandler:self.requestHandler];
224 | }
225 | }
226 | }
227 |
228 |
229 | #pragma mark - Setters
230 |
231 | - (void)setIsAdvertising:(BOOL)isAdvertising
232 | {
233 | if (_isAdvertising == isAdvertising) {
234 | return;
235 | }
236 | _isAdvertising = isAdvertising;
237 | if ([self.delegate respondsToSelector:@selector(voucherServer:didUpdateAdvertising:)]) {
238 | [self.delegate voucherServer:self didUpdateAdvertising:_isAdvertising];
239 | }
240 | }
241 |
242 | - (void)setIsConnectedToClient:(BOOL)isConnectedToClient
243 | {
244 | if (_isConnectedToClient == isConnectedToClient) {
245 | return;
246 | }
247 | _isConnectedToClient = isConnectedToClient;
248 | if ([self.delegate respondsToSelector:@selector(voucherServer:didUpdateConnectionToClient:)]) {
249 | [self.delegate voucherServer:self didUpdateConnectionToClient:_isConnectedToClient];
250 | }
251 | }
252 | @end
253 |
--------------------------------------------------------------------------------
/Voucher/Voucher.h:
--------------------------------------------------------------------------------
1 | //
2 | // Voucher.h
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Voucher.
12 | FOUNDATION_EXPORT double VoucherVersionNumber;
13 |
14 | //! Project version string for Voucher.
15 | FOUNDATION_EXPORT const unsigned char VoucherVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 | #import
20 | #import
21 | #import
22 | #import
23 |
24 |
--------------------------------------------------------------------------------
/Voucher/VoucherCommon.h:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherCommon.h
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #ifndef VoucherCommon_h
10 | #define VoucherCommon_h
11 | #import
12 |
13 | static NSString * kVoucherServiceNameFormat = @"_voucher_%@._tcp.";
14 |
15 | #endif /* VoucherCommon_h */
16 |
--------------------------------------------------------------------------------
/Voucher/VoucherStreamsController.h:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherStreamsController.h
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface VoucherStreamsController : NSObject
12 |
13 | @property (strong, nonatomic, nullable) NSInputStream *inputStream;
14 | @property (strong, nonatomic, nullable) NSOutputStream *outputStream;
15 | @property (assign, nonatomic) NSUInteger streamOpenCount;
16 |
17 | - (void)openStreams;
18 | - (void)closeStreams;
19 |
20 | - (void)sendData:(nonnull NSData *)data;
21 | - (void)handleReceivedData:(nonnull NSData *)data;
22 |
23 | - (void)handleStreamEnd:(nonnull NSStream *)stream;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/Voucher/VoucherStreamsController.m:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherStreamsController.m
3 | // Voucher
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | static NSUInteger const BUFFER_SIZE = 1024;
12 |
13 | @interface VoucherStreamsController ()
14 |
15 | @property (strong, nonatomic) NSMutableData *dataReadBuffer;
16 | @property (assign, nonatomic) int64_t expectedReadLength;
17 | @property (strong, nonatomic) NSMutableData *dataSendBuffer;
18 | @property (assign, nonatomic) NSUInteger sendBufferByteIndex;
19 |
20 | @end
21 |
22 | @implementation VoucherStreamsController
23 |
24 |
25 | - (void) dealloc
26 | {
27 | [self closeStreams];
28 | self.dataSendBuffer = nil;
29 | self.dataReadBuffer = nil;
30 | }
31 |
32 |
33 | #pragma mark - Overall Events
34 |
35 | - (void)sendData:(nonnull NSData *)data
36 | {
37 | // TODO(Riz): Queue up multiple sendData: requests,
38 | // so they don't stomp on each other
39 | self.dataSendBuffer = [NSMutableData dataWithCapacity:8+data.length];
40 | // First, append the length of the data, as a long
41 | uint64_t lengthPreamble = htonll((uint64_t)data.length);
42 | [self.dataSendBuffer appendBytes:&lengthPreamble length:sizeof(lengthPreamble)];
43 | // Then append the actual data
44 | [self.dataSendBuffer appendData:data];
45 | self.sendBufferByteIndex = 0;
46 | if (self.outputStream.hasSpaceAvailable) {
47 | [self flushSendDataIfAvailable];
48 | }
49 | }
50 |
51 |
52 | - (void)handleReceivedData:(nonnull NSData *)data
53 | {
54 | NSLog(@"Received data of length: %lu", (unsigned long) data.length);
55 | }
56 |
57 |
58 | - (void)handleStreamEnd:(NSStream *)stream
59 | {
60 | [self closeStreams];
61 | }
62 |
63 |
64 | - (void)openStreams
65 | {
66 | // streams must exist but aren't open
67 | assert(self.inputStream != nil);
68 | assert(self.outputStream != nil);
69 | assert(self.streamOpenCount == 0);
70 |
71 | self.inputStream.delegate = self;
72 | [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
73 | [self.inputStream open];
74 |
75 | self.outputStream.delegate = self;
76 | [self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
77 | [self.outputStream open];
78 | }
79 |
80 | - (void)closeStreams
81 | {
82 | // should either have both or neither
83 | assert( (self.inputStream != nil) == (self.outputStream != nil) );
84 |
85 | if (self.inputStream != nil) {
86 | [self.inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
87 | [self.inputStream close];
88 | self.inputStream = nil;
89 |
90 | [self.outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
91 | [self.outputStream close];
92 | self.outputStream = nil;
93 | }
94 | self.streamOpenCount = 0;
95 | }
96 |
97 | - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode
98 | {
99 |
100 | #pragma unused(stream)
101 |
102 | switch(eventCode) {
103 |
104 | case NSStreamEventOpenCompleted: {
105 | self.streamOpenCount += 1;
106 | assert(self.streamOpenCount <= 2);
107 |
108 | if (stream == self.inputStream) {
109 | NSLog(@"Input stream open");
110 | } else if (stream == self.outputStream) {
111 | NSLog(@"Output stream open");
112 | }
113 |
114 | if (self.streamOpenCount == 2) {
115 | // Both input and output streams are open,
116 | // Now wait for inputStream to give us the
117 | // client's request (as a NSData(NSDictionary))
118 | }
119 | } break;
120 |
121 | case NSStreamEventHasSpaceAvailable: {
122 | assert(stream == self.outputStream);
123 | NSLog(@"Output stream has space available");
124 | [self flushSendDataIfAvailable];
125 | } break;
126 |
127 | case NSStreamEventHasBytesAvailable: {
128 | if (!self.dataReadBuffer) {
129 | self.dataReadBuffer = [NSMutableData data];
130 | self.expectedReadLength = -1;
131 | }
132 |
133 | assert(stream == self.inputStream);
134 |
135 | while (self.inputStream.hasBytesAvailable) {
136 | if (self.expectedReadLength < 0) {
137 | // We haven't read anything yet, so just read the length preamble
138 | NSUInteger numPreambleBytes = sizeof(uint64_t);
139 | uint8_t buffer[numPreambleBytes];
140 | NSInteger bytesRead = [self.inputStream read:buffer maxLength:numPreambleBytes];
141 | if (bytesRead == numPreambleBytes) {
142 | uint64_t contentLength;
143 | memcpy(&contentLength, buffer, numPreambleBytes);
144 | NTOHLL(contentLength);
145 | self.expectedReadLength = contentLength;
146 | }
147 | } else {
148 | // We already know our expected size, so start or continue reading
149 |
150 | uint8_t buffer[BUFFER_SIZE];
151 |
152 | NSInteger bytesRead = [self.inputStream read:buffer maxLength:BUFFER_SIZE];
153 | if (bytesRead < 0) {
154 | NSLog(@"bytesRead: %ld", (long)bytesRead);
155 | // Handle read errors in NSStreamEventErrorOccurred
156 | } else if (bytesRead > 0) {
157 | // We received some data.
158 | NSLog(@"Received %ld bytes", (long)bytesRead);
159 | [self.dataReadBuffer appendBytes:buffer length:bytesRead];
160 | if (self.dataReadBuffer.length >= self.expectedReadLength) {
161 | NSLog(@"Finished receiving bytes");
162 | // End of buffer was reached. Do something about it?
163 | [self handleReceivedData:[self.dataReadBuffer copy]];
164 | self.dataReadBuffer = nil;
165 | self.expectedReadLength = -1;
166 | }
167 | } else {
168 | NSLog(@"Read zero bytes from input stream. The end is nigh");
169 | }
170 | }
171 | }
172 | } break;
173 |
174 | default:
175 | assert(NO);
176 | // fall through
177 | case NSStreamEventErrorOccurred:
178 | // fall through
179 | NSLog(@"NSStreamErrorOccurred (fallthrough)");
180 | case NSStreamEventEndEncountered: {
181 | // Start server again?
182 | NSLog(@"NSStreamEventEndEncountered");
183 | if (stream == self.inputStream) {
184 | NSLog(@" => Input Stream");
185 | } else if (stream == self.outputStream) {
186 | NSLog(@" => Output Stream");
187 | }
188 | [self handleStreamEnd:stream];
189 | } break;
190 | }
191 | }
192 |
193 |
194 | - (void) flushSendDataIfAvailable
195 | {
196 | if (self.dataSendBuffer.length <= 0) {
197 | return;
198 | }
199 | // Send any data in our write buffer
200 | uint8_t *readBytes = (uint8_t *) [self.dataSendBuffer mutableBytes];
201 | // Move along the byte array up to the sent index
202 | readBytes += self.sendBufferByteIndex;
203 | NSUInteger bytesToWrite = MIN(BUFFER_SIZE, self.dataSendBuffer.length - self.sendBufferByteIndex);
204 |
205 | uint8_t buffer[BUFFER_SIZE];
206 | // Copy the data we want to send over to this buffer
207 | (void)memcpy(buffer, readBytes, bytesToWrite);
208 |
209 | NSInteger bytesWritten = [self.outputStream write:buffer maxLength:bytesToWrite];
210 | if (bytesWritten < 0) {
211 | // Some error occurred, yikes. Handle write errors in NSStreamEventErrorOccurred
212 | NSLog(@"Couldn't write to output stream");
213 | } else {
214 | NSLog(@"Sent %ld bytes", (long) bytesWritten);
215 | self.sendBufferByteIndex += bytesWritten;
216 |
217 | if (self.sendBufferByteIndex == self.dataSendBuffer.length) {
218 | NSLog(@"Finished sending whole data buffer");
219 | self.dataSendBuffer = nil;
220 | self.sendBufferByteIndex = 0;
221 | }
222 | }
223 | }
224 |
225 | @end
226 |
--------------------------------------------------------------------------------
/VoucherTests/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 |
--------------------------------------------------------------------------------
/VoucherTests/VoucherTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // VoucherTests.m
3 | // VoucherTests
4 | //
5 | // Created by Rizwan Sattar on 11/7/15.
6 | // Copyright © 2015 Rizwan Sattar. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | // Things to test:
12 | // Server:
13 | // - Can publish given good name and unique id
14 | // - cannot publish with invalid name and unique id
15 | // - Can start or resume serving if/after airplane mode
16 | // Client:
17 | // - Can start browsing with good name + id
18 | // - Cannot start browing bad name and/or id
19 | // - Can start or resume browsing if/after airplane mode
20 | // -
21 | // Integration tests of both:
22 | // - Client connects to server, then disconnects after opening streams
23 | // => Server should resume serving, ready to receive connections
24 | // => Client should be able to connect to next server
25 | // - Client connects to server, client sends data, then disconnects while server is waiting for user response
26 | // - Client connects to server, server stops publishing, then resumes publishing
27 | // - Client up first;, then server comes online
28 | // - Server up first, then client comes online
29 |
30 | @interface VoucherTests : XCTestCase
31 |
32 | @end
33 |
34 | @implementation VoucherTests
35 |
36 | - (void)setUp {
37 | [super setUp];
38 | // Put setup code here. This method is called before the invocation of each test method in the class.
39 | }
40 |
41 | - (void)tearDown {
42 | // Put teardown code here. This method is called after the invocation of each test method in the class.
43 | [super tearDown];
44 | }
45 |
46 | - (void)testExample {
47 | // This is an example of a functional test case.
48 | // Use XCTAssert and related functions to verify your tests produce the correct results.
49 | }
50 |
51 | - (void)testPerformanceExample {
52 | // This is an example of a performance test case.
53 | [self measureBlock:^{
54 | // Put the code you want to measure the time of here.
55 | }];
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------