MongoDB Swift Driver - CLibMongoC compilation fails

I followed some instructions that was in Github Issue " CLibMongoC compilation fails when SPM package used in an Xcode project #387" to download the MongoDB Swift Driver project, build, and then add it to a workspace. I did since I kept having issues in Xcode when I tried adding the package dependencies.

Before I moved the .xcodeproj to the workspace, I did build it, and it had no issues. Then I moved the entire mongo-swift-driver-master folder that includes the mongo .xcodeproj into my Xcode folder that is for my other Xcode project. I then built the mongo .xcodeproj and again had no issues. The issue occurs when I move the mongo .xcodeproj to the workspace and then build again.

The issue I am having is the below:
Missing ‘#include “/Applications/”’; declaration of ‘SSLContextRef’ must be imported from module ‘Security.SecureTransport’ before it is required

Could someone provide some assistance please?

1 Like

Hi @Oscar_Rodriguez, what deployment target do you have selected? the error message sounds like you are targeting an iPhone simulator.

The driver does not support iOS usage, and is intended for building backend applications in Swift, that run on Linux and/or macOS.

The typical ways to handle DB interaction from a mobile app would be:

  1. Write a backend server to handle MongoDB interaction, which your iOS app can communicate with via a REST API. You could write this backend in Swift using the Swift driver, or really any language.
  2. Or, if you want a “serverless” solution, you might consider using MongoDB Realm Sync, which will allow you to sync local data from an iOS device with a remote MongoDB deployment.