├── .DS_Store
├── SwiftTri
├── Images.xcassets
│ ├── icons
│ │ ├── menuIcon.imageset
│ │ │ ├── delta.png
│ │ │ ├── delta-1.png
│ │ │ └── Contents.json
│ │ ├── scanIcon.imageset
│ │ │ ├── scan.png
│ │ │ ├── scan-1.png
│ │ │ └── Contents.json
│ │ ├── dudeIcon.imageset
│ │ │ ├── dude_icon.png
│ │ │ └── Contents.json
│ │ └── markerIcon.imageset
│ │ │ ├── location_marker.png
│ │ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ ├── appIconIOS7@2x.png
│ │ ├── appIconIPAD@1x.png
│ │ ├── appIconIPAD@2x.png
│ │ └── Contents.json
│ ├── beacons
│ │ ├── beaconBlue.imageset
│ │ │ ├── beacon_blue.png
│ │ │ └── Contents.json
│ │ ├── beaconGreen.imageset
│ │ │ ├── beacon_teal.png
│ │ │ └── Contents.json
│ │ └── beaconPurple.imageset
│ │ │ ├── beacon_purple.png
│ │ │ └── Contents.json
│ ├── background
│ │ └── sandycay.imageset
│ │ │ ├── 03478_sandycay_640x1136@2x.png
│ │ │ └── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
├── Info.plist
├── Base.lproj
│ └── Main.storyboard
├── AppDelegate.swift
├── Utils.swift
├── GridView.swift
├── EstimoteView.swift
├── BeaconManager.swift
└── ViewController.swift
├── SwiftTri.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── LICENSE
├── .gitignore
├── SwiftTriTests
├── Info.plist
└── SwiftTriTests.swift
└── README.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/.DS_Store
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/menuIcon.imageset/delta.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/menuIcon.imageset/delta.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/scanIcon.imageset/scan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/scanIcon.imageset/scan.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/menuIcon.imageset/delta-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/menuIcon.imageset/delta-1.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/scanIcon.imageset/scan-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/scanIcon.imageset/scan-1.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIOS7@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIOS7@2x.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIPAD@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIPAD@1x.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIPAD@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/AppIcon.appiconset/appIconIPAD@2x.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/dudeIcon.imageset/dude_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/dudeIcon.imageset/dude_icon.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconBlue.imageset/beacon_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/beacons/beaconBlue.imageset/beacon_blue.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconGreen.imageset/beacon_teal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/beacons/beaconGreen.imageset/beacon_teal.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/markerIcon.imageset/location_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/icons/markerIcon.imageset/location_marker.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconPurple.imageset/beacon_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/beacons/beaconPurple.imageset/beacon_purple.png
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/background/sandycay.imageset/03478_sandycay_640x1136@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a34729t/TriangulatorSwift/HEAD/SwiftTri/Images.xcassets/background/sandycay.imageset/03478_sandycay_640x1136@2x.png
--------------------------------------------------------------------------------
/SwiftTri.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/dudeIcon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "dude_icon.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconBlue.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "beacon_blue.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconGreen.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "beacon_teal.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/beacons/beaconPurple.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "beacon_purple.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/markerIcon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "location_marker.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/background/sandycay.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "03478_sandycay_640x1136@2x.png"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/menuIcon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "delta-1.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "delta.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/icons/scanIcon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "scan.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "scan-1.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | /*
2 | * ----------------------------------------------------------------------------
3 | * "MODIFIED BEER-WARE LICENSE" (Revision 42.3154):
4 | * wrote this file. As long as you retain this notice you
5 | * can do whatever you want with this stuff.
6 | *
7 | * Also, please don't abuse the shamelessly stolen artwork too much. Give them
8 | * credit at the very least!
9 | * ----------------------------------------------------------------------------
10 | */
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
--------------------------------------------------------------------------------
/SwiftTriTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | Twitter.${PRODUCT_NAME:rfc1034identifier}
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 |
--------------------------------------------------------------------------------
/SwiftTriTests/SwiftTriTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SwiftTriTests.swift
3 | // SwiftTriTests
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class SwiftTriTests: XCTestCase {
12 |
13 | override func setUp() {
14 | super.setUp()
15 | // Put setup code here. This method is called before the invocation of each test method in the class.
16 | }
17 |
18 | override func tearDown() {
19 | // Put teardown code here. This method is called after the invocation of each test method in the class.
20 | super.tearDown()
21 | }
22 |
23 | func testExample() {
24 | // This is an example of a functional test case.
25 | XCTAssert(true, "Pass")
26 | }
27 |
28 | func testPerformanceExample() {
29 | // This is an example of a performance test case.
30 | self.measureBlock() {
31 | // Put the code you want to measure the time of here.
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "size" : "60x60",
15 | "idiom" : "iphone",
16 | "filename" : "appIconIOS7@2x.png",
17 | "scale" : "2x"
18 | },
19 | {
20 | "idiom" : "ipad",
21 | "size" : "29x29",
22 | "scale" : "1x"
23 | },
24 | {
25 | "idiom" : "ipad",
26 | "size" : "29x29",
27 | "scale" : "2x"
28 | },
29 | {
30 | "idiom" : "ipad",
31 | "size" : "40x40",
32 | "scale" : "1x"
33 | },
34 | {
35 | "idiom" : "ipad",
36 | "size" : "40x40",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "76x76",
41 | "idiom" : "ipad",
42 | "filename" : "appIconIPAD@1x.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "76x76",
47 | "idiom" : "ipad",
48 | "filename" : "appIconIPAD@2x.png",
49 | "scale" : "2x"
50 | }
51 | ],
52 | "info" : {
53 | "version" : 1,
54 | "author" : "xcode"
55 | }
56 | }
--------------------------------------------------------------------------------
/SwiftTri/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | Twitter.${PRODUCT_NAME:rfc1034identifier}
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 | NSLocationWhenInUseUsageDescription
28 | The spirit of stack overflow is coders helping coders
29 | NSLocationAlwaysUsageDescription
30 | I have learned more on stack overflow than anything else
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/SwiftTri/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/SwiftTri/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 |
--------------------------------------------------------------------------------
/SwiftTri/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> 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 |
--------------------------------------------------------------------------------
/SwiftTri/Utils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Utils.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/20/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import UIKit
11 |
12 | // Image constants
13 | let backgroundImage = UIImage(named: "sandycay")
14 | let menuIconImage = UIImage(named: "menuIcon.png")
15 | let scanIconImage = UIImage(named: "scanIcon.png")
16 | let markerImage = UIImage(named: "markerIcon.png")
17 | let beaconBlue = UIImage(named: "beaconBlue.png")
18 | let beaconGreen = UIImage(named: "beaconGreen.png")
19 | let beaconPurple = UIImage(named: "beaconPurple.png")
20 |
21 | // Icons in on/off mode
22 | let menuImgOff = filledImageFrom(image: menuIconImage!, UIColor.blackColor())
23 | let menuImgOn = filledImageFrom(image: menuIconImage!, UIColor.grayColor())
24 | let scanImgOff = filledImageFrom(image: scanIconImage!, UIColor.blackColor())
25 | let scanImgOn = filledImageFrom(image: scanIconImage!, UIColor.grayColor())
26 |
27 | // From http://stackoverflow.com/questions/845278/overlaying-a-uiimage-with-a-color?lq=1
28 | func filledImageFrom(#image:UIImage, color:UIColor) -> UIImage {
29 | // begin a new image context, to draw our colored image onto with the right scale
30 | UIGraphicsBeginImageContextWithOptions(image.size, false, UIScreen.mainScreen().scale)
31 |
32 | // get a reference to that context we created
33 | let context:CGContextRef = UIGraphicsGetCurrentContext()
34 |
35 | // set the fill color
36 | color.setFill()
37 |
38 | // translate/flip the graphics context (for transforming from CG* coords to UI* coords
39 | CGContextTranslateCTM(context, 0, image.size.height)
40 | CGContextScaleCTM(context, 1.0, -1.0)
41 |
42 | CGContextSetBlendMode(context, kCGBlendModeColorBurn)
43 | let rect:CGRect = CGRectMake(0, 0, image.size.width, image.size.height)
44 | CGContextDrawImage(context, rect, image.CGImage)
45 |
46 | CGContextSetBlendMode(context, kCGBlendModeSourceIn)
47 | CGContextAddRect(context, rect)
48 | CGContextDrawPath(context,kCGPathFill)
49 |
50 | // generate a new UIImage from the graphics context we drew onto
51 | let coloredImg:UIImage = UIGraphicsGetImageFromCurrentImageContext()
52 | UIGraphicsEndImageContext()
53 |
54 | //return the color-burned image
55 | return coloredImg
56 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Triangulator (in Swift)
2 | =====================
3 |
4 | This app demonstrates how to triangulate distance between iBeacons using CoreLocation. I wrote it for a class I teach as part of Twitter's internal training program.
5 |
6 | Triangulation is not precise because you only have 4 distances you get when ranging an iBeacon (immmediate, near, far and unknown).
7 |
8 | ## Instructions
9 |
10 | Click on the bottom-left triangle icon (it should turn gray) to configure the iBeacons you have to match their real-life location, and click again on the triangle when you are done.
11 |
12 | Next, click on the bottom-right scan icon to start scanning for iBeacons. Once iBeacons are in range, the location marker icon should appear. It's default position is offscreen (at -100, -100).
13 |
14 | ## Testing
15 |
16 | This works on an iPhone 4S running iOS 7.1, with Estimote iBeacons.
17 |
18 | ## Troubleshooting
19 |
20 | If the app doesn't working, you may need to restart your iOS device. I've noticed with any BLE/iBeacon stuff that seems to be the only thing that works. And then it's all fine until the next time!
21 |
22 | ## CoreLocation vs CoreBluetooth
23 |
24 | I am using CoreLocation, which is the only accepted way of interating with iBeacons. CoreBluetooth doesn't give you the background capabilities needed in a distance-aware app.
25 |
26 | CoreLocation gives you iBeacon class (proximity UUID), major and minor (think of them as ways to give an iBeacon a unique ID). CoreBluetooth gives you only a deviceUUID. In fact, the information available to CoreLocation and CoreBluetooth is mutually exclusive- they handle the iBeacon advertisements differently.
27 |
28 | ## Notes
29 |
30 | * The app is hardcoded to use 3 iBeacons. The triangulation code could handle more of them, but the iBeacon setup would need to be modified to support this.
31 | * The triangulation code doesn't handle the 0 < n < 3 signal case. When there are only one or two iBeacons present, we should do something different with the UI. The same goes for 0 iBeacons.
32 | * To make CoreLocation work in iOS 8, you need to add stuff to the plist! See: http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working
33 |
34 | ## Shamelessly Stolen Artwork
35 |
36 | * Estimote iBeacons: From http://www.uidesignbyadam.com/blog/
37 | * Wallpaper: Interfacelift (Sandy Cay is the current background)
38 |
39 | ## Credits
40 |
41 | * People who's artwork I stole (see above)
42 | * Coworkers at Twitter who made helpful suggestions to my coding style
43 |
--------------------------------------------------------------------------------
/SwiftTri/GridView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GridView.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 | // More or less converted from Objective-C code.
9 | // From http://stackoverflow.com/questions/18226496/how-to-draw-grid-lines-when-camera-is-open-avcapturemanager
10 | //
11 |
12 | import UIKit
13 |
14 | class GridView: UIView {
15 | let gridWidth: CGFloat = 0.5
16 | var columns: Int
17 |
18 | init(frame: CGRect, columns: Int) {
19 | // Set size of grid
20 | self.columns = columns - 1
21 | super.init(frame: frame)
22 |
23 | // Set view to be transparent
24 | self.opaque = false;
25 | self.backgroundColor = UIColor(white: 0.0, alpha: 0.0);
26 | }
27 |
28 | required init(coder aDecoder: NSCoder) {
29 | fatalError("init(coder:) has not been implemented")
30 | }
31 |
32 | override func drawRect(rect: CGRect) {
33 | let context: CGContextRef = UIGraphicsGetCurrentContext()
34 | CGContextSetLineWidth(context, gridWidth)
35 | CGContextSetStrokeColorWithColor(context, UIColor.blackColor().CGColor)
36 |
37 | // Calculate basic dimensions
38 | let columnWidth: CGFloat = self.frame.size.width / (CGFloat(self.columns) + 1.0)
39 | let rowHeight: CGFloat = columnWidth;
40 | let numberOfRows: Int = Int(self.frame.size.height)/Int(rowHeight);
41 |
42 | // ---------------------------
43 | // Drawing column lines
44 | // ---------------------------
45 | for i in 1...self.columns {
46 | var startPoint: CGPoint = CGPoint(x: columnWidth * CGFloat(i), y: 0.0)
47 | var endPoint: CGPoint = CGPoint(x: startPoint.x, y: self.frame.size.height)
48 |
49 | CGContextMoveToPoint(context, startPoint.x, startPoint.y);
50 | CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
51 | CGContextStrokePath(context);
52 | }
53 |
54 | // ---------------------------
55 | // Drawing row lines
56 | // ---------------------------
57 | for j in 1...numberOfRows {
58 | var startPoint: CGPoint = CGPoint(x: 0.0, y: rowHeight * CGFloat(j))
59 | var endPoint: CGPoint = CGPoint(x: self.frame.size.width, y: startPoint.y)
60 |
61 | CGContextMoveToPoint(context, startPoint.x, startPoint.y);
62 | CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
63 | CGContextStrokePath(context);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/SwiftTri/EstimoteView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // EstimoteView.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | import CoreLocation
10 | import UIKit
11 |
12 | class EstimoteView: UIView, UIGestureRecognizerDelegate {
13 |
14 | var major, minor: String
15 | var step: CGFloat
16 | var proximity: CLProximity
17 | var coordinateLabel: UILabel
18 | var lastLocation: CGPoint
19 |
20 | init(frame: CGRect, image: UIImage, step: CGFloat, major: String, minor: String) {
21 | // Initialize stuff
22 | self.major = major
23 | self.minor = minor
24 | self.step = step
25 | self.proximity = CLProximity.Unknown
26 | self.coordinateLabel = UILabel(frame: frame)
27 | self.lastLocation = CGPoint()
28 |
29 | super.init(frame: frame)
30 |
31 | // Gesture recognizer
32 | let panRecognizer: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: "detectPan:")
33 | self.gestureRecognizers = [panRecognizer]
34 |
35 | // Estimote image
36 | let imageView: UIImageView = UIImageView(frame: CGRect(origin: CGPoint(x: 0,y: 0), size: self.frame.size))
37 | imageView.image = image
38 | imageView.contentMode = UIViewContentMode.ScaleAspectFit
39 | self.addSubview(imageView)
40 |
41 | // Label for coordinates
42 | self.coordinateLabel.textAlignment = NSTextAlignment.Center
43 | self.coordinateLabel.center = CGPointMake(self.frame.width/2, self.frame.height/2)
44 | self.setCoordinates(self.center)
45 | self.addSubview(self.coordinateLabel)
46 | }
47 |
48 | required init(coder aDecoder: NSCoder) {
49 | fatalError("init(coder:) has not been implemented")
50 | }
51 |
52 | func setCoordinates(point: CGPoint) {
53 | let x: Int = Int(point.x/self.step)
54 | let y: Int = Int(point.y/self.step)
55 | self.coordinateLabel.text = "(\(x),\(x))"
56 | }
57 |
58 | func detectPan(uiPanGestureRecognizer: UIPanGestureRecognizer) {
59 | // Remember the original position
60 | if(uiPanGestureRecognizer.state == UIGestureRecognizerState.Began) {
61 | self.lastLocation = self.center
62 | }
63 |
64 | // Handle panning and end (snap to grid)
65 | if(uiPanGestureRecognizer.state != UIGestureRecognizerState.Ended) {
66 | // Keep on panning
67 | let translation = uiPanGestureRecognizer.translationInView(self.superview!)
68 | self.center = CGPoint(x: self.lastLocation.x + translation.x, y: self.lastLocation.y + translation.y)
69 | self.setCoordinates(self.center)
70 | } else {
71 | // Snap to grid
72 | var newCenter: CGPoint = self.center
73 | newCenter.x = self.step * CGFloat(floor(Double(newCenter.x / self.step) + 0.5))
74 | newCenter.y = self.step * CGFloat(floor(Double(newCenter.y / self.step) + 0.5))
75 |
76 | UIView.animateWithDuration(0.1,
77 | delay: 0.0,
78 | options: UIViewAnimationOptions.CurveEaseInOut,
79 | animations:{ self.center = newCenter}, completion: nil)
80 |
81 | self.center = newCenter
82 | self.setCoordinates(self.center)
83 |
84 | println("endPan (\(newCenter.x),\(newCenter.y))")
85 | }
86 | }
87 |
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/SwiftTri/BeaconManager.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BeaconManager.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | import CoreLocation
10 | import UIKit
11 |
12 | // General search criteria for beacons that are broadcasting
13 | let BEACON_SERVICE_NAME = "estimote"
14 | let BEACON_PROXIMITY_UUID = NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")
15 |
16 | // Beacons are hardcoded into our app so we can easily filter for them in a noisy environment
17 | let BEACON_PURPLE_MAJOR = "60463"
18 | let BEACON_PURPLE_MINOR = "56367"
19 | let BEACON_GREEN_MAJOR = "544"
20 | let BEACON_GREEN_MINOR = "50962"
21 | let BEACON_BLUE_MAJOR = "23680"
22 | let BEACON_BLUE_MINOR = "7349"
23 |
24 | protocol BeaconManagerDelegate {
25 | func discoveredBeacon(#major: String, minor: String, proximity: CLProximity) // NOTE: #major forces first parameter to be named in function call
26 | }
27 |
28 | class BeaconManager: NSObject, CLLocationManagerDelegate {
29 | var locationManager: CLLocationManager = CLLocationManager()
30 | let registeredBeaconMajor: [String] = [BEACON_BLUE_MAJOR, BEACON_GREEN_MAJOR, BEACON_PURPLE_MAJOR]
31 | let estimoteRegion: CLBeaconRegion = CLBeaconRegion(proximityUUID:BEACON_PROXIMITY_UUID, identifier:"Estimote Region")
32 | var delegate: BeaconManagerDelegate?
33 |
34 | class var sharedInstance:BeaconManager {
35 | return sharedBeaconManager
36 | }
37 |
38 | override init() {
39 | super.init()
40 | locationManager.delegate = self
41 | }
42 |
43 | func start() {
44 | println("BM start");
45 | locationManager.startMonitoringForRegion(estimoteRegion)
46 | }
47 |
48 | func stop() {
49 | println("BM stop");
50 | locationManager.stopMonitoringForRegion(estimoteRegion)
51 | }
52 |
53 | // CLLocationManagerDelegate methods
54 |
55 | func locationManager(manager: CLLocationManager!, didStartMonitoringForRegion region: CLRegion!) {
56 | println("BM didStartMonitoringForRegion");
57 | locationManager.requestStateForRegion(region); // should locationManager be manager?
58 | }
59 |
60 | func locationManager(manager: CLLocationManager!, didDetermineState state: CLRegionState, forRegion region: CLRegion!) {
61 | println("BM didDetermineState \(state)");
62 |
63 | switch state {
64 | case .Inside:
65 | println("BeaconManager:didDetermineState CLRegionState.Inside");
66 | locationManager.startRangingBeaconsInRegion(estimoteRegion) // should locationManager be manager?
67 | case .Outside:
68 | println("BeaconManager:didDetermineState CLRegionState.Outside");
69 | case .Unknown:
70 | println("BeaconManager:didDetermineState CLRegionState.Unknown");
71 | default:
72 | println("BeaconManager:didDetermineState default");
73 | }
74 | }
75 |
76 | func locationManager(manager: CLLocationManager!,
77 | didRangeBeacons beacons: [AnyObject]!,
78 | inRegion region: CLBeaconRegion!) {
79 | println("BM didRangeBeacons");
80 |
81 | for beacon: CLBeacon in beacons as! [CLBeacon] {
82 | // TODO: better way to unwrap optionals?
83 | if let major: String = beacon.major?.stringValue {
84 | if let minor: String = beacon.minor?.stringValue {
85 | let contained: Bool = contains(registeredBeaconMajor, major)
86 | let active: Bool = (UIApplication.sharedApplication().applicationState == UIApplicationState.Active)
87 | if contained && active {
88 | delegate?.discoveredBeacon(major: major, minor: minor, proximity: beacon.proximity)
89 | }
90 | }
91 | }
92 | }
93 | }
94 | }
95 |
96 |
97 | let sharedBeaconManager = BeaconManager()
--------------------------------------------------------------------------------
/SwiftTri/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // SwiftTri
4 | //
5 | // Created by Nicolas Flacco on 6/18/14.
6 | // Copyright (c) 2014 Nicolas Flacco. All rights reserved.
7 | //
8 |
9 | // WARNING: Cannot use Images.xcassets with Swift on iOS 7 with XCode Beta 1 (Beta 2 works). As a workaround,
10 | // use absolute path as shown here: http://stackoverflow.com/questions/24069479/swift-playgrounds-with-uiimage
11 | // Naturally, this is a shitshow cause it won't work on an iOS 7 device cause it needs Images.xcassets.
12 |
13 | // TODO: This should really all be autolayout-ed
14 |
15 | import CoreLocation
16 | import UIKit
17 |
18 | class ViewController: UIViewController, BeaconManagerDelegate {
19 | // global config?
20 | let numberColumns: Int = 10
21 |
22 | // general properties
23 | var beaconManager: BeaconManager?
24 | var editMode: Bool = false
25 | var scanMode: Bool = false
26 |
27 | // iBeacons
28 | var blueEstimote, greenEstimote, purpleEstimote: EstimoteView!
29 | var iBeacons: [EstimoteView] = []
30 |
31 | // UI
32 | var gridView: GridView?
33 | var markerView: UIImageView?
34 | var menuButton, scanButton: UIButton?
35 |
36 | override func viewDidLoad() {
37 | super.viewDidLoad()
38 | // Do any additional setup after loading the view, typically from a nib.
39 |
40 | self.beaconManager = sharedBeaconManager
41 | if !CLLocationManager.locationServicesEnabled() {
42 | // TODO: Alert, once alerts work without crashing app
43 | }
44 |
45 | // Set background image
46 | let backgroundImageView: UIImageView = UIImageView(image: backgroundImage)
47 | self.view.addSubview(backgroundImageView)
48 |
49 | // Draw grid
50 | let gridView: GridView = GridView(frame: self.view.frame, columns: numberColumns)
51 | gridView.alpha = 0.25;
52 | self.view.addSubview(gridView);
53 | self.gridView = gridView // This seems really awkward
54 |
55 | // Create iBeacons
56 | let width: CGFloat = self.view.frame.size.width;
57 | let height: CGFloat = self.view.frame.size.height;
58 | let point0: CGPoint = CGPointMake(width/3, height/1.5);
59 | let point1: CGPoint = CGPointMake(width/6, height/8);
60 | let point2: CGPoint = CGPointMake(width/1.5, height/3);
61 |
62 | self.blueEstimote = self.createBeaconView(image: beaconBlue!,
63 | coordinates:point0,
64 | major:BEACON_BLUE_MAJOR,
65 | minor:BEACON_BLUE_MINOR);
66 | self.greenEstimote = self.createBeaconView(image: beaconGreen!,
67 | coordinates:point1,
68 | major:BEACON_GREEN_MAJOR,
69 | minor:BEACON_GREEN_MINOR);
70 | self.purpleEstimote = self.createBeaconView(image: beaconPurple!,
71 | coordinates:point2,
72 | major:BEACON_BLUE_MAJOR,
73 | minor:BEACON_BLUE_MINOR);
74 |
75 | self.iBeacons = [self.blueEstimote, self.greenEstimote, self.purpleEstimote];
76 | for estimote: EstimoteView in self.iBeacons {
77 | // NOTE: These settings don't seem to work when set in view initializer
78 | estimote.userInteractionEnabled = false
79 | estimote.coordinateLabel.hidden = true
80 | self.view.addSubview(estimote)
81 | }
82 |
83 | // Make menu button (delta)
84 | let menuButton: UIButton = self.makeMenuButton(image: menuImgOff, left:true)
85 | menuButton.addTarget(self, action: "menuButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
86 | self.view.addSubview(menuButton)
87 | self.menuButton = menuButton
88 |
89 | // Make scan button (antenna)
90 | let scanButton: UIButton = self.makeMenuButton(image: scanImgOff, left:false)
91 | scanButton.addTarget(self, action: "scanButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
92 | self.view.addSubview(scanButton)
93 | self.scanButton = scanButton
94 |
95 | // Make location marker
96 | let markerView:UIImageView = UIImageView(image: markerImage)
97 | let marker:CGPoint = self.updateLocationMarker()
98 | markerView.frame = CGRect(x: marker.x, y: marker.y - (133/6), width: 150/3, height: 133/3)
99 | self.view.addSubview(markerView)
100 | self.markerView = markerView
101 |
102 | // TODO: Check if bluetooth is on/off
103 | }
104 |
105 | // BeaconManager Delegate Methods
106 |
107 | func discoveredBeacon(#major: String, minor: String, proximity: CLProximity) {
108 | println("VC major:\(major) minor:\(minor) distance:\(proximity)");
109 |
110 | // Update estimote ranges
111 | for estimote:EstimoteView in self.iBeacons {
112 | if estimote.major == major && estimote.minor == minor {
113 | estimote.proximity = proximity
114 | }
115 | }
116 |
117 | // Update location marker position
118 | let marker:CGPoint = self.updateLocationMarker()
119 | self.markerView!.frame = CGRect(x: marker.x, y: marker.y - (133/6), width: 150/3, height: 133/3)
120 | }
121 |
122 | // Marker Helpers
123 |
124 | func updateLocationMarker() -> CGPoint {
125 |
126 | // Handle unknown case (no iBeacons in range) -> Move marker offscreen
127 | // TODO: Turn this into a map function?
128 | var num:Int = 0
129 | for estimote in self.iBeacons {
130 | if (estimote.proximity == CLProximity.Unknown) {
131 | num++
132 | }
133 | }
134 | if num == self.iBeacons.count {
135 | return CGPoint(x: -100.0,y: -100.0) // Off screen
136 | }
137 |
138 | // TODO:
139 | // 1 ... N-1 unknown case?
140 | // If marker would be offscreen, find the nearest point within 50 px of border?
141 |
142 | // All known case:
143 | // We want to weight nearer iBeacons more than further ones. We simply create an array of
144 | // x-coordinates, and the nearer an iBeacon is, the more times we add it to the array, so
145 | // that the average value is influenced more!
146 |
147 | // HACK ALERT: I use two arrays as hack cause otherwise I'd do NSValue (for lack of tuple) cause arrays cannot take primitives
148 | // TODO: Use map/zip/etc.
149 | var xTotal:Int = 0;
150 | var yTotal:Int = 0;
151 | var xCount:Int = 0;
152 | var yCount:Int = 0;
153 | for estimote:EstimoteView in self.iBeacons {
154 | for i:Int in 0...CLProximity2Int(estimote.proximity) {
155 | xTotal += Int(estimote.center.x)
156 | yTotal += Int(estimote.center.y)
157 | xCount++
158 | yCount++
159 | }
160 | }
161 |
162 | return CGPoint(x: xTotal/xCount, y: yTotal/yCount)
163 | }
164 |
165 | func CLProximity2Int(proximity:CLProximity) -> Int {
166 | switch proximity {
167 | case .Unknown:
168 | return 0;
169 | case .Far:
170 | return 1;
171 | case .Near:
172 | return 5;
173 | case .Immediate:
174 | return 20;
175 | default:
176 | return 0; // Also handles .Unknown case
177 | }
178 | }
179 |
180 | // Button Delegates
181 |
182 | func menuButtonClicked(sender: UIButton!) {
183 | println("menuButtonClicked")
184 |
185 | // Toggle edit mode
186 | self.editMode = !self.editMode
187 |
188 | // Change 1) color of button 2) grid transparency (alpha)
189 | if self.editMode {
190 | self.menuButton!.setImage(menuImgOn, forState: UIControlState.Normal)
191 | self.gridView!.alpha = 0.6
192 | } else {
193 | self.menuButton!.setImage(menuImgOff, forState: UIControlState.Normal)
194 | self.gridView!.alpha = 0.25
195 | }
196 |
197 | // Toggle estimotes draggable or not
198 | for estimote:EstimoteView in self.iBeacons {
199 | estimote.userInteractionEnabled = !estimote.userInteractionEnabled
200 | estimote.coordinateLabel.hidden = !estimote.coordinateLabel.hidden
201 | }
202 | }
203 |
204 |
205 | func scanButtonClicked(sender: UIButton!) {
206 | println("scanButtonClicked")
207 |
208 | // Change 1) color of button 2) enable/disable beacon manager
209 | if self.scanMode {
210 | self.scanButton!.setImage(scanImgOff, forState: UIControlState.Normal)
211 | self.beaconManager!.stop()
212 | self.beaconManager!.delegate = nil
213 | } else {
214 | self.scanButton!.setImage(scanImgOn, forState: UIControlState.Normal)
215 | self.beaconManager!.start()
216 | self.beaconManager!.delegate = self
217 | }
218 |
219 | // Toggle scan mode
220 | self.scanMode = !self.scanMode
221 | }
222 |
223 | // View Helpers
224 |
225 | func createBeaconView(#image: UIImage, coordinates: CGPoint, major: String, minor:String) -> EstimoteView {
226 | let scaleFactor: Double = 3.0
227 | let step: CGFloat = CGFloat(self.view.frame.size.width) / CGFloat(self.numberColumns)
228 | let rect: CGRect = CGRectMake(coordinates.x, coordinates.y, CGFloat(200.0/scaleFactor), CGFloat(340.0/scaleFactor))
229 | let beaconView: EstimoteView = EstimoteView(frame: rect, image: image, step: step, major: major, minor: minor)
230 | return beaconView
231 | }
232 |
233 | func makeMenuButton(#image: UIImage, left: Bool) -> UIButton {
234 | let menuWidth: CGFloat = 150/3;
235 | let menuHeight: CGFloat = 133/3;
236 | let menuPadding: CGFloat = 10;
237 |
238 | let button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
239 | if (left) {
240 | button.frame = CGRectMake( menuPadding , self.view.frame.size.height - menuHeight - menuPadding, menuWidth, menuHeight);
241 | } else {
242 | button.frame = CGRectMake(self.view.frame.size.width - menuWidth - menuPadding , self.view.frame.size.height - menuHeight - menuPadding, menuWidth, menuHeight);
243 | }
244 | button.setImage(image, forState: UIControlState.Normal)
245 |
246 | return button;
247 |
248 | }
249 |
250 |
251 | override func didReceiveMemoryWarning() {
252 | super.didReceiveMemoryWarning()
253 | // Dispose of any resources that can be recreated.
254 | }
255 |
256 |
257 | }
258 |
259 |
--------------------------------------------------------------------------------
/SwiftTri.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 260F527B1952776E00092D38 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 260F527A1952776E00092D38 /* README.md */; };
11 | 262736DE1954C4FB00C1BB68 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 262736DD1954C4FB00C1BB68 /* Utils.swift */; };
12 | 2665B29A19525E9E0009BF2F /* EstimoteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2665B29919525E9E0009BF2F /* EstimoteView.swift */; };
13 | 2665B29C19525EC70009BF2F /* GridView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2665B29B19525EC70009BF2F /* GridView.swift */; };
14 | 26B5BFBE195936F500260B49 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 26B5BFBD195936F500260B49 /* LICENSE */; };
15 | 26B692B619521BDE0024F43B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B692B519521BDE0024F43B /* AppDelegate.swift */; };
16 | 26B692B819521BDE0024F43B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B692B719521BDE0024F43B /* ViewController.swift */; };
17 | 26B692BB19521BDE0024F43B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 26B692B919521BDE0024F43B /* Main.storyboard */; };
18 | 26B692BD19521BDE0024F43B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 26B692BC19521BDE0024F43B /* Images.xcassets */; };
19 | 26B692C919521BDE0024F43B /* SwiftTriTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B692C819521BDE0024F43B /* SwiftTriTests.swift */; };
20 | 26B692D7195220800024F43B /* BeaconManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B692D6195220800024F43B /* BeaconManager.swift */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXContainerItemProxy section */
24 | 26B692C319521BDE0024F43B /* PBXContainerItemProxy */ = {
25 | isa = PBXContainerItemProxy;
26 | containerPortal = 26B692A819521BDE0024F43B /* Project object */;
27 | proxyType = 1;
28 | remoteGlobalIDString = 26B692AF19521BDE0024F43B;
29 | remoteInfo = SwiftTri;
30 | };
31 | /* End PBXContainerItemProxy section */
32 |
33 | /* Begin PBXFileReference section */
34 | 260F527A1952776E00092D38 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; };
35 | 262736DD1954C4FB00C1BB68 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; };
36 | 2665B29919525E9E0009BF2F /* EstimoteView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EstimoteView.swift; sourceTree = ""; };
37 | 2665B29B19525EC70009BF2F /* GridView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GridView.swift; sourceTree = ""; };
38 | 26B5BFBD195936F500260B49 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; };
39 | 26B692B019521BDE0024F43B /* SwiftTri.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftTri.app; sourceTree = BUILT_PRODUCTS_DIR; };
40 | 26B692B419521BDE0024F43B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
41 | 26B692B519521BDE0024F43B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
42 | 26B692B719521BDE0024F43B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
43 | 26B692BA19521BDE0024F43B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
44 | 26B692BC19521BDE0024F43B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
45 | 26B692C219521BDE0024F43B /* SwiftTriTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftTriTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
46 | 26B692C719521BDE0024F43B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
47 | 26B692C819521BDE0024F43B /* SwiftTriTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTriTests.swift; sourceTree = ""; };
48 | 26B692D6195220800024F43B /* BeaconManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BeaconManager.swift; sourceTree = ""; };
49 | /* End PBXFileReference section */
50 |
51 | /* Begin PBXFrameworksBuildPhase section */
52 | 26B692AD19521BDE0024F43B /* Frameworks */ = {
53 | isa = PBXFrameworksBuildPhase;
54 | buildActionMask = 2147483647;
55 | files = (
56 | );
57 | runOnlyForDeploymentPostprocessing = 0;
58 | };
59 | 26B692BF19521BDE0024F43B /* Frameworks */ = {
60 | isa = PBXFrameworksBuildPhase;
61 | buildActionMask = 2147483647;
62 | files = (
63 | );
64 | runOnlyForDeploymentPostprocessing = 0;
65 | };
66 | /* End PBXFrameworksBuildPhase section */
67 |
68 | /* Begin PBXGroup section */
69 | 26B692A719521BDE0024F43B = {
70 | isa = PBXGroup;
71 | children = (
72 | 26B5BFBD195936F500260B49 /* LICENSE */,
73 | 260F527A1952776E00092D38 /* README.md */,
74 | 26B692B219521BDE0024F43B /* SwiftTri */,
75 | 26B692C519521BDE0024F43B /* SwiftTriTests */,
76 | 26B692B119521BDE0024F43B /* Products */,
77 | );
78 | sourceTree = "";
79 | };
80 | 26B692B119521BDE0024F43B /* Products */ = {
81 | isa = PBXGroup;
82 | children = (
83 | 26B692B019521BDE0024F43B /* SwiftTri.app */,
84 | 26B692C219521BDE0024F43B /* SwiftTriTests.xctest */,
85 | );
86 | name = Products;
87 | sourceTree = "";
88 | };
89 | 26B692B219521BDE0024F43B /* SwiftTri */ = {
90 | isa = PBXGroup;
91 | children = (
92 | 26B692D219521F4D0024F43B /* UI */,
93 | 26B692D319521F550024F43B /* iBeacon */,
94 | 26B692B319521BDE0024F43B /* Supporting Files */,
95 | );
96 | path = SwiftTri;
97 | sourceTree = "";
98 | };
99 | 26B692B319521BDE0024F43B /* Supporting Files */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 26B692B519521BDE0024F43B /* AppDelegate.swift */,
103 | 26B692BC19521BDE0024F43B /* Images.xcassets */,
104 | 26B692B419521BDE0024F43B /* Info.plist */,
105 | );
106 | name = "Supporting Files";
107 | sourceTree = "";
108 | };
109 | 26B692C519521BDE0024F43B /* SwiftTriTests */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 26B692C819521BDE0024F43B /* SwiftTriTests.swift */,
113 | 26B692C619521BDE0024F43B /* Supporting Files */,
114 | );
115 | path = SwiftTriTests;
116 | sourceTree = "";
117 | };
118 | 26B692C619521BDE0024F43B /* Supporting Files */ = {
119 | isa = PBXGroup;
120 | children = (
121 | 26B692C719521BDE0024F43B /* Info.plist */,
122 | );
123 | name = "Supporting Files";
124 | sourceTree = "";
125 | };
126 | 26B692D219521F4D0024F43B /* UI */ = {
127 | isa = PBXGroup;
128 | children = (
129 | 26B692B919521BDE0024F43B /* Main.storyboard */,
130 | 26B692B719521BDE0024F43B /* ViewController.swift */,
131 | 2665B29919525E9E0009BF2F /* EstimoteView.swift */,
132 | 2665B29B19525EC70009BF2F /* GridView.swift */,
133 | 262736DD1954C4FB00C1BB68 /* Utils.swift */,
134 | );
135 | name = UI;
136 | sourceTree = "";
137 | };
138 | 26B692D319521F550024F43B /* iBeacon */ = {
139 | isa = PBXGroup;
140 | children = (
141 | 26B692D6195220800024F43B /* BeaconManager.swift */,
142 | );
143 | name = iBeacon;
144 | sourceTree = "";
145 | };
146 | /* End PBXGroup section */
147 |
148 | /* Begin PBXNativeTarget section */
149 | 26B692AF19521BDE0024F43B /* SwiftTri */ = {
150 | isa = PBXNativeTarget;
151 | buildConfigurationList = 26B692CC19521BDE0024F43B /* Build configuration list for PBXNativeTarget "SwiftTri" */;
152 | buildPhases = (
153 | 26B692AC19521BDE0024F43B /* Sources */,
154 | 26B692AD19521BDE0024F43B /* Frameworks */,
155 | 26B692AE19521BDE0024F43B /* Resources */,
156 | );
157 | buildRules = (
158 | );
159 | dependencies = (
160 | );
161 | name = SwiftTri;
162 | productName = SwiftTri;
163 | productReference = 26B692B019521BDE0024F43B /* SwiftTri.app */;
164 | productType = "com.apple.product-type.application";
165 | };
166 | 26B692C119521BDE0024F43B /* SwiftTriTests */ = {
167 | isa = PBXNativeTarget;
168 | buildConfigurationList = 26B692CF19521BDE0024F43B /* Build configuration list for PBXNativeTarget "SwiftTriTests" */;
169 | buildPhases = (
170 | 26B692BE19521BDE0024F43B /* Sources */,
171 | 26B692BF19521BDE0024F43B /* Frameworks */,
172 | 26B692C019521BDE0024F43B /* Resources */,
173 | );
174 | buildRules = (
175 | );
176 | dependencies = (
177 | 26B692C419521BDE0024F43B /* PBXTargetDependency */,
178 | );
179 | name = SwiftTriTests;
180 | productName = SwiftTriTests;
181 | productReference = 26B692C219521BDE0024F43B /* SwiftTriTests.xctest */;
182 | productType = "com.apple.product-type.bundle.unit-test";
183 | };
184 | /* End PBXNativeTarget section */
185 |
186 | /* Begin PBXProject section */
187 | 26B692A819521BDE0024F43B /* Project object */ = {
188 | isa = PBXProject;
189 | attributes = {
190 | LastUpgradeCheck = 0600;
191 | ORGANIZATIONNAME = "Nicolas Flacco";
192 | TargetAttributes = {
193 | 26B692AF19521BDE0024F43B = {
194 | CreatedOnToolsVersion = 6.0;
195 | };
196 | 26B692C119521BDE0024F43B = {
197 | CreatedOnToolsVersion = 6.0;
198 | TestTargetID = 26B692AF19521BDE0024F43B;
199 | };
200 | };
201 | };
202 | buildConfigurationList = 26B692AB19521BDE0024F43B /* Build configuration list for PBXProject "SwiftTri" */;
203 | compatibilityVersion = "Xcode 3.2";
204 | developmentRegion = English;
205 | hasScannedForEncodings = 0;
206 | knownRegions = (
207 | en,
208 | Base,
209 | );
210 | mainGroup = 26B692A719521BDE0024F43B;
211 | productRefGroup = 26B692B119521BDE0024F43B /* Products */;
212 | projectDirPath = "";
213 | projectRoot = "";
214 | targets = (
215 | 26B692AF19521BDE0024F43B /* SwiftTri */,
216 | 26B692C119521BDE0024F43B /* SwiftTriTests */,
217 | );
218 | };
219 | /* End PBXProject section */
220 |
221 | /* Begin PBXResourcesBuildPhase section */
222 | 26B692AE19521BDE0024F43B /* Resources */ = {
223 | isa = PBXResourcesBuildPhase;
224 | buildActionMask = 2147483647;
225 | files = (
226 | 26B5BFBE195936F500260B49 /* LICENSE in Resources */,
227 | 26B692BB19521BDE0024F43B /* Main.storyboard in Resources */,
228 | 26B692BD19521BDE0024F43B /* Images.xcassets in Resources */,
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | 26B692C019521BDE0024F43B /* Resources */ = {
233 | isa = PBXResourcesBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | );
237 | runOnlyForDeploymentPostprocessing = 0;
238 | };
239 | /* End PBXResourcesBuildPhase section */
240 |
241 | /* Begin PBXSourcesBuildPhase section */
242 | 26B692AC19521BDE0024F43B /* Sources */ = {
243 | isa = PBXSourcesBuildPhase;
244 | buildActionMask = 2147483647;
245 | files = (
246 | 2665B29A19525E9E0009BF2F /* EstimoteView.swift in Sources */,
247 | 26B692B819521BDE0024F43B /* ViewController.swift in Sources */,
248 | 26B692D7195220800024F43B /* BeaconManager.swift in Sources */,
249 | 260F527B1952776E00092D38 /* README.md in Sources */,
250 | 26B692B619521BDE0024F43B /* AppDelegate.swift in Sources */,
251 | 2665B29C19525EC70009BF2F /* GridView.swift in Sources */,
252 | 262736DE1954C4FB00C1BB68 /* Utils.swift in Sources */,
253 | );
254 | runOnlyForDeploymentPostprocessing = 0;
255 | };
256 | 26B692BE19521BDE0024F43B /* Sources */ = {
257 | isa = PBXSourcesBuildPhase;
258 | buildActionMask = 2147483647;
259 | files = (
260 | 26B692C919521BDE0024F43B /* SwiftTriTests.swift in Sources */,
261 | );
262 | runOnlyForDeploymentPostprocessing = 0;
263 | };
264 | /* End PBXSourcesBuildPhase section */
265 |
266 | /* Begin PBXTargetDependency section */
267 | 26B692C419521BDE0024F43B /* PBXTargetDependency */ = {
268 | isa = PBXTargetDependency;
269 | target = 26B692AF19521BDE0024F43B /* SwiftTri */;
270 | targetProxy = 26B692C319521BDE0024F43B /* PBXContainerItemProxy */;
271 | };
272 | /* End PBXTargetDependency section */
273 |
274 | /* Begin PBXVariantGroup section */
275 | 26B692B919521BDE0024F43B /* Main.storyboard */ = {
276 | isa = PBXVariantGroup;
277 | children = (
278 | 26B692BA19521BDE0024F43B /* Base */,
279 | );
280 | name = Main.storyboard;
281 | sourceTree = "";
282 | };
283 | /* End PBXVariantGroup section */
284 |
285 | /* Begin XCBuildConfiguration section */
286 | 26B692CA19521BDE0024F43B /* Debug */ = {
287 | isa = XCBuildConfiguration;
288 | buildSettings = {
289 | ALWAYS_SEARCH_USER_PATHS = NO;
290 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
291 | CLANG_CXX_LIBRARY = "libc++";
292 | CLANG_ENABLE_MODULES = YES;
293 | CLANG_ENABLE_OBJC_ARC = YES;
294 | CLANG_WARN_BOOL_CONVERSION = YES;
295 | CLANG_WARN_CONSTANT_CONVERSION = YES;
296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
297 | CLANG_WARN_EMPTY_BODY = YES;
298 | CLANG_WARN_ENUM_CONVERSION = YES;
299 | CLANG_WARN_INT_CONVERSION = YES;
300 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
301 | CLANG_WARN_UNREACHABLE_CODE = YES;
302 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
303 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
304 | COPY_PHASE_STRIP = NO;
305 | ENABLE_STRICT_OBJC_MSGSEND = YES;
306 | GCC_C_LANGUAGE_STANDARD = gnu99;
307 | GCC_DYNAMIC_NO_PIC = NO;
308 | GCC_OPTIMIZATION_LEVEL = 0;
309 | GCC_PREPROCESSOR_DEFINITIONS = (
310 | "DEBUG=1",
311 | "$(inherited)",
312 | );
313 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
316 | GCC_WARN_UNDECLARED_SELECTOR = YES;
317 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
318 | GCC_WARN_UNUSED_FUNCTION = YES;
319 | GCC_WARN_UNUSED_VARIABLE = YES;
320 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
321 | METAL_ENABLE_DEBUG_INFO = YES;
322 | ONLY_ACTIVE_ARCH = YES;
323 | SDKROOT = iphoneos;
324 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
325 | TARGETED_DEVICE_FAMILY = "1,2";
326 | };
327 | name = Debug;
328 | };
329 | 26B692CB19521BDE0024F43B /* Release */ = {
330 | isa = XCBuildConfiguration;
331 | buildSettings = {
332 | ALWAYS_SEARCH_USER_PATHS = NO;
333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
334 | CLANG_CXX_LIBRARY = "libc++";
335 | CLANG_ENABLE_MODULES = YES;
336 | CLANG_ENABLE_OBJC_ARC = YES;
337 | CLANG_WARN_BOOL_CONVERSION = YES;
338 | CLANG_WARN_CONSTANT_CONVERSION = YES;
339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
340 | CLANG_WARN_EMPTY_BODY = YES;
341 | CLANG_WARN_ENUM_CONVERSION = YES;
342 | CLANG_WARN_INT_CONVERSION = YES;
343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
344 | CLANG_WARN_UNREACHABLE_CODE = YES;
345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
346 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
347 | COPY_PHASE_STRIP = YES;
348 | ENABLE_NS_ASSERTIONS = NO;
349 | ENABLE_STRICT_OBJC_MSGSEND = YES;
350 | GCC_C_LANGUAGE_STANDARD = gnu99;
351 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
352 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
353 | GCC_WARN_UNDECLARED_SELECTOR = YES;
354 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
355 | GCC_WARN_UNUSED_FUNCTION = YES;
356 | GCC_WARN_UNUSED_VARIABLE = YES;
357 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
358 | METAL_ENABLE_DEBUG_INFO = NO;
359 | SDKROOT = iphoneos;
360 | TARGETED_DEVICE_FAMILY = "1,2";
361 | VALIDATE_PRODUCT = YES;
362 | };
363 | name = Release;
364 | };
365 | 26B692CD19521BDE0024F43B /* Debug */ = {
366 | isa = XCBuildConfiguration;
367 | buildSettings = {
368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
369 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
370 | INFOPLIST_FILE = SwiftTri/Info.plist;
371 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
372 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
373 | PRODUCT_NAME = "$(TARGET_NAME)";
374 | };
375 | name = Debug;
376 | };
377 | 26B692CE19521BDE0024F43B /* Release */ = {
378 | isa = XCBuildConfiguration;
379 | buildSettings = {
380 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
381 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
382 | INFOPLIST_FILE = SwiftTri/Info.plist;
383 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
385 | PRODUCT_NAME = "$(TARGET_NAME)";
386 | };
387 | name = Release;
388 | };
389 | 26B692D019521BDE0024F43B /* Debug */ = {
390 | isa = XCBuildConfiguration;
391 | buildSettings = {
392 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftTri.app/SwiftTri";
393 | FRAMEWORK_SEARCH_PATHS = (
394 | "$(SDKROOT)/Developer/Library/Frameworks",
395 | "$(inherited)",
396 | );
397 | GCC_PREPROCESSOR_DEFINITIONS = (
398 | "DEBUG=1",
399 | "$(inherited)",
400 | );
401 | INFOPLIST_FILE = SwiftTriTests/Info.plist;
402 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
403 | METAL_ENABLE_DEBUG_INFO = YES;
404 | PRODUCT_NAME = "$(TARGET_NAME)";
405 | TEST_HOST = "$(BUNDLE_LOADER)";
406 | };
407 | name = Debug;
408 | };
409 | 26B692D119521BDE0024F43B /* Release */ = {
410 | isa = XCBuildConfiguration;
411 | buildSettings = {
412 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftTri.app/SwiftTri";
413 | FRAMEWORK_SEARCH_PATHS = (
414 | "$(SDKROOT)/Developer/Library/Frameworks",
415 | "$(inherited)",
416 | );
417 | INFOPLIST_FILE = SwiftTriTests/Info.plist;
418 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
419 | METAL_ENABLE_DEBUG_INFO = NO;
420 | PRODUCT_NAME = "$(TARGET_NAME)";
421 | TEST_HOST = "$(BUNDLE_LOADER)";
422 | };
423 | name = Release;
424 | };
425 | /* End XCBuildConfiguration section */
426 |
427 | /* Begin XCConfigurationList section */
428 | 26B692AB19521BDE0024F43B /* Build configuration list for PBXProject "SwiftTri" */ = {
429 | isa = XCConfigurationList;
430 | buildConfigurations = (
431 | 26B692CA19521BDE0024F43B /* Debug */,
432 | 26B692CB19521BDE0024F43B /* Release */,
433 | );
434 | defaultConfigurationIsVisible = 0;
435 | defaultConfigurationName = Release;
436 | };
437 | 26B692CC19521BDE0024F43B /* Build configuration list for PBXNativeTarget "SwiftTri" */ = {
438 | isa = XCConfigurationList;
439 | buildConfigurations = (
440 | 26B692CD19521BDE0024F43B /* Debug */,
441 | 26B692CE19521BDE0024F43B /* Release */,
442 | );
443 | defaultConfigurationIsVisible = 0;
444 | defaultConfigurationName = Release;
445 | };
446 | 26B692CF19521BDE0024F43B /* Build configuration list for PBXNativeTarget "SwiftTriTests" */ = {
447 | isa = XCConfigurationList;
448 | buildConfigurations = (
449 | 26B692D019521BDE0024F43B /* Debug */,
450 | 26B692D119521BDE0024F43B /* Release */,
451 | );
452 | defaultConfigurationIsVisible = 0;
453 | defaultConfigurationName = Release;
454 | };
455 | /* End XCConfigurationList section */
456 | };
457 | rootObject = 26B692A819521BDE0024F43B /* Project object */;
458 | }
459 |
--------------------------------------------------------------------------------