Swiftpack.co -  zntfdr/Sight as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A spatial search μlibrary powered by GameplayKit 👾
.package(url: "https://github.com/zntfdr/Sight.git", from: "1.0.0")


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 position.
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: https://github.com/zntfdr/Sight.git.


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!


Stars: 26
Last commit: 1 year ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Initial Release
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API