As of iOS 10, you can use the Spatial Partitioning features of GampelayKit. In 2D either GKQuadtree or GKRTree depending on your needs.
From the docs:
Quadtrees and R-trees have different performance tradeoffs for different tasks: quadtrees can be faster when objects are more uniformly distributed in space or when their positions change frequently, and R-trees can be faster when searching for all objects in a given region.
Add your enemies to the tree:
let minX = Float(enemy.frame.minX)
let minY = Float(enemy.frame.minY)
let maxX = Float(enemy.frame.maxX)
let maxY = Float(enemy.frame.maxY)
var enemiesRTree = GKRTree(maxNumberOfChildren: 3)
enemiesRTree.addElement(enemy,
boundingRectMin: vector2(minX, minY),
boundingRectMax: vector2(maxX, maxY),
splitStrategy: GKRTreeSplitStrategy.linear)
Then you can search by area.
let enemiesInProximity = enemiesRTree.elements(
inBoundingRectMin: vector2(0, 0),
rectMax: vector2(100, 100))
You can then create the search area e.g. relative to the player's position.