100% Offline Maps in an iOS Application Using Free and Open-Source Tools

In this post, I’d like to show a simple, free, and open-source solution for using 100% offline vector maps in an iOS application.

The complete source code for my playground is available on GitHub https://github.com/AndreiMaksimovich/SwiftDeveloperBlog/tree/main/08%20-%20OfflineMaps, so I won’t cover the implementation details here. Instead, this post focuses on the overall technology stack, explains how the components fit together, and provides links to all of the tools and resources you’ll need.

Technology Stack

iOS Map Library

Vector Tile Schemas

Map Styles

Download OpenStreetMap Data

Generate MBTiles from .osm.pbf


How Everything Fits Together

To avoid confusion, here’s how the individual pieces work together.

  • MapLibre Native is an open-source map rendering engine that can display vector MBTiles completely offline.
  • MBTiles is an open file format for storing raster or vector map tiles in a single portable SQLite database.
  • The vector data stored in an MBTiles database can follow different schemas. The popular ones are Shortbread Tiles and OpenMapTiles.
  • MapLibre uses a style specification that defines how the map is rendered, what layers to draw, in what order, and how each feature should look.
  • A map style is created for a specific tile schema. For example, an OpenMapTiles style cannot be used directly with Shortbread Tiles, and vice versa.
  • OpenStreetMap data can be downloaded as .osm.pbf files. Before it can be used by MapLibre offile, it must be converted into MBTiles using a tool that exports data in the desired schema.
  • MapLibre Native can load fonts, sprites, and other style assets directly from your application’s bundle.
  • You can display your own data such as custom points of interest, routes, polygons, or markers using GeoJSON, additional MBTiles or other supported data sources.

OpenStreetMap (.osm.pbf) → Tilemaker → MBTiles → MapLibre Native → iOS App


Building an Offline Map Application

The overall workflow is straightforward:

  1. Choose the tile schema and map style that best fits your application.
  2. Include the required style assets (fonts, sprites, style JSON) in your application bundle.
  3. Download OpenStreetMap data for the desired region from Geofabrik.
  4. Convert the .osm.pbf file into an MBTiles database using Tilemaker.
  5. Embed the generated MBTiles file in your application or download it on demand.
  6. Add your own POIs, routes, or other custom data as additional map sources.
  7. Automate the download and conversion process as part of your build or content pipeline.

Result

With this setup, you’ll have a fully offline, beautifully rendered vector map that is completely free and open source. Depending on the selected style, it can display significantly more detail than Apple Maps while giving you full control over the map’s appearance, assets, and data.