ObjCMongoDB坏了?我无法让它工作 [英] ObjCMongoDB broken? I can't get it to work

查看:120
本文介绍了ObjCMongoDB坏了?我无法让它工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的信息披露:



我不是一名受过教育的程序员,我的编程经验完全在Javascript和Objective-C中。



所以现在你知道你在处理什么。仔细踩踏。没有突然的动作。






我正在写一个与Mac服务器交谈的iPad应用程序。我想使用MongoDB作为后端,而ObjCMongoDB看起来非常适合,但是我无法使用这里的说明来使用它:

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



我的repro步骤:
$ b


  1. 从gitHub上的主ObjCMongoDB页面,点击在Mac中克隆(我正在使用GitHub for Mac来处理下载)

  2. 从命令行导航到ObjCMongoDB目录并输入:

      git子模块更新

  3. $

      git checkout v0.9.6 

    然后: >


  4. 将mongo-c-driver / src文件夹复制到XCode项目文件夹中


  5. 在XCode中,在Project中创建一个名为ObjCMongoDB的新组并将其选中

  6. 添加 src 文件夹从步骤4移至Projec t,但不是目标。 将项目中 src 的名称更改为 mongo-c-driver

    • bson.c

    • encoding.c

    • numbers.c

    • mongo.c

    • md5.c

    • env.c

    • $ b $在XCode中,再次选择ObjCMongoDB组,并向项目和目标添加以下文件夹,选中为所有添加的文件夹创建组 :
      $ b

      • ObjCMongoDB / BSON

      • ObjCMongoDB / Mongo


      • b
        $ b


        根据分步指南,我应该能够构建&首先,从 MongoConnection + Diagnostics.h

          #import< ObjCMongoDB / ObjCMongoDB.h> 

        此时我没有一个名为 ObjCMongoDB 的Framework,所以这显然会失败。 更令人困惑的是这个漂亮的错误,后面跟着API:

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

        当然似乎期待3个参数...







      所以我很茫然。任何帮助将不胜感激。

      解决方案

      我是ObjCMongoDB的作者。为了解决第一个问题,请更改 #import MongoConnection + Diagnostics.h #importObjCMongoDB.h中的c $ c>行。 (在最后一个版本之后,已经在master中修复了)。

      另一个问题正在发生,因为v0.9.6基于早期版本的Mongo C驱动程序您正在使用的文件,我猜你是从Github的10gen仓库下载或克隆的。



      C驱动程序被设置为子模块,所以当你克隆ObjCMongoDB时,你应该会看到一个空的 mongo-c-driver 文件夹。



      可以运行这个命令:

        git submodule update --init 

      它应该加载正确版本的Mongo C驱动程序(我的fork从v0.9.6开始,但下一个版本将使用正式版本)。



      添加这些版本的。[ch] 文件到你的项目,它应该正确地建立。


      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.

      解决方案

      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.

      这篇关于ObjCMongoDB坏了?我无法让它工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆