Straw iOS Service consists of two parts; Service Backend and Service Frontend.
Service Backend is a native implementation of service. And it includes actual service procedures.
Service Frontend is a JavaScript interface of the native implementation of the service in the WebView.
- 🚰 xcode 5.1 or higher
- 🔴 ruby 1.9.3 or higher
- 🍏 node.js 0.8 or higher
🅾️ cocoapods
gem install cocoapods
- 🍮 xctool 0.1.5 or higher (optional)
- 🍹 gulp or 🐗 grunt (optional)
1. Create Cocoa Touch Static Library project with Xcode.
1.2. Change the scheme shared (for ci).
2. Add Straw pod.
pod 'Straw', :git => 'https://github.com/strawjs/straw-ios.git', :tag => 'v0.3.5'3. Implement Service class which confirms to STWService.
#include <Straw/Straw.h>
@interface MYServiceFooBar : NSObject <STWService>
...
@end@implementation MYServiceFooBar
- (NSString *)name {...}
- (BOOL)isBackgroundJob:(NSString *)method {...}
// Service Method
- (void)foo:(NSDictionary *)params withContext:(id<STWServiceCallContext>)context {...}
- (void)bar:(NSDictionary *)params withContext:(id<STWServiceCallContext>)context {...}
@end4. Add tests.
5. Add .podspec.
1. Start JavaScript project.
With npm, gulp (or grunt) and karma (or testem), start an ordinary client-side JavaScript library.
2. Add straw-ios(core) and jQuery dependency.
With bower install straw-ios and jQuery.
bower init
bower install --save jquery
bower install --save straw-ios=https://github.com/strawjs/straw-ios.js
3. Write source and test.
4. Release a tag.