MongoDB Swift driver 1.0.0-rc1 released

We are pleased to announce the second release candidate for our 1.0.0 release.

Please note that this release drops support for Swift 5.0. The driver officially supports Swift 5.1 and 5.2 on macOS, Ubuntu 16.04, and Ubuntu 18.04.

A full list of included tickets is available below, but here are some highlights:

New Feature: Transactions Support

The driver now provides an API for transactions! Note that MongoDB supports transactions in replica sets as of v4.0, and in sharded clusters as of v4.2.

Please see the Transactions Guide in our documentation for details and examples.

Work on the convenient API for transactions (i.e. a withTransaction helper that includes helpful logic to automatically retry transactions on certain errors) is currently in progress.

Notable API Changes

  • MongoClient.shutdown() and MongoClient.syncShutdown() have been renamed MongoClient.close() and MongoClient.syncClose(), respectively, for consistency with other MongoDB drivers. (SWIFT-749)
  • ReadPreference is now a struct rather than a class. It no longer has any public initializers, but is instead initializable via static properties and methods available on the type. This makes usages more succinct, particularly in the context of e.g. an options struct where the compiler can infer the type. (SWIFT-738)
    let rp = ReadPreference(.primary) // old
    let rp = ReadPreference.primary // new
    let rp = try ReadPreference(.secondary, maxStalenessSeconds: 100) // old
    let rp = try ReadPreference.secondary(maxStalenessSeconds: 100) // new
    let options = FindOptions(readPreference: ReadPreference(.primary)) // old
    let options = FindOptions(readPreference: .primary) // new
  • All of the TLS options previously specifiable via the TLSOptions struct have been moved directly into ClientOptions, and have been renamed for consistency with the names used when they are specified via a MongoDB connection string. (SWIFT-753)
  • The maxScan option which has been deprecated since MongoDB v4.0 has been removed from FindOptions and FindOneOptions. (SWIFT-439)
  • Several previous usages of other integer types in the API have been updated to use Int instead (SWIFT-754). Please see this diff for a complete list.

Included Tickets


  • [SWIFT-750] - fix potential for deadlock when all connections are in use

New Feature

  • [SWIFT-746] - Implement startTransaction, commitTransaction, and abortTransaction in the asynchronous API
  • [SWIFT-747] - Implement startTransaction, commitTransaction, and abortTransaction in the synchronous API


  • [SWIFT-434] - Add a TLS guide
  • [SWIFT-743] - Implement TransactionOptions struct
  • [SWIFT-752] - Implement Transactions Spec Test Runner
  • [SWIFT-347] - Update error handling guide to include errorLabels information
  • [SWIFT-439] - Remove maxScan query option
  • [SWIFT-499] - Update benchmark suite to include multithreaded scenarios
  • [SWIFT-595] - Bump libmongoc version to 1.16
  • [SWIFT-618] - Bump minimum Swift version to 5.1, and start testing against Swift 5.2
  • [SWIFT-636] - Stop filtering out SERVICE_NAME = mongodb from mechanism properties in GSSAPI auth tests
    ( [SWIFT-705] - Tune default NIOThreadPool size
  • [SWIFT-731] - Update guides to focus on async API
  • [SWIFT-735] - Make ObjectId work with JSONEncoder/JSONDecoder
  • [SWIFT-744] - Update ClientSessionOptions to support transactions
  • [SWIFT-745] - Implement StartTransactionOperation, CommitTransactionOperation, and AbortTransactionOperation
  • [SWIFT-784] - Disable BSON_EXTRA_ALIGN in vendored libbson
  • [SWIFT-423] - Provide Transactions example for Docs


  • [SWIFT-224] - Avoid roundtripping values through Swift when copying values from one document to another
  • [SWIFT-621] - Provide default values for enum associated values where appropriate
  • [SWIFT-623] - Use Self rather than type(of: self)
  • [SWIFT-677] - listIndexNames should extract names from Documents rather than decoding entire IndexModels
  • [SWIFT-753] - Condense TLSOptions into ClientOptions struct, and make property names consistent with URI options spec
  • [SWIFT-754] - Use Int in public API as much as possible
  • [SWIFT-757] - Add RetryableWriteError error labels to retryable transaction tests
  • [SWIFT-772] - Add allowDiskUse option to find command
  • [SWIFT-751] - Add maxPoolSize option for connection pool
  • [SWIFT-773] - Support for authorizedDatabases option
  • [SWIFT-749] - Improve MongoClient shutdown logic
  • [SWIFT-738] - Make ReadPreference a struct
1 Like

When do you expect to have the final version released? Thank you!

1 Like

Hi Oscar! We expect to tag 1.0 within the next month.


Thank you so much! I am looking forward to it!

1 Like