Automatically generate REST APIs for Core Data models
|Core Data Model||API Endpoints|
Building web services for iOS apps is a constant struggle to coordinating data models. You're probably not running Objective-C on the server, so you're stuck duplicating your business logic--allthewhile doing your best to maintain the correct conventions and idioms for each platform.
Rack::CoreData aims to bridge the client/server divide, and save you time.
Rack::CoreData at your Core Data model file, and a RESTful webservice is automatically created for you, with all of the resource endpoints you might expect in Rails. And since we're running on Rack, each endpoint can be overriden if you need to add or change any existing behavior. Likewise, any of the models can be re-opened to make any necessary adjustments.
Think of it like an API scaffold: while you may throw all of it away eventually, having something to start with will allow you to iterate on the most important parts of your application while you're the most excited about them.
The easiest way to use Rack::CoreData is to deploy to Heroku using the Core Data Buildpack. Just
.xcdatamodelfile to Heroku, and you'll have a REST webservice up and running in a matter of seconds.
source :rubygems gem 'rack-core-data', :require => 'rack/core-data' gem 'thin' gem 'pg'
require 'bundler' Bundler.require # Rack::CoreData requires a Sequel connection to a database DB = Sequel.connect(ENV['DATABASE_URL'] || "postgres://localhost:5432/coredata") run Rack::CoreData('./Example.xcdatamodeld')
An example web API using a Core Data model can be found the
It uses the same data model as the AFIncrementalStore example iOS project, so try running that against Rack::CoreData running on localhost.
Rack::CoreData is available under the MIT license. See the LICENSE file for more info.