These are the exact steps needed to take to create an syncing client-server app in 3 minutes. Watch this video for a complete demo. You will need to have CocoaPods Installed on your machine.
- Install CocoaPods
- Create New Project with AFNetworking Xcode Template
- Close current project.
cd
toPROJECTNAME
directory then - Run
pod install
- Run
open PROJECTNAME.xcworkspace
- Create
ENTITYNAME
inPROJECTNAME.xcdatamodeld
file - Run
git commit -a -m "first commit"
- Run
heroku create --buildpack git://github.com/mattt/heroku-buildpack-core-data.git
- Run
git push heroku master
- Copy random-name-here.herokuapp.com url from terminal, set
kAPIBaseURLString
inPROJECTNAMEAPIClient.m
to random-name-here.herokuapp.com url. - Add SDScaffoldKit to project. Then add
#import "SDScaffoldKit.h"
toPROJECTNAME-Prefix.pch
- Create
SDScaffoldIndexViewController
instance and set it to therootViewController
of the mainnavigationController
. - App Delegate should look like this:
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:8 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
[NSURLCache setSharedURLCache:URLCache];
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
SDScaffoldIndexViewController *scaffoldViewController = [[SDScaffoldIndexViewController alloc]
initWithEntityName:@"ENTITYNAME" sortBy:@"PROPERTY" context:self.managedObjectContext];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:scaffoldViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
- open http://kAPIBaseURLString/MODELNAMEs in your browser i.e. http://sleepy-eyrie-2619.herokuapp.com/runs
- Run Xcode applciation
- Follow @stevederico on twitter, tell me what you think. Thank @mattt for the wonderful AFNetworking & AFIncrementalStore.
Common Errors
- Don't forget to change the build target from Pods. Click Pods next to the Stop button and change to PROJECTNAME, then build and Run.
LEGEND
- PROJECTNAME - Full name of the Project i.e. "RunnerLog"
- ENTITYNAME - Core Data Model Entity Name i.e. "Run"
- PROPERTY - An attribute of the new Entity i.e "summary"
- random-name-here.herokuapp.com url - Heroku webserver url i.e. http://sleepy-eyrie-2619.herokuapp.com