Im making a iOS app and have to connect to a PostgreSQL database without web service (connect directly with the database). I started my journey from here: How to connect to postgresql from ios9
Simply, it says to follow this steps:
- Go find a libpq.framework.
- You have to create a C type file(because libpq is not Obj-c.) as C API to connect libpq.
- After that create a Bridging-Header to connect it.(It Bridging will not generate its own)
- Back to the C type file you created
- Follow this "PostgreSQL C Language API" tutorial this tutorial saved me a lot of time .(C has been a very far away from me.)
- If need, go to Build Settings >> Enable Bitcode >> YES
- Make sure test it on the device.
And finally, leads to this project on GitHub witch I tried to follow, but Im stuck on this error "ld: framework not found libpq"
This is what I already have done trying to make it work:
- Download the entire project from GitHub
- Copy the "libpq.framework" from inside the downloaded project to "MyProject/Contents/Framework/"
- Copy "testPostgreSqlAPI.c" and "testPostgreSqlAPI.h" to my project in Xcode (Xcode made the "myProject-Bridging-Header.h" automatically)
- Added the "libpq.framework" on "Linked Frameworks and Libraries" in the General tab on Xcode
- Edited the Headers Search Path in the Build Settings tab to "$(PROJECT_DIR)/Contents/Frameworks/libpq.framework/Versions/A/Headers"
- Edited the Library Search Path in the Build Settings tab to "$(PROJECT_DIR) recursive"
- And for last, copy the "libpq.framework" to /Library/Frameworks/
After all of this, my app don't show any erro in Xcode before try to build, but when I try to build I get the error ": Linker command failed with exit code 1 (use -v to see invocation)", and in the log show the error "ld: framework not found libpq"
PS
This is my first iOS app, and my first time using Mac OS, so Im probably doing a lot of things wrong, and Im looking for any help in this context, like "Is really necessary copy the 'libpq.framework' to /Library/Frameworks/ or this ridiculous?"