-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathmain.m
67 lines (55 loc) · 1.91 KB
/
main.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
//
// Any changes in this file will be removed after you update your platform!
//
#import <UIKit/UIKit.h>
#import <NativeScript/NativeScript.h>
#ifdef DEBUG
#include <notify.h>
#include <TKLiveSync/TKLiveSync.h>
#include "macros.h"
#endif
#if NS_SWIFTUI_BOOT == 0
// Users can disable Obj-C bootstrapping by defining NS_SWIFTUI_BOOT = 1 in their project's build.xcconfig file
// This requires a NativeScriptApp.swift to be setup in the project and embedding enabled in @nativescript/core bootstrap
extern char startOfMetadataSection __asm("section$start$__DATA$__TNSMetadata");
NativeScript* nativescript;
int main(int argc, char *argv[]) {
@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 = [nativescript 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;
nativescript = [[NativeScript alloc] initWithConfig:config];
[nativescript runMainApplication];
return 0;
}
}
#endif