Skip to content

Andrew-Lees11/PersistentiOSKituraKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kitura 2 Sample App - ToDo List with Database Persistence

Kitura Bird

Travis CI Slack

PersistentiOSKituraKit provides an example of the todo list application iOSSampleKituraKit, which has been connected to a MySQL database. This means that, if the server is restarted, the data will persist inside the database. The server handles all communcation the database, so for technical details and example code on how persistence has been added, view the ToDoServer README .

Quick Start*

  1. Install MySQL

brew install mysql

  1. Start the MySQL server

mysql.server start

  1. Create and configure a database called ToDoDatabase
mysql -uroot -e "CREATE USER 'swift'@'localhost' IDENTIFIED BY 'kuery';"
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS ToDoDatabase;"
mysql -uroot -e "GRANT ALL ON ToDoDatabase.* TO 'swift'@'localhost';"
  1. Create a table called toDoTable in the database
mysql -uroot;
use ToDoDatabase;
CREATE TABLE toDoTable (
    toDo_id INT NOT NULL,
    toDo_title VARCHAR(50),
    toDo_user VARCHAR(50),
    toDo_order INT,
    toDo_completed BOOLEAN,
    toDo_url VARCHAR(50),
    PRIMARY KEY ( toDo_id )
);
  1. Exit MySQL using \q

  2. Ensure Xcode 9 or later is installed.

  3. Clone this repository:

    git clone https://github.com/Andrew-Lees11/PersistentiOSKituraKit.git

  4. Navigate into the ToDoServer folder using:

    cd PersistentiOSKituraKit/ToDoServer/

  5. Run the following commands to compile the code:

    swift build -Xlinker -L/usr/local/lib

  6. Start the server with:

    .build/x86_64-apple-macosx10.10/debug/ToDoServer

Note: This command will start the server and it will listen for new connections forever, so the terminal window will be unable to take new commands while the server is running.

  1. Open new Terminal window and navigate into the KituraiOS folder using:

cd /PersistentiOSKituraKit/KituraiOS

  1. Open the iOS Sample Kitura Buddy.xcodeproj file with:

    open iOSKituraKitSample.xcodeproj

A new Xcode window will open. For more info on the iOS app, click here.

  1. Ensure that the Scheme in Xcode is set to the iOS Application. The Scheme selection is located along the top of the Xcode window next to the Run and Stop buttons. If you don't see a Kitura icon (white and blue) in the box next to the Stop button, click the icon that's there and select the App from the drop down menu.

  2. Make sure an iPhone X is selected in the drop down menu next to the Scheme, not "Generic iOS Device". The iPhone Simulators all have blue icons next to their names. iPad is not supported at this time.

  3. Press the Run button or ⌘+R. The project will build and the simulator will launch the application. Navigate your web browser to the address http://localhost:8080 to see an empty array. This is where ToDos made in the app are stored. As you add or delete elements in the app, this array will change.

*The Kitura component can be run on Linux or macOS. Xcode is not required for running the Kitura server component (Xcode is only required for the iOS component).

  1. You now have a todolist application, running on a simulated iPhone. You can add, delete and edit todo items in the app and then view your changes on the server at localhost:8080. Since there is a database connected, you can restart both the application and the server but any todolist items you have created will persist!

The server is responsible for all database communication and logic so for technical details and code go to the ToDoServer . The server README will descibes the components required for adding persistence and within the application.swift you will find code examples of HTTP requests from the application being converted to SQL queries to the database.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published