How to add the sqlite3 framework to project

Discussion in 'iOS Programming' started by tutiplain, Apr 21, 2011.

  1. macrumors member

    Joined:
    Feb 4, 2011
    #1
    Hi all,

    Here's a simple question, though I can't seem to figure it out on my own. I am trying to use sqlite on my app. I have #imported the sqlite3.h header file. But when I compile, I get a few warnings and the program does not compile:

    Code:
    Ld /Users/ocampos/Library/Developer/Xcode/DerivedData/SueldoCalc-erlcpmxwibxgvoewahrcnyaigkot/Build/Products/Debug-iphonesimulator/SueldoCalc.app/SueldoCalc normal i386
        cd /Users/ocampos/Documents/SueldoCalc
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/ocampos/Library/Developer/Xcode/DerivedData/SueldoCalc-erlcpmxwibxgvoewahrcnyaigkot/Build/Products/Debug-iphonesimulator "-L/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib" -F/Users/ocampos/Library/Developer/Xcode/DerivedData/SueldoCalc-erlcpmxwibxgvoewahrcnyaigkot/Build/Products/Debug-iphonesimulator -filelist /Users/ocampos/Library/Developer/Xcode/DerivedData/SueldoCalc-erlcpmxwibxgvoewahrcnyaigkot/Build/Intermediates/SueldoCalc.build/Debug-iphonesimulator/SueldoCalc.build/Objects-normal/i386/SueldoCalc.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -lsqlite3.0 -o /Users/ocampos/Library/Developer/Xcode/DerivedData/SueldoCalc-erlcpmxwibxgvoewahrcnyaigkot/Build/Products/Debug-iphonesimulator/SueldoCalc.app/SueldoCalc
    
    ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/libsqlite3.0.dylib, missing required architecture i386 in file
    ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/libSystem.dylib, missing required architecture i386 in file
    ld: in /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/libobjc.A.dylib, missing required architecture i386 in file for architecture i386
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
    
    
    I read in a tutorial that I need to add a reference to a file called libsqlite3.0.dylib, via de "Add Existing Frameworks" option, but the tutorial is old and I can't this option in Xcode 4. Can someone help me correct this? Any info will be greatly appreciated, as always.
     
  2. macrumors regular

    Joined:
    Sep 11, 2008
  3. dejo, Apr 22, 2011
    Last edited: Apr 22, 2011

    Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
  4. macrumors regular

    Joined:
    Sep 11, 2008
    #4
    Oh, my bad!

    I was sure the old way was when we had to manually navigate to the propper SDK and its folder on disk.
     
  5. thread starter macrumors member

    Joined:
    Feb 4, 2011
    #5
    HI,

    A Google search showed me how to do it. You click on project name in the Project Explorer, then click on Build Phases, then the + button.
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Are you saying you posted here first, ignored the responses and just found a solution through Google anyways? Not nice.

    Which + button? There are three on the screen when you get to the point of adding the framework. If you're going to explain the solution to your issue, you should please be so kind to be specific enough that others readers can follow it as well.
     
  7. thread starter macrumors member

    Joined:
    Feb 4, 2011
    #7
    Please don't take it that way, but if you look at the responses I got, one was apparently for XCode 3, which was not what I was looking for, and the other reply was not very helpful, although I did not see you had posted a link below yours until now. This does not mean that I am not grateful for the responses. It was in fact the first response which gave me idea on how to look for it in Google.

    Still, I see your point, dejo. From now on, I will try to be more thorough when in doubt, lest I not ask something and then find a solution elsewhere. I'm sorry, and I apologize, to you, and the other repliers.

    I am not on my Mac right now, but I'll post a screenshot later showing where the option is.
     
  8. thread starter macrumors member

    Joined:
    Feb 4, 2011
    #8
    Hi again, everyone.

    As promised here's a screenshot of where the sqlite framework can be added to your project. As you can see, you first click on your project name on the Project Explorer (left side of the attached picture). This causes the middle pane switch to a tabbed interface with the labels, Summary, Info, Build Settings, Build Phases and Build Rules. You click on Build Phases and you are presented with a screen similar to the attached screenshot. Next click on the gray arrow besides "Link Binary with Libraries" to expand it. Listed, you should see the default frameworks, namely UIKit, Foundation and CoreGraphics. Next you click on the + sign below CoreGraphics (might be different on your system or project, I believe). This will bring down a list of frameworks and libraries you can add. On the top there is a spotlight icon, and a text field, type "libsqlite.0.dylib" there, and it should pop up on the list. Select it and press "Add". Now sqlite should appear on your list of frameworks, as well as the Project Explorer on the left. You should now be able to use the sqlite3 functions in your code.

    One thing no one commented on was the errors and warnings I was getting. I still don't know what they were, but they started appearing after I attempted to add libsqlite as a resource (before figuring out the correct way to do it). I had to reinstall Xcode to make them go away. Anyway, I hope this info might of help to someone else :)
     
  9. macrumors newbie

    Joined:
    Nov 5, 2011
    #9
    One more thing...

    tutiplain, your comment of Apr 24, 2011 08:19 PM was incredibly helpful. You have saved me many hours of work, thank you.

    I was able to eliminate my errors by simply quitting and re-opening Xcode. This may save the next hapless sap some time. I'm in Xcode 4.1 with iOS 4.3 as my target.
     
  10. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #10
    You could also press Command+Shift+K, which does a clean, and try rebuilding, with command shift B, if that doesn't fix it, then theres probably something wrong.
     
  11. macrumors newbie

    Joined:
    Jul 7, 2013
    #11
    The instructions are very good and helpful. The screenshot was missing. I clicked on the project name under "Targets" in the Project Explorer and it worked perfectly. Regards, Gloria
     
  12. macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #12
    I'd advise against mentioning times, particularly without a timezone, on the internet... tutiplain made no comment at that time in my timezone. I suggest using the "quote" button or giving a link to the post you're referring to.
     

Share This Page