On this page
Welcome to the documentation site for the official MongoDB Swift driver. You can add the driver to your application to work with MongoDB in Swift. Download it with the Swift Package Manager or set up a runnable project with examples from our Usage Guide.
If you are looking for information about using Swift with MongoDB Realm, see the MongoDB Realm iOS SDK documentation.
For information about connecting to Atlas Serverless, see the Serverless Instance Limitations page for the minimum driver version you need.
If you need to run a MongoDB server on your local machine for development purposes instead of using an Atlas cluster, you need to complete the following:
Install and configure MongoDB Server.
Start the server.
Always secure your MongoDB server from malicious attacks. See our Security Checklist for a list of security recommendations.
After you successfully start your MongoDB server, specify your connection string in your driver connection code.
If your MongoDB Server is running locally, you can use the connection string
<port> is the port number you
configured your server to listen for incoming connections.
If you need to specify a different hostname or IP address, see our Server Manual entry on Connection Strings.
To test whether you can connect to your server, replace the connection string in the Connect to MongoDB Atlas code example and run it.
All features are supported.
The Driver version will work with the MongoDB version, but not all new MongoDB features are supported.
The Driver version is not tested with the MongoDB version.
The Swift driver is not compatible with MongoDB server versions older than 3.6.
|||(1, 2) Versions 1.2 and 1.3 do not include support for Client-Side Field Level Encryption, GridFS, and authentication using AWS IAM roles.|
|||(1, 2) Versions 1.0 and 1.1 do not include support for OCSP, Client-Side Field Level Encryption, GridFS, and authentication using AWS IAM roles.|
The MongoDB Swift driver requires Swift 5.1 or later.
For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.