8000 update xcode template project · pythonzz/LuaViewSDK@5006e25 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 5006e25

Browse files
committed
update xcode template project
1 parent 1443b0f commit 5006e25

File tree

5 files changed

+54
-85
lines changed

5 files changed

+54
-85
lines changed

cli/generators/xcode/template/app/AppDelegate.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
//
22
// AppDelegate.h
3-
// Awesome
43
//
54
// Created by lv-cli on 16/1/20.
65
// Copyright © 2016年 juhuasuan. All rights reserved.
76
//
87

98
#import <UIKit/UIKit.h>
109

11-
//#define ENABLE_NETWORK_DEBUG 1
12-
#define ENABLE_LOCAL_DEBUG 1
13-
14-
#if !TARGET_IPHONE_SIMULATOR || ENABLE_NETWORK_DEBUG
15-
#undef ENABLE_LOCAL_DEBUG
16-
#endif
17-
18-
extern NSString * const LVReloadPackageNotification;
19-
2010
@interface AppDelegate : UIResponder <UIApplicationDelegate>
2111

2212
@property (strong, nonatomic) UIWindow *window;

cli/generators/xcode/template/app/AppDelegate.m

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@
77

88
#import "AppDelegate.h"
99
#import "LView.h"
10-
#import "LVPkgManager.h"
11-
12-
NSString * const LVReloadPackageNotification = @"LVReloadPackageNotification";
10+
#import "ViewController.h"
1311

1412
@interface AppDelegate ()
1513

16-
#if ENABLE_NETWORK_DEBUG
17-
@property(nonatomic, copy) NSString *packageURL;
18-
#endif
19-
@property(nonatomic, strong) LView *lv;
20-
2114
@end
2215

2316
@implementation AppDelegate
@@ -29,78 +22,12 @@ - (BOOL)application:(UIApplication *)application
2922
self.window.backgroundColor = [UIColor whiteColor];
3023
[self.window makeKeyAndVisible];
3124

32-
[self rebuildLView];
33-
UIViewController *vc = [UIViewController new];
34-
vc.view = self.lv;
25+
ViewController *vc = [ViewController new];
3526
self.window.rootViewController = vc;
3627

37-
#if ENABLE_NETWORK_DEBUG
38-
self.packageURL = @"";
39-
[self reloadPackage];
40-
#else
41-
[self.lv runFile:@"main.lua"];
42-
#endif
43-
4428
return YES;
4529
}
4630

47-
- (void)rebuildLView {
48-
self.lv = [[LView alloc] initWithFrame:self.window.bounds];
49-
50-
#if ENABLE_LOCAL_DEBUG
51-
[self.lv.bundle addScriptPath:[self lvSourcePath]];
52-
#endif // ENABLE_LOCAL_DEBUG
53-
}
54-
55-
#if ENABLE_NETWORK_DEBUG || ENABLE_LOCAL_DEBUG
56-
57-
/*
58-
* Cmd + r 没有刷新时需要做如下设置:
59-
* simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard
60-
*
61-
* https://github.com/facebook/react-native/issues/306#issuecomment-86834162
62-
*/
63-
- (NSArray<UIKeyCommand *> *)keyCommands {
64-
UIKeyCommand *reloadKeyCommand = [UIKeyCommand
65-
keyCommandWithInput:@"r"
66-
modifierFlags:UIKeyModifierCommand
67-
action:@selector(reloadPackage)];
68-
69-
return @[reloadKeyCommand];
70-
}
71-
72-
- (void)reloadPackage {
73-
[[NSNotificationCenter defaultCenter]
74-
postNotificationName:LVReloadPackageNotification object:nil];
75-
76-
#if ENABLE_NETWORK_DEBUG
77-
78-
[LVUtil download:self.packageURL callback:^(NSData *data) {
79-
if (!data) {
80-
return;
81-
}
82-
83-
NSString *pkgName = @"Main";
84-
[LVPkgManager unpackageData:data packageName:pkgName localMode:NO];
85-
86-
[self rebuildLView];
87-
self.window.rootViewController.view = self.lv;
88-
89-
[self.lv runPackage:@"Main"];
90-
}];
91-
92-
#else
93-
94-
[self rebuildLView];
95-
self.window.rootViewController.view = self.lv;
96-
97-
[self.lv runFile:@"main.lua"];
98-
99-
#endif // ENABLE_NETWORK_DEBUG
100-
}
101-
102-
#endif // ENABLE_NETWORK_DEBUG || ENABLE_LOCAL_DEBUG
103-
10431
+ (NSString *)lvSourcePath {
10532
#if TARGET_IPHONE_SIMULATOR
10633
NSString *filePath = [NSString stringWithUTF8String:__FILE__];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ViewController.h
3+
//
4+
// Created by lv-cli on 16/2/23.
5+
// Copyright © 2016年 juhuasuan. All rights reserved.
6+
//
7+
8+
#import <UIKit/UIKit.h>
9+
#import "LViewController.h"
10+
11+
@interface ViewController : LViewController
12+
13+
@end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ViewController.m
3+
//
4+
// Created by lv-cli on 16/2/23.
5+
// Copyright © 2016年 juhuasuan. All rights reserved.
6+
//
7+
8+
#import "ViewController.h"
9+
#import "AppDelegate.h"
10+
#import "LView.h"
11+
12+
@interface ViewController ()
13+
14+
@end
15+
16+
@implementation ViewController
17+
18+
- (void)willCreateLuaView {
19+
[super willCreateLuaView];
20+
21+
while (self.view.subviews.count) {
22+
UIView* child = self.view.subviews.lastObject;
23+
[child removeFromSuperview];
24+
}
25+
}
26+
27+
- (void)didCreateLuaView:(LView *)view {
28+
[super didCreateLuaView:view];
29+
30+
[view.bundle changeCurrentPath:[AppDelegate lvSourcePath]];
31+
}
32+
33+
@end

cli/generators/xcode/template/xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
3C98A5461C7C5C350001508E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C98A5451C7C5C350001508E /* ViewController.m */; };
1011
3CF0CA7B1C4F520100873E6C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CF0CA7A1C4F520100873E6C /* main.m */; };
1112
3CF0CA7E1C4F520100873E6C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CF0CA7D1C4F520100873E6C /* AppDelegate.m */; };
1213
3CF0CA861C4F520100873E6C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3CF0CA851C4F520100873E6C /* Assets.xcassets */; };
@@ -59,6 +60,8 @@
5960
/* End PBXContainerItemProxy section */
6061

6162
/* Begin PBXFileReference section */
63+
3C98A5441C7C5C350001508E /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
64+
3C98A5451C7C5C350001508E /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
6265
3CF0CA761C4F520100873E6C /* <%= @proj_name %>.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = <%= @proj_name %>.app; sourceTree = BUILT_PRODUCTS_DIR; };
6366
3CF0CA7A1C4F520100873E6C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
6467
3CF0CA7C1C4F520100873E6C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -126,6 +129,8 @@
126129
children = (
127130
3CF0CA7C1C4F520100873E6C /* AppDelegate.h */,
128131
3CF0CA7D1C4F520100873E6C /* AppDelegate.m */,
132+
3C98A5441C7C5C350001508E /* ViewController.h */,
133+
3C98A5451C7C5C350001508E /* ViewController.m */,
129134
3CF0CA851C4F520100873E6C /* Assets.xcassets */,
130135
3CF0CA871C4F520100873E6C /* LaunchScreen.storyboard */,
131136
3CF0CA8A1C4F520100873E6C /* Info.plist */,
@@ -328,6 +333,7 @@
328333
isa = PBXSourcesBuildPhase;
329334
buildActionMask = 2147483647;
330335
files = (
336+
3C98A5461C7C5C350001508E /* ViewController.m in Sources */,
331337
3CF0CA7E1C4F520100873E6C /* AppDelegate.m in Sources */,
332338
3CF0CA7B1C4F520100873E6C /* main.m in Sources */,
333339
);

0 commit comments

Comments
 (0)
0