MongoDB - Swift integration

I just have a lot confusion about what I need to create an IOS app Using MongoDB running on AWS, basically im building a social app but I have a lot of confusion in my mind about these topics:

1 - Setup MongoDB on Xcode - What do I need to setup mongo in my project? In official documents there’s a Realm configuration, but my app is only on cloud so why should I need Realm that is a local database?

2 Back End services - I see tutorials (very confusing) using Vapor, Express and Node JS, MongoKitten and other tools but I don’t get what do these tools do, can someone provide me a clear description about what I need and how to set up mongo on Xcode?

3 Authetication - Id like to use Firebase Authentication in my project in order to login users and get their tokens given me by Firebase, then I’d put these tokens in a collections called “Users” on mongoDB in order to authenticate users to mongoDB too, is it possible?

If needed I’d pay an expert who dedidates me sometime to clarify these topics, I want to get this knowledge, so please help me.

Hi @Marco_Vastolo,

Welcome to MongoDB community

The obsolutly best way to build swift apps with MongoDB on aws is with Atlas and Realm apps + Realm sdk:

https://docs.mongodb.com/realm/tutorial/ios-swift/

Realm allows custom function authontication so you might work with firebase api, however, there are many included auth providers like google,apple and Facebook so you might skip firebase .

Thanks
Pavel

Hi Pavel, how can I connect an Xcode project Mongo DB atlas using MongoSwift driver?

@Marco_Vastolo here you go:

https://docs.mongodb.com/drivers/swift/#connect-to-mongodb-atlas

But I really recommend exploring the swift realm sdk it will boost your Development in orders of magnitude.

Thanks
Pavel

Hi @Marco_Vastolo, I’m one of the developers of MongoSwift.

The Swift driver would be useful if you’d like to write a traditional backend application in Swift. This might be useful if, for example, you’d like your iOS app to send requests to an HTTP server which handles database interaction. From your backend you can use MongoSwift to connect to a MongoDB deployment.

You could use a web framework such as Vapor to implement the HTTP server. We have an example project available here that uses the driver with Vapor which you could use as a template for writing such a backend.

That said, given you are building an iOS app I agree it is worth exploring what Realm supports as well to figure out what best suits your use case.

1 Like