3

I'm making an application on xcode 8.3.3 and am using swift to make the app. We have a hosted postgres database which is up and running but I don't know how to connect to it through swift and xcode. I have a host, port number, username and password but I don't know how to connect to the database so I can get the data. I'm a newbie to xcode, swift and basically programming in general please help.

vsarunhah
  • 125
  • 2
  • 8

1 Answers1

4

A simple google search would yield tremondous results.

http://druware.tumblr.com/post/112163075395/getting-started-with-pgsqlkit-and-swift

I believe the above link should get you sorted.

Basically you have to use the C API libpq library.

See also: https://github.com/stepanhruda/PostgreSQL-Swift

David
  • 1,192
  • 5
  • 13
  • 30
  • Hey, thanks but how do import the code from [link] (http://www.druware.com/pgsqltouch/) as a .framework file? – vsarunhah Jun 21 '17 at 09:17
  • @vsarunhah see: https://help.apple.com/xcode/mac/8.0/#//apple_ref/doc/uid/TP40010155-CH17-SW1 and also: https://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4?rq=1 – David Jun 21 '17 at 09:20
  • Sorry but there's another problem. The apple link isn't opening and the stackoverflow link helps but the problem is that the code isn't downloadable as a framework nor is it possible to copy it into a cocoa touch framework because it requires you to import "GenDBConnection" which currently doesn't exist. Can you help me with that? @David Farrugia – vsarunhah Jun 21 '17 at 09:39