Skip to content
Gautam Mittal edited this page Nov 27, 2015 · 23 revisions

Getting Started

There are a lot of neat things you can do with Ringo. Here are some of the API endpoints that will help you get started with harnessing the power of Xcode:

=======

GET /get-secure-tunnel

Get the URL of the ngrok tunnel created by the build server.

Parameters Details
None No body necessary.

Example Request:

curl localhost:3000/get-secure-tunnel

Response:

{"tunnel_url":"http://61329946.ngrok.com"}

=======

POST /build-sandbox

Run Swift code.

Parameters Details
code (required) The Swift code you would like to be executed by the build server.

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"code":"print(2+2);"}' http://localhost:3000/build-sandbox

Response:

4

======

POST /create-project

Create a new Xcode project from a SpriteKit Game, Master Detail Application, Single View Application, Page-based Application, or Tabbed Application template. Returns a unique project ID string which can be used later on to make changes or build the project.

Parameters Details
projectName (required) What would you like to call your project?
template (required) Set to either game, mda, sva, pba, or ta

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"projectName":"TestProject", "template":"game"}' http://localhost:3000/create-project

Response:

{"uid":"K37PLSW5-7SxmTfsSDo"}

======

POST /build-project

Builds projects through Xcode and returns an Appetize simulator URL upon a successful, error-free build. If there is an error in the code, the API will return build errors to aid with debugging.

Parameters Details
id (required) Unique project ID generated returned by /create-project

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K37PLSW5-7SxmTfsSDo"}' http://localhost:3000/build-project

Response:

{
  "simulatorURL":"https://appetize.io/app/q3nc2ccxw35ct0gkm9ucvvmt38",
  "screenOnlyEmbedCode":"<iframe src=\"https://appetize.io/embed/q3nc2ccxw35ct0gkm9ucvvmt38?device=iphone6&scale=75&autoplay=false&orientation=portrait&deviceColor=black&screenOnly=true&xdocMsg=true&osVersion=9.0\" width=\"282px\" height=\"501px\" frameborder=\"0\" scrolling=\"no\"></iframe>",
  "fullDeviceEmbedCode":"<iframe src=\"https://appetize.io/embed/q3nc2ccxw35ct0gkm9ucvvmt38?device=iphone6&scale=75&autoplay=true&orientation=portrait&deviceColor=black&xdocMsg=true&osVersion=9.0\" width=\"312px\" height=\"653px\" frameborder=\"0\" scrolling=\"no\"></iframe>",
  "console":""
}

======

GET /download-project/:id

Download a ZIP file with all of the code for a project.

Parameters Details
id (required) Unique project ID of the project you would like to download

Example Request:

curl localhost:3000/download-project/K37PLSW5-7SxmTfsSDo

Response: A ZIP file with the contents of the project will be returned.

======

POST /upload-project-zip

Upload an existing Xcode project as a ZIP to edit/build with Ringo. Ringo returns a unique project ID for the newly uploaded project.

Parameters Details
file (required) base64-encoded string of the ZIP file

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"file":"...."}' http://localhost:3000/upload-project-zip

Response:

{"id": "K3SJdCHjEPceNZ6q-er"}

=======

POST /clone-git-project

Give a public git repository URL, clone and edit/build the project using Ringo. Ringo returns a unique project ID for the newly uploaded project.

Parameters Details
url (required) url of public git repository

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"url":"https://github.com/JakeLin/ChineseZodiac"}' http://localhost:3000/clone-git-project

Response:

{"uid": "K3SJdCHjEPceNZ6q-er"}

=======

POST /update-project-contents

Saves project files with updated content. Assumes that user has already made a request to /get-project-contents.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.
files (required) An array object of the files and their updated contents

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3SJdCHjEPceNZ6q-er", "files":[{"name": "AppDelegate.swift", "data":"..."}, {"name":"GameScene.swift", "data":"...", ...]}' http://localhost:3000/update-project-contents

Response:

Complete

========

POST /get-project-contents

Returns list of files and their respective contents from the project directory.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ"}' http://localhost:3000/get-project-contents

Response:

[
  {"name":"AppDelegate.swift","data":"..."},
  {"name":"Base.lproj/LaunchScreen.storyboard","data":"..."},
  {"name":"Base.lproj/Main.storyboard","data":"..."},
  {"name":"GameScene.swift","data":"..."},
  {"name":"GameViewController.swift","data":"..."},
  {"name":"Info.plist","data":"..."},
  {"count": 6}
]

=======

POST /add-image-xcasset

Adds a new Xcode image asset to the project asset catalog.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.
assetName (required) Name of the new image asset (used for reference purposes later on within the project code)
file (required) Base64-encoded string of a PNG file

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ", "assetName": "myAwesomeImage", "file":"..."}' http://localhost:3000/add-image-xcasset

Response:

{"Success": "Image xcasset successfully added."}

========

POST /get-image-xcassets

Returns list of image Xcode assets and their respective contents from the project's image asset directory.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ"}' http://localhost:3000/get-image-xcassets

Response:

{"files":
 [
   {"name":"Spaceship.imageset","data":"..."}
 ]
}

=======

POST /add-file

Add a new Swift file to the project directory.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.
fileName (required) Name of the new Swift file that will be added to the project directory

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ", "fileName":"myAwesomeFile"}' http://localhost:3000/add-file

Response:

{"Success": "Successfully added file named myAwesomeFile.swift"}

========

POST /delete-file

Delete a file from the project directory.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.
fileName (required) Name of the file that will be removed from the project directory

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ", "fileName":"myAwesomeFile.swift"}' http://localhost:3000/delete-file

Response:

{"Success": "Successfully deleted file named myAwesomeFile.swift"}

=======

GET /get-project-details/:id

Get project metadata such as name, file count, and asset count.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.

Example Request:

curl localhost:3000/get-project-details/K3gNlOOXu3P9xO80CmJ

Response:

{
 "project":{
    "name":"TestProject",
    "file_count":6,
    "asset_count":2
  }
}

=======

POST /create-ipa

Generate a packaged IPA file (experimental) from an Xcode project.

Parameters Details
id (required) Unique project ID returned when project is initially uploaded, created, or cloned.

Example Request:

curl -H "Content-Type: application/json" -X POST -d '{"id":"K3gNlOOXu3P9xO80CmJ"}' http://localhost:3000/create-ipa

Response:

{
  "raw_ipa_url":"https://61329946.ngrok.com/K3gNlOOXu3P9xO80CmJ/TestProject/TestProject.ipa",
  "signed_dl_url":"itms-services://?action=download-manifest&url=https%3A%2F%2F61329946.ngrok.com%2FK3gNlOOXu3P9xO80CmJ%2FTestProject%2Fmanifest.plist"
}