-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathNativeScriptStart.m
73 lines (58 loc) · 1.97 KB
/
NativeScriptStart.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// NativeScriptStart.m
//
// Created by Team nStudio on 7/5/23.
// Copyright © 2023 NativeScript. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <NativeScript/NativeScript.h>
#import <NativeScriptStart.h>
#ifdef DEBUG
#include <notify.h>
#include <TKLiveSync/TKLiveSync.h>
#include "macros.h"
#endif
extern char startOfMetadataSection __asm("section$start$__DATA$__TNSMetadata");
NativeScript* nativescriptStart;
@implementation NativeScriptStart
+(void)setup{
@autoreleasepool {
NSString* baseDir = [[NSBundle mainBundle] resourcePath];
#ifdef DEBUG
int refreshRequestSubscription;
notify_register_dispatch(NOTIFICATION("RefreshRequest"), &refreshRequestSubscription, dispatch_get_main_queue(), ^(int token) {
notify_post(NOTIFICATION("AppRefreshStarted"));
bool success = [nativescriptStart liveSync];
if (success) {
notify_post(NOTIFICATION("AppRefreshSucceeded"));
} else {
NSLog(@"__onLiveSync call failed");
notify_post(NOTIFICATION("AppRefreshFailed"));
}
});
TNSInitializeLiveSync();
if (getenv("TNSBaseDir")) {
baseDir = @(getenv("TNSBaseDir"));
}
#endif
void* metadataPtr = &startOfMetadataSection;
bool isDebug =
#ifdef DEBUG
true;
#else
false;
#endif
Config* config = [[Config alloc] init];
config.IsDebug = isDebug;
config.LogToSystemConsole = isDebug;
config.MetadataPtr = metadataPtr;
config.BaseDir = baseDir;
// config.ArgumentsCount = argc;
// config.Arguments = argv;
nativescriptStart = [[NativeScript alloc] initWithConfig:config];
}
}
+(void)boot{
[nativescriptStart runMainApplication];
}
@end