Repository: mhergon/RealmGeoQueries Branch: master Commit: 3cb2e6dd9566 Files: 30 Total size: 85.3 KB Directory structure: gitextract_do6dfjge/ ├── .gitignore ├── .swift-version ├── Cartfile ├── Cartfile.resolved ├── GeoQueries/ │ ├── GeoQueries.h │ └── Info.plist ├── GeoQueries.swift ├── LICENSE ├── Package.swift ├── README.md ├── RealmGeoQueries/ │ ├── AppDelegate.swift │ ├── Controllers/ │ │ ├── BoxViewController.swift │ │ ├── BoxViewController.xib │ │ ├── RadiusViewController.swift │ │ └── RadiusViewController.xib │ ├── Info.plist │ ├── Model/ │ │ ├── Annotation.swift │ │ └── Point.swift │ └── Resources/ │ ├── Assets.xcassets/ │ │ ├── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── box.imageset/ │ │ │ └── Contents.json │ │ └── radius.imageset/ │ │ └── Contents.json │ └── RealmGeoQueriesPoints.realm ├── RealmGeoQueries.podspec ├── RealmGeoQueries.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ └── xcshareddata/ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata/ │ └── xcschemes/ │ └── GeoQueries.xcscheme └── RealmGeoQueriesTests/ ├── Info.plist ├── RealmGeoQueriesTests.swift └── TestPoint.swift ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ ##### # OS X temporary files that should never be committed .DS_Store *.swp *.lock profile #### # Xcode temporary files that should never be committed *~.nib #### # Xcode build files DerivedData/ build/ Builds/ ##### # Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) *.pbxuser *.mode1v3 *.mode2v3 *.perspectivev3 !default.pbxuser !default.mode1v3 !default.mode2v3 !default.perspectivev3 #### # Xcode 4 xcuserdata !xcschemes # Xcode 4 *.moved-aside #### # XCode 4 workspaces - more detailed !xcshareddata !default.xcworkspace *.xcworkspacedata #### # Xcode 5 *.xccheckout *.xcuserstate #### # Xcode 7 *.xcscmblueprint #### # AppCode .idea/ #### # Other Xcode files profile *.hmap *.ipa #### # CocoaPods Pods/ #### # Carthage Carthage/Build Carthage/Checkouts ================================================ FILE: .swift-version ================================================ 4.0 ================================================ FILE: Cartfile ================================================ github "realm/realm-cocoa" ================================================ FILE: Cartfile.resolved ================================================ github "realm/realm-cocoa" "v3.13.1" ================================================ FILE: GeoQueries/GeoQueries.h ================================================ // // GeoQueries.h // GeoQueries // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // #import //! Project version number for GeoQueries. FOUNDATION_EXPORT double GeoQueriesVersionNumber; //! Project version string for GeoQueries. FOUNDATION_EXPORT const unsigned char GeoQueriesVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import ================================================ FILE: GeoQueries/Info.plist ================================================ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType FMWK CFBundleShortVersionString 1.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass ================================================ FILE: GeoQueries.swift ================================================ // // GeoQueries.swift // GeoQueries // // Created by mhergon on 15/10/16. // Copyright © 2016 mhergon. All rights reserved. // import RealmSwift import CoreLocation import MapKit enum GeoQueriesError: Error { case invalidRealm(String) } // MARK: - Public extensions public extension Realm { /** Find objects inside MKCoordinateRegion. Useful for use in conjunction with MapKit - parameter type: Realm object type - parameter region: Region that fits MapKit view - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Found objects inside MKCoordinateRegion */ func findInRegion(type: Element.Type, region: MKCoordinateRegion, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> Results { // Query return try self .objects(type) .filterGeoBox(box: region.geoBox, latitudeKey: latitudeKey, longitudeKey: longitudeKey) } /** Find objects inside GeoBox - parameter type: Realm object type - parameter box: GeoBox struct - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Found objects inside GeoBox */ func findInBox(type: Element.Type, box: GeoBox, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> Results { // Query return try self .objects(type) .filterGeoBox(box: box, latitudeKey: latitudeKey, longitudeKey: longitudeKey) } /** Find objects from center and distance radius - parameter type: Realm object type - parameter center: Center coordinate - parameter radius: Radius in meters - parameter order: Sort by distance (optional) - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Found objects inside radius around the center coordinate */ func findNearby(type: Element.Type, origin center: CLLocationCoordinate2D, radius: Double, sortAscending sort: Bool?, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> [Element] { // Query return try self .objects(type) .filterGeoBox(box: center.geoBox(radius: radius), latitudeKey: latitudeKey, longitudeKey: longitudeKey) .filterGeoRadius(center: center, radius: radius, sortAscending: sort, latitudeKey: latitudeKey, longitudeKey: longitudeKey) } } public extension RealmCollection where Element: Object { /** Filter results from Realm query using MKCoordinateRegion - parameter region: Region that fits MapKit view - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Filtered objects inside MKCoordinateRegion */ func filterGeoRegion(region: MKCoordinateRegion, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> Results { // Realm instance pre-check guard let _ = realm else { throw GeoQueriesError.invalidRealm("RLMRealm instance is needed to call this method") } let box = region.geoBox let topLeftPredicate = NSPredicate(format: "%K <= %f AND %K >= %f", latitudeKey, box.topLeft.latitude, longitudeKey, box.topLeft.longitude) let bottomRightPredicate = NSPredicate(format: "%K >= %f AND %K <= %f", latitudeKey, box.bottomRight.latitude, longitudeKey, box.bottomRight.longitude) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [topLeftPredicate, bottomRightPredicate]) return self.filter(compoundPredicate) } /** Filter results from Realm query using GeoBox - parameter box: GeoBox struct - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Filtered objects inside GeoBox */ func filterGeoBox(box: GeoBox, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> Results { // Realm instance pre-check guard let _ = realm else { throw GeoQueriesError.invalidRealm("RLMRealm instance is needed to call this method") } let topLeftPredicate = NSPredicate(format: "%K <= %f AND %K >= %f", latitudeKey, box.topLeft.latitude, longitudeKey, box.topLeft.longitude) let bottomRightPredicate = NSPredicate(format: "%K >= %f AND %K <= %f", latitudeKey, box.bottomRight.latitude, longitudeKey, box.bottomRight.longitude) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [topLeftPredicate, bottomRightPredicate]) return self.filter(compoundPredicate) } /** Filter results from center and distance radius - parameter center: Center coordinate - parameter radius: Radius in meters - parameter sort: Sort by distance (optionl) - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Found objects inside radius around the center coordinate */ func filterGeoRadius(center: CLLocationCoordinate2D, radius: Double, sortAscending sort: Bool?, latitudeKey: String = "lat", longitudeKey: String = "lng") throws -> [Element] { // Realm instance pre-check guard let _ = realm else { throw GeoQueriesError.invalidRealm("RLMRealm instance is needed to call this method") } // Get box let inBox = try filterGeoBox(box: center.geoBox(radius: radius), latitudeKey: latitudeKey, longitudeKey: longitudeKey) // add distance let distance = inBox.addDistance(center: center, latitudeKey: latitudeKey, longitudeKey: longitudeKey) // Inside radius let radius = distance.filter { (obj: Object) -> Bool in return obj.objDist <= radius } // Sort results guard let s = sort else { return radius } return radius.sort(ascending: s) } /// Sort by distance /// /// - Parameters: /// - center: Center coordinate /// - ascending: Ascendig or descending /// - latitudeKey: Set to use different latitude key in query (default: "lat") /// - longitudeKey: Set to use different longitude key in query (default: "lng") /// - Returns: Sorted objects func sortByDistance(center: CLLocationCoordinate2D, ascending: Bool, latitudeKey: String = "lat", longitudeKey: String = "lng") -> [Element] { return self .addDistance(center: center, latitudeKey: latitudeKey, longitudeKey: longitudeKey) .sort(ascending: ascending) } } // MARK: - Public core extensions /// GeoBox struct. Set top-left and bottom-right coordinate to create a box public struct GeoBox { public var topLeft: CLLocationCoordinate2D public var bottomRight: CLLocationCoordinate2D public init(topLeft: CLLocationCoordinate2D, bottomRight: CLLocationCoordinate2D) { self.topLeft = topLeft self.bottomRight = bottomRight } } public extension CLLocationCoordinate2D { /** Accessory function to convert CLLocationCoordinate2D to GeoBox - parameter radius: Radius in meters - returns: GeoBox struct */ func geoBox(radius: Double) -> GeoBox { #if swift(>=4.2) return MKCoordinateRegion(center: self, latitudinalMeters: radius * 2.0, longitudinalMeters: radius * 2.0).geoBox #else return MKCoordinateRegion.init(center: self, latitudinalMeters: radius * 2.0, longitudinalMeters: radius * 2.0).geoBox #endif } } public extension MKCoordinateRegion { /// Accessory function to convert MKCoordinateRegion to GeoBox var geoBox: GeoBox { let maxLat = self.center.latitude + (self.span.latitudeDelta / 2.0) let minLat = self.center.latitude - (self.span.latitudeDelta / 2.0) let maxLng = self.center.longitude + (self.span.longitudeDelta / 2.0) let minLng = self.center.longitude - (self.span.longitudeDelta / 2.0) return GeoBox( topLeft: CLLocationCoordinate2D(latitude: maxLat, longitude: minLng), bottomRight: CLLocationCoordinate2D(latitude: minLat, longitude: maxLng) ) } } private extension Array where Element: Object { /** Sorting function - parameter ascending: Ascending/Descending - returns: Array of [Object] sorted by distance */ func sort(ascending: Bool = true) -> [Iterator.Element] { return self.sorted(by: { (a: Object, b: Object) -> Bool in if ascending { return a.objDist < b.objDist } else { return a.objDist > b.objDist } }) } } // MARK: - Private core extensions private extension RealmCollection where Element: Object { /** Add distance to sort results - parameter center: Center coordinate - parameter latitudeKey: Set to use different latitude key in query (default: "lat") - parameter longitudeKey: Set to use different longitude key in query (default: "lng") - returns: Array of results sorted */ func addDistance(center: CLLocationCoordinate2D, latitudeKey: String = "lat", longitudeKey: String = "lng") -> [Element] { return self.map { (obj) -> Element in // Calculate distance let location = CLLocation(latitude: obj.value(forKeyPath: latitudeKey) as! CLLocationDegrees, longitude: obj.value(forKeyPath: longitudeKey) as! CLLocationDegrees) let center = CLLocation(latitude: center.latitude, longitude: center.longitude) let distance = location.distance(from: center) // Save obj.objDist = distance return obj } } } private extension Object { private struct AssociatedKeys { static var DistanceKey = "DistanceKey" } var objDist: Double { get { guard let value = objc_getAssociatedObject(self, &AssociatedKeys.DistanceKey) as? Double else { return 0.0 } return value } set (value) { objc_setAssociatedObject(self, &AssociatedKeys.DistanceKey, value, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) } } } ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: Package.swift ================================================ // swift-tools-version:5.1 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "GeoQueries", products: [ .library( name: "GeoQueries", targets: ["GeoQueries"]), ], dependencies: [ .package(url: "https://github.com/realm/realm-cocoa.git", from: "4.3.0"), ], targets: [ .target( name: "GeoQueries", dependencies: ["RealmSwift"], path: ".", sources: ["GeoQueries.swift"] ) ] ) ================================================ FILE: README.md ================================================

RealmGeoQueries

![cocoapods](https://img.shields.io/cocoapods/v/RealmGeoQueries.svg?style=flat) ![carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat) ![issues](https://img.shields.io/github/issues/mhergon/RealmGeoQueries.svg) ![stars](https://img.shields.io/github/stars/mhergon/RealmGeoQueries.svg) ![license](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg) RealmGeoQueries simplifies spatial queries with [Realm Cocoa][1]. In the absence of and official functions, this library provide the possibility to do proximity search. It's not necessary to include Geohash or other types of indexes in the model class as it only needs latitude and longitude properties. ## How To Get Started ### Installation with CocoaPods ```ruby platform :ios, '9.0' pod "RealmGeoQueries" ``` ### Installation with Carthage Add to `mhergon/RealmGeoQueries` project to your `Cartfile` ```ruby github "mhergon/RealmGeoQueries" ``` Drag `GeoQueries.framework`, `RealmSwift.framework` and `Realm.framework` from Carthage/Build/ to the “Linked Frameworks and Libraries” section of your Xcode project’s “General” settings. Only on **iOS/tvOS/watchOS**: On your application targets "Build Phases" settings tab, click the "+" icon and choose "New Run Script Phase". Create a Run Script with the following contents: ```ruby /usr/local/bin/carthage copy-frameworks ``` and add the paths to the frameworks you want to use under "Input Files", e.g.: ```ruby $(SRCROOT)/Carthage/Build/iOS/GeoQueries.framework $(SRCROOT)/Carthage/Build/iOS/Realm.framework $(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework ``` ### Swift Package Manager Once you have your Swift package set up, adding RealmGeoQueries as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. ```swift dependencies: [ .package(url: "https://github.com/mhergon/RealmGeoQueries.git", from: "1.4.0") ] ``` ### Manually installation [Download](https://github.com/mhergon/RealmGeoQueries/raw/master/GeoQueries.swift) (right-click) and add to your project. ### Requirements | Version | Language | Minimum iOS Target | |:--------------------:|:---------------------------:|:---------------------------:| | 1.4 | Swift 5.x / Realm 5.x | iOS 9 | | 1.3 | Swift 4.x / Realm 3.x | iOS 9 | | 1.2 | Swift 3.0 / Realm 2.x | iOS 9 | | 1.1 | Swift 2.x / Realm 2.x | iOS 8 | ### Usage First, import module; ```swift import GeoQueries ``` Model must have a latitude and longitude keys, that have to be named "lat" and "lng" respectively. You can use another property names (use "latitudeKey" and "longitudeKey" parameters).
Search with MapView MKCoordinateRegion; ```swift let results = try! Realm() .findInRegion(type: YourModelClass.self, region: mapView.region) ```
Search around the center with radius in meters; ```swift let results = try! Realm() .findNearby(type: YourModelClass.self, origin: mapView.centerCoordinate, radius: 500, sortAscending: nil) ```
Filter Realm results with radius in meters; ```swift let results = try! Realm() .objects(YourModelClass.self) .filter("type", "restaurant") .filterGeoRadius(center: mapView.centerCoordinate, radius: 500, sortAscending: nil) ```
See ```GeoQueries.swift``` for more options. ## Contact - [Linkedin][2] - [Twitter][3] (@mhergon) [1]: http://www.realm.io [2]: https://es.linkedin.com/in/marchervera [3]: http://twitter.com/mhergon "Marc Hervera" ## License Licensed under Apache License v2.0.
Copyright 2020 Marc Hervera. ================================================ FILE: RealmGeoQueries/AppDelegate.swift ================================================ // // AppDelegate.swift // RealmGeoQueries // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) window?.backgroundColor = UIColor.white window?.makeKeyAndVisible() // DB initialSetup() // Views let boxView = BoxViewController() boxView.tabBarItem = UITabBarItem(title: "Box query", image: UIImage(named: "box"), tag: 0) let radiusView = RadiusViewController() radiusView.tabBarItem = UITabBarItem(title: "Radius query", image: UIImage(named: "radius"), tag: 1) let tabBar = UITabBarController() tabBar.viewControllers = [boxView, radiusView] self.window?.rootViewController = tabBar return true } func applicationWillResignActive(_ application: UIApplication) { // 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. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // 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. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // 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. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } //MARK:- Methods func initialSetup() { let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)[0] as NSString let filePath = path.appendingPathComponent("default.realm") let fileManager = FileManager.default guard !fileManager.fileExists(atPath: filePath) else { return } if let db = Bundle.main.path(forResource: "RealmGeoQueriesPoints", ofType: "realm") { try! fileManager.copyItem(atPath: db, toPath: filePath) } } } ================================================ FILE: RealmGeoQueries/Controllers/BoxViewController.swift ================================================ // // BoViewController.swift // RealmGeoQueries // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // import UIKit import MapKit import RealmSwift fileprivate let AnnotationIdentifier = "AnnotationIdentifier" class BoxViewController: UIViewController { // MARK: - Properties @IBOutlet weak var mapView: MKMapView! fileprivate var results: Results? override func viewDidLoad() { super.viewDidLoad() reloadData() } //MARK:- Methods func reloadData() { // Get results results = try! Realm().findInRegion(type: Point.self, region: mapView.region) // Add to map guard let r = results else { return } // Remove previous annotations self.mapView.removeAnnotations(self.mapView.annotations) // Marina services var annotations = [Annotation]() for p in r { let coordinate = CLLocationCoordinate2D(latitude: p.lat, longitude: p.lng) let a = Annotation(location: coordinate, name: p.name) annotations.append(a) } // Add new annotations self.mapView.addAnnotations(annotations) } } // MARK: - MKMapViewDelegate extension BoxViewController: MKMapViewDelegate { func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { reloadData() } func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { // User location if annotation is MKUserLocation { return nil } guard let a = annotation as? Annotation else { return nil } // Marinas var pin = mapView.dequeueReusableAnnotationView(withIdentifier: AnnotationIdentifier) if pin == nil { pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: AnnotationIdentifier) pin?.canShowCallout = true } pin?.annotation = a return pin } } ================================================ FILE: RealmGeoQueries/Controllers/BoxViewController.xib ================================================ ================================================ FILE: RealmGeoQueries/Controllers/RadiusViewController.swift ================================================ // // RadiusViewController.swift // RealmGeoQueries // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // import UIKit import MapKit import RealmSwift fileprivate let AnnotationIdentifier = "AnnotationIdentifier" class RadiusViewController: UIViewController { // MARK: - Properties @IBOutlet weak var mapView: MKMapView! fileprivate var results: [Point]? override func viewDidLoad() { super.viewDidLoad() reloadData() } // MARK:- Methods func reloadData() { // Get results let radius = 450000.0 // 450 km results = try! Realm().findNearby(type: Point.self, origin: mapView.centerCoordinate, radius: radius, sortAscending: true) // Add to map guard let r = results else { return } // Remove previous annotations self.mapView.removeAnnotations(self.mapView.annotations) // Marina services var annotations = [Annotation]() for p in r { let coordinate = CLLocationCoordinate2D(latitude: p.lat, longitude: p.lng) let a = Annotation(location: coordinate, name: p.name) annotations.append(a) } // Add new annotations self.mapView.addAnnotations(annotations) // Add circle mapView.removeOverlays(mapView.overlays) let circle = MKCircle(center: mapView.centerCoordinate, radius: radius) mapView.addOverlay(circle) } } // MARK: - MKMapViewDelegate extension RadiusViewController: MKMapViewDelegate { func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { reloadData() } func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { // User location if annotation is MKUserLocation { return nil } guard let a = annotation as? Annotation else { return nil } // Marinas var pin = mapView.dequeueReusableAnnotationView(withIdentifier: AnnotationIdentifier) if pin == nil { pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: AnnotationIdentifier) pin?.canShowCallout = true } pin?.annotation = a return pin } func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { let circle = MKCircleRenderer(overlay: overlay) circle.strokeColor = UIColor.red circle.fillColor = UIColor(red: 255, green: 0, blue: 0, alpha: 0.1) circle.lineWidth = 1 return circle } } ================================================ FILE: RealmGeoQueries/Controllers/RadiusViewController.xib ================================================ ================================================ FILE: RealmGeoQueries/Info.plist ================================================ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName BoxViewController UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: RealmGeoQueries/Model/Annotation.swift ================================================ // // Annotation.swift // Geohash-Mapbox // // Created by mhergon on 21/5/15. // Copyright (c) 2015 mhergon. All rights reserved. // import UIKit import CoreLocation import MapKit class Annotation: NSObject, MKAnnotation { let coordinate: CLLocationCoordinate2D var title: String? var subtitle: String? init(location coordinate: CLLocationCoordinate2D, name: String?) { self.coordinate = coordinate self.title = name } } ================================================ FILE: RealmGeoQueries/Model/Point.swift ================================================ // // Point.swift // TestGeoQuery // // Created by mhergon on 30/11/15. // Copyright © 2015 mhergon. All rights reserved. // import Realm import RealmSwift class Point: Object { @objc dynamic var name = "" @objc dynamic var lat: Double = 0.0 @objc dynamic var lng: Double = 0.0 } ================================================ FILE: RealmGeoQueries/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "20x20", "scale" : "2x" }, { "idiom" : "iphone", "size" : "20x20", "scale" : "3x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "1x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "2x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "1x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x" }, { "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" }, { "idiom" : "ios-marketing", "size" : "1024x1024", "scale" : "1x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: RealmGeoQueries/Resources/Assets.xcassets/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: RealmGeoQueries/Resources/Assets.xcassets/box.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "box.pdf" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: RealmGeoQueries/Resources/Assets.xcassets/radius.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "radius.pdf" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: RealmGeoQueries.podspec ================================================ Pod::Spec.new do |spec| spec.name = 'RealmGeoQueries' spec.platform = :ios, "9.0" spec.version = '1.3.2' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/mhergon/RealmGeoQueries' spec.authors = { 'Marc Hervera' => 'mhergon@gmail.com' } spec.summary = 'Realm GeoQueries made easy' spec.source = { :git => 'https://github.com/mhergon/RealmGeoQueries.git', :tag => 'v1.3.2' } spec.source_files = 'GeoQueries.swift' spec.ios.frameworks = 'CoreLocation', 'MapKit' spec.dependency 'RealmSwift' spec.requires_arc = true spec.module_name = 'GeoQueries' end ================================================ FILE: RealmGeoQueries.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 48; objects = { /* Begin PBXBuildFile section */ 4B1ABE061F84F40700566726 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1ABE051F84F40700566726 /* MapKit.framework */; }; 4B1ABE071F84F74900566726 /* RealmGeoQueriesPoints.realm in Resources */ = {isa = PBXBuildFile; fileRef = 4B1F42481F84BA7C00ABFE1B /* RealmGeoQueriesPoints.realm */; }; 4B1F422B1F84B76D00ABFE1B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1F422A1F84B76D00ABFE1B /* AppDelegate.swift */; }; 4B1F42321F84B76D00ABFE1B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B1F42311F84B76D00ABFE1B /* Assets.xcassets */; }; 4B1F423E1F84B89B00ABFE1B /* BoxViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B1F423C1F84B89B00ABFE1B /* BoxViewController.xib */; }; 4B1F423F1F84B89B00ABFE1B /* BoxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1F423D1F84B89B00ABFE1B /* BoxViewController.swift */; }; 4B1F42461F84BA4900ABFE1B /* RadiusViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B1F42441F84BA4900ABFE1B /* RadiusViewController.xib */; }; 4B1F42471F84BA4900ABFE1B /* RadiusViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1F42451F84BA4900ABFE1B /* RadiusViewController.swift */; }; 4B1F42511F84C5D900ABFE1B /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F424F1F84C5D900ABFE1B /* RealmSwift.framework */; }; 4B1F42521F84C5D900ABFE1B /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F42501F84C5D900ABFE1B /* Realm.framework */; }; 4B1F42561F84D86A00ABFE1B /* Point.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1F42541F84D7D000ABFE1B /* Point.swift */; }; 4B1F42571F84D86C00ABFE1B /* Annotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1F42551F84D7D000ABFE1B /* Annotation.swift */; }; 4BC1E8BF1F84FDB900AF3BE0 /* GeoQueries.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC1E8BD1F84FDB900AF3BE0 /* GeoQueries.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC1E8C21F84FDB900AF3BE0 /* GeoQueries.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */; }; 4BC1E8C31F84FDB900AF3BE0 /* GeoQueries.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BC1E8C91F84FE0D00AF3BE0 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F42501F84C5D900ABFE1B /* Realm.framework */; }; 4BC1E8CA1F84FE0D00AF3BE0 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F424F1F84C5D900ABFE1B /* RealmSwift.framework */; }; 4BC1E8D21F85529D00AF3BE0 /* RealmGeoQueriesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC1E8D11F85529D00AF3BE0 /* RealmGeoQueriesTests.swift */; }; 4BC1E8D91F85539B00AF3BE0 /* GeoQueries.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */; }; 4BC1E8DA1F8553A600AF3BE0 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F42501F84C5D900ABFE1B /* Realm.framework */; }; 4BC1E8DB1F8553A600AF3BE0 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1F424F1F84C5D900ABFE1B /* RealmSwift.framework */; }; 4BC1E8DE1F8556D900AF3BE0 /* TestPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC1E8DD1F8556D900AF3BE0 /* TestPoint.swift */; }; 4BDD4545223ACD0500AC34E3 /* GeoQueries.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDD4544223ACD0500AC34E3 /* GeoQueries.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 4BC1E8C01F84FDB900AF3BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4B1F421F1F84B76D00ABFE1B /* Project object */; proxyType = 1; remoteGlobalIDString = 4BC1E8BA1F84FDB900AF3BE0; remoteInfo = GeoQueries; }; 4BC1E8D41F85529D00AF3BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4B1F421F1F84B76D00ABFE1B /* Project object */; proxyType = 1; remoteGlobalIDString = 4B1F42261F84B76D00ABFE1B; remoteInfo = RealmGeoQueries; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ 4BC1E8C71F84FDB900AF3BE0 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( 4BC1E8C31F84FDB900AF3BE0 /* GeoQueries.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 4B1ABE051F84F40700566726 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; 4B1F42271F84B76D00ABFE1B /* RealmGeoQueries.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RealmGeoQueries.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4B1F422A1F84B76D00ABFE1B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4B1F42311F84B76D00ABFE1B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4B1F42361F84B76D00ABFE1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4B1F423C1F84B89B00ABFE1B /* BoxViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BoxViewController.xib; sourceTree = ""; }; 4B1F423D1F84B89B00ABFE1B /* BoxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxViewController.swift; sourceTree = ""; }; 4B1F42441F84BA4900ABFE1B /* RadiusViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RadiusViewController.xib; sourceTree = ""; }; 4B1F42451F84BA4900ABFE1B /* RadiusViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadiusViewController.swift; sourceTree = ""; }; 4B1F42481F84BA7C00ABFE1B /* RealmGeoQueriesPoints.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = RealmGeoQueriesPoints.realm; sourceTree = ""; }; 4B1F424F1F84C5D900ABFE1B /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = Carthage/Build/iOS/RealmSwift.framework; sourceTree = ""; }; 4B1F42501F84C5D900ABFE1B /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = ""; }; 4B1F42541F84D7D000ABFE1B /* Point.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Point.swift; sourceTree = ""; }; 4B1F42551F84D7D000ABFE1B /* Annotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Annotation.swift; sourceTree = ""; }; 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GeoQueries.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4BC1E8BD1F84FDB900AF3BE0 /* GeoQueries.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeoQueries.h; sourceTree = ""; }; 4BC1E8BE1F84FDB900AF3BE0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4BC1E8CF1F85529D00AF3BE0 /* RealmGeoQueriesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealmGeoQueriesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 4BC1E8D11F85529D00AF3BE0 /* RealmGeoQueriesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmGeoQueriesTests.swift; sourceTree = ""; }; 4BC1E8D31F85529D00AF3BE0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4BC1E8DD1F8556D900AF3BE0 /* TestPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestPoint.swift; sourceTree = ""; }; 4BDD4544223ACD0500AC34E3 /* GeoQueries.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoQueries.swift; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 4B1F42241F84B76D00ABFE1B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4B1F42511F84C5D900ABFE1B /* RealmSwift.framework in Frameworks */, 4BC1E8C21F84FDB900AF3BE0 /* GeoQueries.framework in Frameworks */, 4B1ABE061F84F40700566726 /* MapKit.framework in Frameworks */, 4B1F42521F84C5D900ABFE1B /* Realm.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8B71F84FDB900AF3BE0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4BC1E8C91F84FE0D00AF3BE0 /* Realm.framework in Frameworks */, 4BC1E8CA1F84FE0D00AF3BE0 /* RealmSwift.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8CC1F85529D00AF3BE0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4BC1E8DA1F8553A600AF3BE0 /* Realm.framework in Frameworks */, 4BC1E8DB1F8553A600AF3BE0 /* RealmSwift.framework in Frameworks */, 4BC1E8D91F85539B00AF3BE0 /* GeoQueries.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 4B1F421E1F84B76D00ABFE1B = { isa = PBXGroup; children = ( 4B1F42291F84B76D00ABFE1B /* RealmGeoQueries */, 4BC1E8BC1F84FDB900AF3BE0 /* GeoQueries */, 4BC1E8D01F85529D00AF3BE0 /* RealmGeoQueriesTests */, 4B1F42281F84B76D00ABFE1B /* Products */, 4B1F424E1F84C5D800ABFE1B /* Frameworks */, ); sourceTree = ""; }; 4B1F42281F84B76D00ABFE1B /* Products */ = { isa = PBXGroup; children = ( 4B1F42271F84B76D00ABFE1B /* RealmGeoQueries.app */, 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */, 4BC1E8CF1F85529D00AF3BE0 /* RealmGeoQueriesTests.xctest */, ); name = Products; sourceTree = ""; }; 4B1F42291F84B76D00ABFE1B /* RealmGeoQueries */ = { isa = PBXGroup; children = ( 4B1F422A1F84B76D00ABFE1B /* AppDelegate.swift */, 4B1F42361F84B76D00ABFE1B /* Info.plist */, 4BDD4543223ACAD700AC34E3 /* GeoQueries */, 4B1F42531F84D7C500ABFE1B /* Model */, 4B1F42491F84BAD000ABFE1B /* Resources */, 4B1F42401F84B89F00ABFE1B /* Controllers */, ); path = RealmGeoQueries; sourceTree = ""; }; 4B1F42401F84B89F00ABFE1B /* Controllers */ = { isa = PBXGroup; children = ( 4B1F423D1F84B89B00ABFE1B /* BoxViewController.swift */, 4B1F423C1F84B89B00ABFE1B /* BoxViewController.xib */, 4B1F42451F84BA4900ABFE1B /* RadiusViewController.swift */, 4B1F42441F84BA4900ABFE1B /* RadiusViewController.xib */, ); path = Controllers; sourceTree = ""; }; 4B1F42491F84BAD000ABFE1B /* Resources */ = { isa = PBXGroup; children = ( 4B1F42311F84B76D00ABFE1B /* Assets.xcassets */, 4B1F42481F84BA7C00ABFE1B /* RealmGeoQueriesPoints.realm */, ); path = Resources; sourceTree = ""; }; 4B1F424E1F84C5D800ABFE1B /* Frameworks */ = { isa = PBXGroup; children = ( 4B1ABE051F84F40700566726 /* MapKit.framework */, 4B1F42501F84C5D900ABFE1B /* Realm.framework */, 4B1F424F1F84C5D900ABFE1B /* RealmSwift.framework */, ); name = Frameworks; sourceTree = ""; }; 4B1F42531F84D7C500ABFE1B /* Model */ = { isa = PBXGroup; children = ( 4B1F42541F84D7D000ABFE1B /* Point.swift */, 4B1F42551F84D7D000ABFE1B /* Annotation.swift */, ); path = Model; sourceTree = ""; }; 4BC1E8BC1F84FDB900AF3BE0 /* GeoQueries */ = { isa = PBXGroup; children = ( 4BC1E8BD1F84FDB900AF3BE0 /* GeoQueries.h */, 4BC1E8BE1F84FDB900AF3BE0 /* Info.plist */, ); path = GeoQueries; sourceTree = ""; }; 4BC1E8D01F85529D00AF3BE0 /* RealmGeoQueriesTests */ = { isa = PBXGroup; children = ( 4BC1E8DD1F8556D900AF3BE0 /* TestPoint.swift */, 4BC1E8D11F85529D00AF3BE0 /* RealmGeoQueriesTests.swift */, 4BC1E8D31F85529D00AF3BE0 /* Info.plist */, ); path = RealmGeoQueriesTests; sourceTree = ""; }; 4BDD4543223ACAD700AC34E3 /* GeoQueries */ = { isa = PBXGroup; children = ( 4BDD4544223ACD0500AC34E3 /* GeoQueries.swift */, ); path = GeoQueries; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 4BC1E8B81F84FDB900AF3BE0 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 4BC1E8BF1F84FDB900AF3BE0 /* GeoQueries.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 4B1F42261F84B76D00ABFE1B /* RealmGeoQueries */ = { isa = PBXNativeTarget; buildConfigurationList = 4B1F42391F84B76D00ABFE1B /* Build configuration list for PBXNativeTarget "RealmGeoQueries" */; buildPhases = ( 4B1F42231F84B76D00ABFE1B /* Sources */, 4B1F42241F84B76D00ABFE1B /* Frameworks */, 4B1F42251F84B76D00ABFE1B /* Resources */, 4B1F424D1F84C55E00ABFE1B /* ShellScript */, 4BC1E8C71F84FDB900AF3BE0 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( 4BC1E8C11F84FDB900AF3BE0 /* PBXTargetDependency */, ); name = RealmGeoQueries; productName = RealmGeoQueries; productReference = 4B1F42271F84B76D00ABFE1B /* RealmGeoQueries.app */; productType = "com.apple.product-type.application"; }; 4BC1E8BA1F84FDB900AF3BE0 /* GeoQueries */ = { isa = PBXNativeTarget; buildConfigurationList = 4BC1E8C41F84FDB900AF3BE0 /* Build configuration list for PBXNativeTarget "GeoQueries" */; buildPhases = ( 4BC1E8B61F84FDB900AF3BE0 /* Sources */, 4BC1E8B71F84FDB900AF3BE0 /* Frameworks */, 4BC1E8B81F84FDB900AF3BE0 /* Headers */, 4BC1E8B91F84FDB900AF3BE0 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = GeoQueries; productName = GeoQueries; productReference = 4BC1E8BB1F84FDB900AF3BE0 /* GeoQueries.framework */; productType = "com.apple.product-type.framework"; }; 4BC1E8CE1F85529D00AF3BE0 /* RealmGeoQueriesTests */ = { isa = PBXNativeTarget; buildConfigurationList = 4BC1E8D61F85529D00AF3BE0 /* Build configuration list for PBXNativeTarget "RealmGeoQueriesTests" */; buildPhases = ( 4BC1E8CB1F85529D00AF3BE0 /* Sources */, 4BC1E8CC1F85529D00AF3BE0 /* Frameworks */, 4BC1E8CD1F85529D00AF3BE0 /* Resources */, ); buildRules = ( ); dependencies = ( 4BC1E8D51F85529D00AF3BE0 /* PBXTargetDependency */, ); name = RealmGeoQueriesTests; productName = RealmGeoQueriesTests; productReference = 4BC1E8CF1F85529D00AF3BE0 /* RealmGeoQueriesTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 4B1F421F1F84B76D00ABFE1B /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0900; LastUpgradeCheck = 1010; ORGANIZATIONNAME = mhergon; TargetAttributes = { 4B1F42261F84B76D00ABFE1B = { CreatedOnToolsVersion = 9.0; LastSwiftMigration = 1010; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.Maps.iOS = { enabled = 1; }; }; }; 4BC1E8BA1F84FDB900AF3BE0 = { CreatedOnToolsVersion = 9.0; LastSwiftMigration = 1010; ProvisioningStyle = Automatic; }; 4BC1E8CE1F85529D00AF3BE0 = { CreatedOnToolsVersion = 9.0; LastSwiftMigration = 1010; ProvisioningStyle = Automatic; TestTargetID = 4B1F42261F84B76D00ABFE1B; }; }; }; buildConfigurationList = 4B1F42221F84B76D00ABFE1B /* Build configuration list for PBXProject "RealmGeoQueries" */; compatibilityVersion = "Xcode 8.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 4B1F421E1F84B76D00ABFE1B; productRefGroup = 4B1F42281F84B76D00ABFE1B /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 4B1F42261F84B76D00ABFE1B /* RealmGeoQueries */, 4BC1E8BA1F84FDB900AF3BE0 /* GeoQueries */, 4BC1E8CE1F85529D00AF3BE0 /* RealmGeoQueriesTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 4B1F42251F84B76D00ABFE1B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 4B1F42461F84BA4900ABFE1B /* RadiusViewController.xib in Resources */, 4B1ABE071F84F74900566726 /* RealmGeoQueriesPoints.realm in Resources */, 4B1F42321F84B76D00ABFE1B /* Assets.xcassets in Resources */, 4B1F423E1F84B89B00ABFE1B /* BoxViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8B91F84FDB900AF3BE0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8CD1F85529D00AF3BE0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 4B1F424D1F84C55E00ABFE1B /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework", "$(SRCROOT)/Carthage/Build/iOS/Realm.framework", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RealmSwift.framework", "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Realm.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "/usr/local/bin/carthage copy-frameworks\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 4B1F42231F84B76D00ABFE1B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 4B1F42561F84D86A00ABFE1B /* Point.swift in Sources */, 4B1F42571F84D86C00ABFE1B /* Annotation.swift in Sources */, 4B1F422B1F84B76D00ABFE1B /* AppDelegate.swift in Sources */, 4B1F42471F84BA4900ABFE1B /* RadiusViewController.swift in Sources */, 4BDD4545223ACD0500AC34E3 /* GeoQueries.swift in Sources */, 4B1F423F1F84B89B00ABFE1B /* BoxViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8B61F84FDB900AF3BE0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 4BC1E8CB1F85529D00AF3BE0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 4BC1E8DE1F8556D900AF3BE0 /* TestPoint.swift in Sources */, 4BC1E8D21F85529D00AF3BE0 /* RealmGeoQueriesTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 4BC1E8C11F84FDB900AF3BE0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4BC1E8BA1F84FDB900AF3BE0 /* GeoQueries */; targetProxy = 4BC1E8C01F84FDB900AF3BE0 /* PBXContainerItemProxy */; }; 4BC1E8D51F85529D00AF3BE0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4B1F42261F84B76D00ABFE1B /* RealmGeoQueries */; targetProxy = 4BC1E8D41F85529D00AF3BE0 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ 4B1F42371F84B76D00ABFE1B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; 4B1F42381F84B76D00ABFE1B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; }; 4B1F423A1F84B76D00ABFE1B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = E6L68FW2WH; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = RealmGeoQueries/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.RealmGeoQueries; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; 4B1F423B1F84B76D00ABFE1B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = E6L68FW2WH; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = RealmGeoQueries/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.RealmGeoQueries; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; 4BC1E8C51F84FDB900AF3BE0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = E6L68FW2WH; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = GeoQueries/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.GeoQueries; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Debug; }; 4BC1E8C61F84FDB900AF3BE0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = E6L68FW2WH; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = GeoQueries/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.GeoQueries; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Release; }; 4BC1E8D71F85529D00AF3BE0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = RealmGeoQueriesTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.RealmGeoQueriesTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RealmGeoQueries.app/RealmGeoQueries"; }; name = Debug; }; 4BC1E8D81F85529D00AF3BE0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = RealmGeoQueriesTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mhergon.RealmGeoQueriesTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RealmGeoQueries.app/RealmGeoQueries"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 4B1F42221F84B76D00ABFE1B /* Build configuration list for PBXProject "RealmGeoQueries" */ = { isa = XCConfigurationList; buildConfigurations = ( 4B1F42371F84B76D00ABFE1B /* Debug */, 4B1F42381F84B76D00ABFE1B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4B1F42391F84B76D00ABFE1B /* Build configuration list for PBXNativeTarget "RealmGeoQueries" */ = { isa = XCConfigurationList; buildConfigurations = ( 4B1F423A1F84B76D00ABFE1B /* Debug */, 4B1F423B1F84B76D00ABFE1B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4BC1E8C41F84FDB900AF3BE0 /* Build configuration list for PBXNativeTarget "GeoQueries" */ = { isa = XCConfigurationList; buildConfigurations = ( 4BC1E8C51F84FDB900AF3BE0 /* Debug */, 4BC1E8C61F84FDB900AF3BE0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4BC1E8D61F85529D00AF3BE0 /* Build configuration list for PBXNativeTarget "RealmGeoQueriesTests" */ = { isa = XCConfigurationList; buildConfigurations = ( 4BC1E8D71F85529D00AF3BE0 /* Debug */, 4BC1E8D81F85529D00AF3BE0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 4B1F421F1F84B76D00ABFE1B /* Project object */; } ================================================ FILE: RealmGeoQueries.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ================================================ IDEDidComputeMac32BitWarning ================================================ FILE: RealmGeoQueries.xcodeproj/xcshareddata/xcschemes/GeoQueries.xcscheme ================================================ ================================================ FILE: RealmGeoQueriesTests/Info.plist ================================================ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleVersion 1 ================================================ FILE: RealmGeoQueriesTests/RealmGeoQueriesTests.swift ================================================ // // RealmGeoQueriesTests.swift // RealmGeoQueriesTests // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // import XCTest import RealmSwift import GeoQueries import CoreLocation import MapKit class RealmGeoQueriesTests: XCTestCase { // MARK: - Properties fileprivate var realm: Realm? fileprivate let centerCoordinate = CLLocationCoordinate2DMake(43.0, 2.0) // MARK: - Setup methods override func setUp() { super.setUp() // Setup Realm realm = try! Realm(configuration: Realm.Configuration(inMemoryIdentifier: "testRealm")) // Setup test points try! realm?.write { var point = TestPoint() point.lat = 43.5837 point.lng = 2.43782 realm?.add(point) point = TestPoint() point.lat = 43.5237 point.lng = 2.93782 realm?.add(point) point = TestPoint() point.lat = 42.5237 point.lng = 3.93782 realm?.add(point) point = TestPoint() point.lat = 43.1237 point.lng = 2.90782 realm?.add(point) } } override func tearDown() { try! realm?.write { realm?.deleteAll() } realm = nil super.tearDown() } // MARK: - General methods func testFindInRegionSomePoints() { let region = MKCoordinateRegion.init(center: centerCoordinate, span: MKCoordinateSpan.init(latitudeDelta: 2.0, longitudeDelta: 2.0)) let count = try! realm?.findInRegion(type: TestPoint.self, region: region).count ?? 0 XCTAssertGreaterThan(count, 0) } func testFindInBoxSomePoints() { let count = try! realm?.findInBox(type: TestPoint.self, box: centerCoordinate.geoBox(radius: 200000)).count ?? 0 XCTAssertGreaterThan(count, 0) } func testFindNearbySomePoints() { let count = try! realm?.findNearby(type: TestPoint.self, origin: centerCoordinate, radius: 100000, sortAscending: true).count ?? 0 XCTAssertGreaterThan(count, 0) } func testFindNearbyMinimumRadius() { let count = try! realm?.findNearby(type: TestPoint.self, origin: centerCoordinate, radius: 100, sortAscending: true).count ?? 0 XCTAssertEqual(count, 0) } // MARK: - Results methods func testFilterGeoRegion() { let all = realm?.objects(TestPoint.self) let region = MKCoordinateRegion.init(center: centerCoordinate, span: MKCoordinateSpan.init(latitudeDelta: 2.0, longitudeDelta: 2.0)) do { let count = try all?.filterGeoRegion(region: region).count ?? 0 XCTAssertGreaterThan(count, 0) } catch { XCTFail("\(error)") } } // MARK: - List methods func testFilterGeoRegionWithoutRealm() { let list = List() let point = TestPoint() point.lat = 43.5837 point.lng = 2.43782 list.append(point) let region = MKCoordinateRegion.init(center: centerCoordinate, span: MKCoordinateSpan.init(latitudeDelta: 2.0, longitudeDelta: 2.0)) do { let count = try list.filterGeoRegion(region: region).count XCTAssertEqual(count, 0) XCTFail() } catch { XCTAssertNotNil(error) } } } ================================================ FILE: RealmGeoQueriesTests/TestPoint.swift ================================================ // // TestPoint.swift // RealmGeoQueriesTests // // Created by mhergon on 4/10/17. // Copyright © 2017 mhergon. All rights reserved. // import Realm import RealmSwift class TestPoint: Object { @objc dynamic var name = "" @objc dynamic var lat: Double = 0.0 @objc dynamic var lng: Double = 0.0 }