Barn swallows prefer to build their nests in open areas near water or fields, where they can easily find insects for food. To attract them, place a nest box under the eaves or rafters of a building, with a clear line of sight to open spaces.