Question

Full Disclosure:

I'm not an educated programmer, and the entirety of my programming experience is in Javascript and Objective-C.

So now you know what you're dealing with. Tread carefully. No sudden moves.


I'm writing an iPad app which talks to a Mac server. I'd like to use MongoDB for the backend, and ObjCMongoDB looks like the perfect fit, but I can't get it to work using the instructions here:

https://github.com/noa--/ObjCMongoDB/wiki/GettingStarted

My repro steps:

  1. From the main ObjCMongoDB page on gitHub, click "Clone in Mac" (I'm using GitHub for Mac to handle the download)

  2. From the command line, navigate to the ObjCMongoDB directory and type:

    git submodule update
    
  3. Then:

    git checkout v0.9.6
    
  4. copy the mongo-c-driver/src folder into the XCode Project folder

  5. In XCode, make a new group in the Project called "ObjCMongoDB" and select it

  6. Add the src folder from step 4 to the Project, but not to the target.

  7. Change the name of src in the Project to mongo-c-driver

  8. Add these files in mongo-c-driver to the target:

    • bson.c
    • encoding.c
    • numbers.c
    • mongo.c
    • md5.c
    • env.c

  9. In XCode, select the ObjCMongoDB group again, and add to both the project and the target the following folders, checking "Create groups for any added folders":

    • ObjCMongoDB/BSON
    • ObjCMongoDB/Mongo
    • ObjCMongoDB/OrderedDictionary

According to the step-by-step guide, I should be able to build & run my project now, but there are errors.

  • First, from MongoConnection+Diagnostics.h:

    #import <ObjCMongoDB/ObjCMongoDB.h>
    

    I don't have a Framework called ObjCMongoDB at this point, so this will obviously fail.

  • Even more confusing is this nifty error, followed by the API in question:

    int bson_init_finished_data( bson *b, char *data, bson_bool_t ownsData ) {
        _bson_zero( b );
        b->data = data;
        b->dataSize = bson_finished_data_size( data );
        b->ownsData = ownsData;
        b->finished = 1;
        return BSON_OK;
    }
    

    Certainly seems to expect 3 arguments...


So I'm at a loss. Any help would be greatly appreciated.

Was it helpful?

Solution

I'm the author of ObjCMongoDB. Thanks for your interest in the library and the heads-up about your question.

To fix the first problem, change the #import line in MongoConnection+Diagnostics.h to #import "ObjCMongoDB.h". (That's been fixed in master, subsequent to the last release.)

The other problem is happening because v0.9.6 is based on an earlier version of the Mongo C driver than the files you're using, which I'm guessing you downloaded or cloned yourself from the 10gen repository on Github.

The C driver is set up as a submodule, so when you clone ObjCMongoDB you should see an empty mongo-c-driver folder.

From your repository root, you can run this command:

git submodule update --init

which should load the correct version of Mongo C driver (my fork as of v0.9.6, but the next release will use the official version). I'm adding a note to the readme about this step.

Once you add those versions of the .[ch] files to your project instead, it should build correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top