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

Hi Kaitlin, I’ve seen the sample projects but unfortunately they’re just the back-end part of the Mongo integration, I meant something like a video tutorial step by step about creating a sample Swift app using Vapor as middle layer if possible and connected to MongoDB Atlas, all configured starting by zero, for me that I never handled back-end and that i have always used Firebase which implementation is very easy and with no extra layers needed, its very difficult to understand all the connection part, I don’t mind about the mongo queries themselves cause that its just a matter of practice and there’s a rich and clear documentation about that I just mean a sample Swift app that writes and read sample data from Mongo DB Atlas. In case you can put me In contact with some expert (even if asks me money to teach me), id be very grateful, thanks!