Skip to content

Commit 7778fc0

Browse files
Add example project.
1 parent 4419e91 commit 7778fc0

10 files changed

Lines changed: 2206 additions & 0 deletions

File tree

Examples/HelloWorld/HelloWorld.xcodeproj/project.pbxproj

Lines changed: 2013 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AppDelegate.h
3+
// HelloWorld
4+
//
5+
// Created by kishikawa katsumi on 2014/01/04.
6+
// Copyright (c) 2014 kishikawa katsumi. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (nonatomic) UIWindow *window;
14+
15+
@end
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// AppDelegate.m
3+
// HelloWorld
4+
//
5+
// Created by kishikawa katsumi on 2014/01/04.
6+
// Copyright (c) 2014 kishikawa katsumi. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
#import "JavaScriptBridge.h"
11+
12+
@implementation AppDelegate
13+
14+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
15+
{
16+
JSContext *context = [JSBScriptingSupport globalContext];
17+
18+
[context evaluateScript:
19+
@"var window = UIWindow.new();"
20+
@"window.frame = UIScreen.mainScreen().bounds;"
21+
@"window.backgroundColor = UIColor.whiteColor();"
22+
@""
23+
@"var navigationController = UINavigationController.new();"
24+
@"var viewController = UIViewController.new();"
25+
@"viewController.navigationItem.title = 'Make UI with JavaScript';"
26+
@""
27+
@"var view = UIView.new();"
28+
@"view.backgroundColor = UIColor.redColor();"
29+
@"view.frame = {x: 20, y: 80, width: 280, height: 80};"
30+
@""
31+
@"var label = UILabel.new();"
32+
@"label.backgroundColor = UIColor.blueColor();"
33+
@"label.textColor = UIColor.whiteColor();"
34+
@"label.text = 'Hello World.';"
35+
@"label.font = UIFont.boldSystemFontOfSize(24);"
36+
@"label.sizeToFit();"
37+
@""
38+
@"var frame = label.frame;"
39+
@"frame.x = 10;"
40+
@"frame.y = 10;"
41+
@"label.frame = frame;"
42+
@""
43+
@"view.addSubview(label);"
44+
@"viewController.view.addSubview(view);"
45+
@""
46+
@"navigationController.viewControllers = [viewController];"
47+
@""
48+
@"window.rootViewController = navigationController;"
49+
@"window.makeKeyAndVisible();"
50+
];
51+
52+
return YES;
53+
}
54+
55+
@end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.kishikawakatsumi.${PRODUCT_NAME:rfc1034identifier}</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>${PRODUCT_NAME}</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1.0</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
</dict>
38+
</plist>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Prefix header
3+
//
4+
// The contents of this file are implicitly included at the beginning of every source file.
5+
//
6+
7+
#import <Availability.h>
8+
9+
#ifndef __IPHONE_3_0
10+
#warning "This project uses features only available in iOS SDK 3.0 and later."
11+
#endif
12+
13+
#ifdef __OBJC__
14+
#import <UIKit/UIKit.h>
15+
#import <Foundation/Foundation.h>
16+
#endif
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "29x29",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "40x40",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "60x60",
16+
"scale" : "2x"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"orientation" : "portrait",
5+
"idiom" : "iphone",
6+
"extent" : "full-screen",
7+
"minimum-system-version" : "7.0",
8+
"scale" : "2x"
9+
},
10+
{
11+
"orientation" : "portrait",
12+
"idiom" : "iphone",
13+
"subtype" : "retina4",
14+
"extent" : "full-screen",
15+
"minimum-system-version" : "7.0",
16+
"scale" : "2x"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Localized versions of Info.plist keys */
2+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// main.m
3+
// HelloWorld
4+
//
5+
// Created by kishikawa katsumi on 2014/01/04.
6+
// Copyright (c) 2014 kishikawa katsumi. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
#import "AppDelegate.h"
12+
13+
int main(int argc, char * argv[])
14+
{
15+
@autoreleasepool {
16+
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17+
}
18+
}

JavaScriptBridge.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)