2023-10-15 12:55:25 -04:00
|
|
|
#include "log.h"
|
|
|
|
|
2023-10-13 21:37:34 -04:00
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <WebKit/WKWebView.h>
|
|
|
|
#import <WebKit/WKWebViewConfiguration.h>
|
|
|
|
|
2023-10-15 12:55:25 -04:00
|
|
|
#include <libgen.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
void tf_run_thread_start(const char* zip_path);
|
|
|
|
|
2023-10-13 21:37:34 -04:00
|
|
|
@interface ViewController : UIViewController
|
|
|
|
@property(strong, nonatomic) WKWebView* web_view;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ViewController
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
|
|
|
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
|
|
|
|
self.web_view = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
|
2023-10-15 12:55:25 -04:00
|
|
|
[self.web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:12345/"]]];
|
2023-10-13 21:37:34 -04:00
|
|
|
[self.view addSubview:self.web_view];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface AppDelegate : UIResponder<UIApplicationDelegate>
|
|
|
|
@property(strong, nonatomic) UIWindow* window;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
- (BOOL)application:(UIApplication*)application
|
|
|
|
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
|
|
|
|
{
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
|
ViewController* view_controller = [[ViewController alloc] init];
|
|
|
|
self.window.rootViewController = view_controller;
|
|
|
|
[self.window makeKeyAndVisible];
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2023-10-15 12:55:25 -04:00
|
|
|
NSFileManager* file_manager = [NSFileManager defaultManager];
|
|
|
|
NSString* library_directory = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
|
|
|
[file_manager changeCurrentDirectoryPath:library_directory];
|
|
|
|
size_t path_length = strlen(argv[0]) - strlen(basename(argv[0]));
|
|
|
|
size_t length = path_length + strlen("data.zip");
|
|
|
|
char* zip_path = alloca(length + 1);
|
|
|
|
snprintf(zip_path, length + 1, "%.*sdata.zip", (int)path_length, argv[0]);
|
|
|
|
tf_run_thread_start(zip_path);
|
2023-10-13 21:37:34 -04:00
|
|
|
return UIApplicationMain(argc, argv, nil, @"AppDelegate");
|
|
|
|
}
|