Enough glue to load a web page from our web server in the iOS simulator. Next challenge is uv_spawn: permission denied.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4519 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-10-15 16:55:25 +00:00
parent 84eaa3e2fd
commit 8bd0027e71
6 changed files with 76 additions and 9 deletions

View File

@ -1,7 +1,14 @@
#include "log.h"
#import <UIKit/UIKit.h>
#import <WebKit/WKWebView.h>
#import <WebKit/WKWebViewConfiguration.h>
#include <libgen.h>
#include <string.h>
void tf_run_thread_start(const char* zip_path);
@interface ViewController : UIViewController
@property(strong, nonatomic) WKWebView* web_view;
@end
@ -12,7 +19,7 @@
[super viewDidLoad];
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
self.web_view = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
[self.web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.tildefriends.net/"]]];
[self.web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:12345/"]]];
[self.view addSubview:self.web_view];
}
@end
@ -35,5 +42,13 @@
int main(int argc, char* argv[])
{
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);
return UIApplicationMain(argc, argv, nil, @"AppDelegate");
}