mongodb / stitch-ios-sdk

Apache License 2.0
42 stars 25 forks source link

Installing StitchSDK heavily increase app weight #187

Open dariopellegrini opened 5 years ago

dariopellegrini commented 5 years ago

Hello! Wonderful library! I need your help. I'm using only local functionalities of Stitch and I noticed how much space it needs in a project.

Installing StitchSDK using

pod 'StitchSDK', '= 6.0.0'

increases project dimension of 500 MB, which means 170 MB for a single app!

More specifically:

That's because installing StitchSDK needs all these other libraries: Installing MongoMobile (0.1.0) Installing MongoSwift (0.1.0) Installing StitchCore (6.0.0) Installing StitchCoreLocalMongoDBService (6.0.0) Installing StitchCoreRemoteMongoDBService (6.0.0) Installing StitchCoreSDK (6.0.0) Installing StitchRemoteMongoDBService (6.0.0) Installing StitchSDK (6.0.0) Installing mongo-embedded-c-driver (1.13.0-4.0.4) Installing mongo_embedded (4.0.4) <- This is the biggest one Installing mongoc_embedded (4.0.4)

Is there any way to avoid this and decrease this library weight?

Thank you

adamchel commented 5 years ago

Hi @dariopellegrini ,

If you don't need StitchRemoteMongoDBService, you can just install the StitchCore pod which is sufficient for Stitch authentication and calling Stitch functions. StitchRemoteMongoDBService includes both QueryAnywhere the Mobile Sync Beta functionality, which requires the large mongo_embedded library.

Let us know if just importing just StitchCore fixes this for you. If you need to use the remote MongoDB service for QueryAnywhere, not importing the mongo_embedded library is currently not possible, but let us know if it's something that would benefit your application.

dariopellegrini commented 5 years ago

Trying to develop a local only app and reading your documentation here https://docs.mongodb.com/stitch/mongodb/mobile/build-local/, I need StitchLocalMongoDBService, which has mongo_embedded dependency.

Using only StitchCore I can't create a MongoDatabase instance using the following code, cause it gives error on mongoClientFactory.

let appID = Bundle.main.bundleIdentifier ?? "CasualAppID"
        let defaultAppClient = Stitch.defaultAppClient ?? (try! Stitch.initializeDefaultAppClient(
            withClientAppID: appID))
        let databaseName = "MyDatabase"
        let database = try! defaultAppClient.serviceClient(fromFactory: mongoClientFactory).db(databaseName)

As my purpose is to use Mongo as a local storage, without database I can't perform CRUD on collections. Maybe I'm missing something?

adamchel commented 5 years ago

If you’re looking to just have a local store with no remote syncing capabilities, we’d actually recommend checking out Realm Database. Their solution is a bit more lightweight. See https://realm.io/

dariopellegrini commented 5 years ago

Yeah I know about Realm, but Mongo was interesting cause lets developers save document like JSON, with filtering and all the other Mongo features. Maybe Couchbase it's a good solution too. So for the heavy weight of the library no solution for the moment? Maybe it could be a future improvement.

jlichti commented 4 years ago

I'm looking for a lightweight way to watch a single document by id and subscribe to changes and this seemed like a great solution. Proof of concept worked great but increasing our binary size by over 100MB is an issue.

dariopellegrini commented 4 years ago

@jlichti try with Realm or Couchbase. Realm has Rx extensions for that and Couchbase ha a built-in feature to observe changes on database.

https://github.com/RxSwiftCommunity/RxRealm#observing-object-collections

https://docs.couchbase.com/couchbase-lite/2.6/swift.html#live-query