Skip to content

exis-io/iOSExample

Repository files navigation


Stop writing network code. Seriously.


[Exis + Swift](http://exis.io/swift) is currently the best solution to allow Swift developers to run their code in the cloud. Exis allows developers to write native Swift code, test it locally in Xcode, and launch it in the cloud.

Feel free to checkout other programming languages that Exis supports.

Example

Server-side (cloud) code:

class Backend: RiffleDomain {
    override func onJoin() {
        register("hello", sayHi)
    }

    //Called by user frontend code
    func sayHi(name: String) -> AnyObject {
        print("\(name) says hello! Lets let him know Exis is here to help!")
        return "Hi, \(name)! Exis can hear you loud and clear!"
    }
}

Client-side (local) code:

//Send your request to your Swift backend!
@IBAction func sendRequest(sender: AnyObject) {

    container.call("hello", nameField.text!) { (response: String)  in
        print("There is someone out there!\nResponse: \(response)")
    }

}

Getting started writing Swift in the backend

  • First, download or clone this repo to get your hands on our example project:
    git clone https://github.com/exis-io/iOSExample.git

  • In order to run our Hello World example you will need to head to my.exis.io and create an account.
    After signing up you will follow these easy few steps to see the power of writing your backend in Swift using Exis!

  • Create an app from template 'helloWorldSwift' in your dashboard and leave the Name(Optional) blank

  • Navigate to and open your .xcworkspace in the iOSExample project that you cloned or downloaded

    • You will find all the front end code in ViewController.swift and all your Swift written backend code in Backend/main.swift


    • There should be 2 lines of code in both your frontend and backend code that you are required to replace the X's with your keys and USERNAME with your username that you used during signup process. Follow the inline comments on how to obtains those from your dashboard on my.exis.io
    *Frontend Keys* *Backend Keys*

  • Now, go ahead and run your backend code by setting your current active scheme to backend and clicking run


  • After you have launched your backend running Swift, go ahead and run your main scheme and witness the communication between the two in your output log as well as in your View in the simulator.


  • You may switch between your backend output log and your front end to see the communication between the two!

What now?

Now you have Swift backend code running locally for testing purposes. Want to push to production? Next step is to push your Swift backend code to our cloud and we will host it for you and any of your clients to reach.

If you want to see how to launch your Swift backend code in the cloud, check out our more advanced tutorial, Cards Against Humanity and its step-by-step tutorial page which will show you just how easy it is.

About

Hello, world with Riffle on iOS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •