LaneKit is an iOS Objective-C code generator for integration with RestKit. It generates models, resource providers, table views, and full iOS apps with mimimal effort. There is support for unit testing with SenTestingKit including fixtures and tests. LaneKit is a command line app written in Ruby and packaged as a Ruby Gem.
- Source code for LaneKit from GitHub.
- Questions? Stack Overflow is the best place to find answers.
- properly implemented models, resource providers, and table views
- easy integration with RestKit
- consistent Objective-C code
- unit tests with OCUnit (SenTestingKit)
- test fixtures in JSON and Objective-C
- iOS app creation fully integrated with CocoaPods and RestKit, and .gitignore file
- tested code
- rapid development
- enhanced productivity of junior developers
- reduces dependency on senior developers
-
Install the LaneKit Ruby Gem from RubyGems.org
$ gem install lanekit Successfully installed lanekit-x.x.x
-
LaneKit is ready to use
$ lanekit generate model Video duration:string headline:string id:integer image:string location:string
create Classes/Models
create Classes/Tests/Fixtures
create Classes/Tests/Models
create Classes/Models/Video.h
create Classes/Models/Video.m
create Classes/Tests/Fixtures/VideoFixtures.h
create Classes/Tests/Fixtures/VideoFixtures.m
create Classes/Tests/Fixtures/VideoFixtures.one.json
create Classes/Tests/Fixtures/VideoFixtures.two.json
create Classes/Tests/Models/VideoTest.h
create Classes/Tests/Models/VideoTest.m
create Classes/Models/LKModel.h
create Classes/Models/LKModel.m
and here is the Objective-C header file that was generated by LaneKit:
//
// Video.h
//
// This model was created on 2013-10-20 by LaneKit v0.3.0.
//
// The following LaneKit command was used to generate this file:
// lanekit generate model Video duration:string headline:string id:integer image:string location:string
//
#import "LKModel.h"
@interface Video : LKModel
@property (nonatomic,strong) NSString *duration;
@property (nonatomic,strong) NSString *headline;
@property (nonatomic,strong) NSNumber *id;
@property (nonatomic,strong) NSString *image;
@property (nonatomic,strong) NSString *location;
@end
and here is the Objective-C .m file that was generated by LaneKit:
//
// Video.m
//
// This model was created on 2013-10-20 by LaneKit v0.3.0.
//
// The following LaneKit command was used to generate this file:
// lanekit generate model Video duration:string headline:string id:integer image:string location:string
//
#import "Video.h"
@implementation Video
// Dictionary to convert self to JSON
+ (NSDictionary *)dictionaryForRequestMappings
{
return @{
// source key path : destination attribute name
@"duration": @"duration",
@"headline": @"headline",
@"id": @"id",
@"image": @"image",
@"location": @"location"
};
}
// Dictionary to convert JSON to self
+ (NSDictionary *)dictionaryForResponseMappings
{
return @{
// source key path : destination attribute name
@"duration": @"duration",
@"headline": @"headline",
@"id": @"id",
@"image": @"image",
@"location": @"location"
};
}
+ (NSString *)keyPath
{
return @"video";
}
@end
and here is the unit test fixtures file that was generated by LaneKit:
//
// VideoFixtures.m
//
// This model fixture was created on 2013-08-11 by LaneKit v0.2.0.
//
#import "VideoFixtures.h"
@implementation VideoFixtures
+ (Video *)one
{
Video *video = Video.new;
video.duration = @"MyString";
video.headline = @"MyString";
video.id = [NSNumber numberWithInteger:1];
video.image = @"MyString";
video.itemDate = NSDate.new;
video.location = @"MyString";
return video;
}
+ (Video *)two
{
Video *video = Video.new;
video.duration = @"MyString";
video.headline = @"MyString";
video.id = [NSNumber numberWithInteger:1];
video.image = @"MyString";
video.itemDate = NSDate.new;
video.location = @"MyString";
return video;
}
@end
and here is the RestKit compatible JSON fixture file that was generated by LaneKit:
{
"video": {
"duration": "MyString",
"headline": "MyString",
"id": "1",
"image": "MyString",
"itemDate": "03/01/2012",
"location": "MyString"
}
}
and here is a unit test that was generated in Models/VideoTest.m by LaneKit:
- (void)testVideoNewOne
{
Video *video = VideoFixtures.one;
STAssertNotNil(video, @"video is nil");
STAssertTrue([video.duration isEqualToString:@"MyString"], @"duration not correct value");
STAssertTrue([video.headline isEqualToString:@"MyString"], @"headline not correct value");
STAssertTrue(video.id.integerValue == [NSNumber numberWithInteger:1].integerValue, @"id not [NSNumber numberWithInteger:1]");
STAssertTrue([video.image isEqualToString:@"MyString"], @"image not correct value");
STAssertNotNil(video.itemDate, @"itemDate is nil");
}
$ lanekit generate model contents contents:array:Video
exist Classes/model
create Classes/model/Contents.h
create Classes/model/Contents.m
$ lanekit generate provider Contents Contents http://scores.espn.go.com/allsports/scorecenter/v2/videos/build?sport=top
create Classes/Controllers
create Classes/Controllers/LKResourceProvider.h
create Classes/Controllers/LKResourceProvider.m
create Classes/Controllers/ContentsProvider.h
create Classes/Controllers/ContentsProvider.m
$ lanekit new SportsFrames
create SportsFrames
create SportsFrames/Podfile
create SportsFrames/lanekit-ios-project.xcworkspace/contents.xcworkspacedata
create SportsFrames/lanekit-ios-project.xcworkspace/xcshareddata/lanekit-ios-project.xccheckout
create SportsFrames/lanekit-ios-project.xcworkspace/xcuserdata/larry.xcuserdatad/UserInterfaceState.xcuserstate
create SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/project.pbxproj
create SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/lanekit-ios-project.xcscheme
create SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/xcschememanagement.plist
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKAppDelegate.h
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKAppDelegate.m
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKDetailViewController.h
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKDetailViewController.m
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKMasterViewController.h
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKMasterViewController.m
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Resources/Base.lproj/Main_iPad.storyboard
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Resources/Base.lproj/Main_iPhone.storyboard
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Resources/Images.xcassets/AppIcon.appiconset/Contents.json
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Resources/en.lproj/InfoPlist.strings
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Supporting Files/lanekit-ios-project-Info.plist
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Supporting Files/lanekit-ios-project-Prefix.pch
create SportsFrames/lanekit-ios-project/lanekit-ios-project/Supporting Files/main.m
create SportsFrames/lanekit-ios-project/lanekit-ios-projectTests/en.lproj/InfoPlist.strings
create SportsFrames/lanekit-ios-project/lanekit-ios-projectTests/lanekit-ios-projectTests-Info.plist
create SportsFrames/lanekit-ios-project/lanekit-ios-projectTests/lanekit-ios-projectTests.m
create SportsFrames/.gitignore
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames/Supporting Files/SportsFrames-Info.plist
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames/Supporting Files/SportsFrames-Prefix.pch
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj/project.pbxproj
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj/project.xcworkspace/contents.xcworkspacedata
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/SportsFrames.xcscheme
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/SportsFrames.xcscheme
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFrames.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/xcschememanagement.plist
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFramesTests
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFramesTests/SportsFramesTests-Info.plist
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames/SportsFramesTests/SportsFramesTests.m
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames.xcworkspace
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames.xcworkspace/contents.xcworkspacedata
rename /Users/larry/Projects/lanekit/SportsFrames/SportsFrames.xcworkspace/xcshareddata/SportsFrames.xccheckout
update /Users/larry/Projects/lanekit/SportsFrames/SportsFrames.xcworkspace/xcshareddata/SportsFrames.xccheckout
update /Users/larry/Projects/lanekit/SportsFrames/Podfile
Installing CocoaPods for RestKit
[in /Users/larry/Projects/lanekit/SportsFrames]
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (1.3.3)
Installing RestKit (0.20.3)
Installing SOCKit (1.1)
Installing TransitionKit (1.1.1)
Generating Pods project
Integrating client project
clean /Users/larry/Projects/lanekit/SportsFrames/SportsFrames.xcworkspace
This will display the Contents model that is a list of videos.
$ lanekit generate tableviewcontroller Contents -r LKFeedCell
create SportsFrames/SportsFrames/Controllers/ContentsViewController.h
create SportsFrames/SportsFrames/Controllers/ContentsViewController.m
create SportsFrames/SportsFrames/Views/LKFeedCell.h
create SportsFrames/SportsFrames/Views/LKFeedCell.m
Add the Urban Airship CocoaPods Pod to the project.
$ lanekit generate pod UrbanAirship-iOS-SDK
Installing UrbanAirship-iOS-SDK (3.0.1)
The SportsFrames app is a fully functional sample app using RestKit created to demonstrate the use of LaneKit in a real world app. It has models and resource providers that are generated from LaneKit. Download the code from GitHub.
LaneKit was created by Larry Aasen.
Follow Larry Aasen on Twitter @LarryAasen.
LaneKit is available under the MIT license. See the LICENSE file for more info.