Skip navigation
This discussion is archived

Installing 3rd party libraries - sqlite

1286 Views 6 Replies Latest reply: Jul 25, 2008 4:25 PM by tazz_ben RSS
whafrog Calculating status...
Currently Being Moderated
Jul 22, 2008 4:24 PM
Hi, serious newbie question...I'm coming from the Java world (Eclipse) where you just take a 3rd party .jar file and put it in your development environment/project's classpath. Then you have reference to all the classes.

How do I install a third-party library in XCode to achieve the same thing? Specifically, I want to use SQLite in my iPhone app.

Thanks!

Jon
iMac 20in. (Intel 2GHz), Mac OS X (10.5.3)
  • robhedin Calculating status...
    Currently Being Moderated
    Jul 22, 2008 4:46 PM (in response to whafrog)
    Well, the easy way to use SQLite, is to just use it-- it's built into the iPhone no need for external libraries.

    rob.
    Macbook Pro 2.33, Mac OS X (10.5.2)
  • tazz_ben Calculating status...
    Currently Being Moderated
    Jul 22, 2008 4:53 PM (in response to whafrog)
    Hey Jon -

    First for the class you need to have:

    #import <sqlite3.h>

    Also make sure in the frameworks folder to add:

    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/li bsqlite3.0.dylib

    Other thing --- Conserve your connections to SQLite. I don't know why, but it seems that when you finalize and close a connection, all of the resources for sqlite3_step aren't released (even though it isn't reported as a leak, you can see your object allocation go up). So while it may seem like a plan to close the DB on a memory warning, it's better to keep it open for the life of the app.
    iMac (intel), Mac OS X (10.4.6)
  • David Dennis Level 1 Level 1 (45 points)
    Currently Being Moderated
    Jul 24, 2008 6:05 PM (in response to tazz_ben)
    I'm having this same problem you mention with sqlite3_finalize not freeing up all the resources used by a query. It's driving me nuts because it seems to be consistently filling up my memory in exactly the way you describe, and of course that eventually causes my iPhone application to crash .

    Do you have any details on how to fix this, or how to deal with it better? It's really messing up my memory allocation big-time .

    Thanks!

    D
    MacBook Pro 2.4ghz; iPhone with version 2.0 software, Mac OS X (10.5.4)
  • admanimal Level 1 Level 1 (90 points)
    Currently Being Moderated
    Jul 24, 2008 6:17 PM (in response to David Dennis)
    Are you following the example set by the SQLiteBooks sample? You should only prepare and finalize frequently used queries once per app lifetime, and just reset them after each use.
  • tazz_ben Level 1 Level 1 (30 points)
    Currently Being Moderated
    Jul 25, 2008 4:25 PM (in response to David Dennis)
    Yeah, David, like the other responder I reduced my connections to 3. Though I disagree with him that this is the way it's suppose to be. I really wish this was fixed. In a mobile app, it makes a lot of sense to be opening and closing the database depending on the memory condition.
    iMac (intel), Mac OS X (10.5.4)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.