A spatial search μlibrary powered by GameplayKit 👾

What's New

Initial Release



Build status Swift Package Manager MacOS + iOS + iPadOS + tvOS Twitter: @zntfdr

Welcome to Sight, a Swift spatial search μlibrary. Its primary goal is to extend Apple's GameplayKit framework.


Sight helps you quickly determine which object is closest to a given position.

This is done via a Region instance, which represents the space where all the objects are positioned in.

import Sight

// Define a region with bounds and search radius.
let region = Region<String>(
  minBounds: SIMD2(x: 0, y: 0), 
  maxBounds: SIMD2(x: 1, y: 1), 
  searchRadius: 0.3

// Place objects in the region.
region.add("A", at: SIMD2(x: 0, y: 0.1))
region.add("B", at: SIMD2(x: 0.5, y: 0))
region.add("C", at: SIMD2(x: 0, y: 0.8))

// Find the closest object to any point.
region.closestValue(to: SIMD2(x: 0.5, y: 0.2)) // "B" 
region.closestValue(to: SIMD2(x: 1, y: 0)) // nil 

Region is optimized for spatial searches, this is why during its initialization both search radius and its bounds are required.

You can find many more examples in the Tests folder.


Sight is distributed using the Swift Package Manager. To install it into a project, follow this tutorial and use this repository URL:


Sight was built by Federico Zanetello as a component of Bangkok Metro.

If you'd like to know more on how this library works, please refer to GameplayKit's GKQuadtree overview.

Contributions and Support

All users are welcome and encouraged to become active participants in the project continued development — by fixing any bug that they encounter, or by improving the documentation wherever it’s found to be lacking.

If you'd like to make a change, please open a Pull Request, even if it just contains a draft of the changes you’re planning, or a test that reproduces an issue.

Thank you and please enjoy using Sight!


  • Swift Tools 5.1.0
View More Packages from this Author


  • None
Last updated: Sat Mar 18 2023 05:38:37 GMT-0500 (GMT-05:00)