luboslenco преди 1 месец
родител
ревизия
2ad30883bb

+ 0 - 1
base/project.js

@@ -191,7 +191,6 @@ if (!flags.lite) {
 		add_thread_backend("apple");
 		add_gpu_backend("metal");
 		project.add_cfiles("sources/backends/data/ios.plist");
-		project.add_cfiles("sources/backends/data/LaunchScreen.storyboard");
 		project.add_cfiles("sources/backends/ios_file_dialog.m");
 		project.add_define("IRON_METAL");
 	}

+ 0 - 27
base/sources/backends/data/LaunchScreen.storyboard

@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
-    <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <scenes>
-        <!--View Controller-->
-        <scene sceneID="EHf-IW-A2E">
-            <objects>
-                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="qVO-8e-Oj3"/>
-                        <viewControllerLayoutGuide type="bottom" id="Y9C-1R-Fay"/>
-                    </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" red="0" green="0" blue="0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                    </view>
-                </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="53" y="375"/>
-        </scene>
-    </scenes>
-</document>

+ 23 - 3
base/sources/backends/data/ios.plist

@@ -26,11 +26,9 @@
 	<true/>
 	<key>UIFileSharingEnabled</key>
 	<true/>
-	<key>UILaunchStoryboardName</key>
-	<string>LaunchScreen</string>
 	<key>UIRequiredDeviceCapabilities</key>
 	<array>
-		<string>armv7</string>
+		<string>arm64</string>
 	</array>
 	<key>UIStatusBarHidden</key>
 	<true/>
@@ -49,5 +47,27 @@
 	</array>
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<false/>
+	<key>UIApplicationSceneManifest</key>
+	<dict>
+		<key>UIApplicationSupportsMultipleScenes</key>
+		<false/>
+		<key>UISceneConfigurations</key>
+		<dict>
+			<key>UIWindowSceneSessionRoleApplication</key>
+			<array>
+				<dict>
+					<key>UISceneConfigurationName</key>
+					<string>Default Configuration</string>
+					<key>UISceneDelegateClassName</key>
+					<string>IronSceneDelegate</string>
+				</dict>
+			</array>
+		</dict>
+	</dict>
+	<key>UILaunchScreen</key>
+	<dict>
+		<key>UIColorName</key>
+        <string>Black</string>
+	</dict>
 </dict>
 </plist>

+ 3 - 3
base/sources/backends/ios_file_dialog.m

@@ -3,11 +3,11 @@
 #import <UIKit/UIKit.h>
 
 void IOSFileDialogOpen() {
-	UIViewController<UIDocumentPickerDelegate> *glViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
+	UIViewController<UIDocumentPickerDelegate> *myViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
 	UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeOpen];
-	documentPicker.delegate = glViewController;
+	documentPicker.delegate = myViewController;
 	documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
-	[glViewController presentViewController:documentPicker animated:YES completion:nil];
+	[myViewController presentViewController:documentPicker animated:YES completion:nil];
 }
 
 wchar_t* IOSFileDialogSave() {

+ 8 - 22
base/sources/backends/ios_system.h

@@ -4,9 +4,7 @@
 #import <QuartzCore/CAMetalLayer.h>
 #import <CoreMotion/CMMotionManager.h>
 
-struct gpu_texture;
-
-@interface GLView : UIView <UIKeyInput> {
+@interface MyView : UIView <UIKeyInput> {
 @private
 	id<MTLDevice> device;
 	id<MTLCommandQueue> commandQueue;
@@ -15,12 +13,10 @@ struct gpu_texture;
 	id<CAMetalDrawable> drawable;
 	id<MTLLibrary> library;
 	MTLRenderPassDescriptor *renderPassDescriptor;
-
 	CMMotionManager *motionManager;
 	bool hasAccelerometer;
 	float lastAccelerometerX, lastAccelerometerY, lastAccelerometerZ;
 }
-
 - (void)begin;
 - (void)end;
 - (void)showKeyboard;
@@ -28,28 +24,18 @@ struct gpu_texture;
 - (CAMetalLayer *)metalLayer;
 - (id<MTLDevice>)metalDevice;
 - (id<MTLCommandQueue>)metalQueue;
-
+- (BOOL)hasText;
+- (void)insertText:(NSString *)text;
+- (void)deleteBackward;
 @end
 
-@interface GLViewController : UIViewController <UIDocumentPickerDelegate, UIDropInteractionDelegate> {
-@private
-}
-
+@interface MyViewController : UIViewController <UIDocumentPickerDelegate, UIDropInteractionDelegate> {}
 - (void)loadView;
-
 - (void)setVisible:(BOOL)value;
-
-@end
-
-@class GLView;
-
-@interface IronAppDelegate : NSObject <UIApplicationDelegate> {
-}
-
+- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures;
 @end
 
-@interface Motion : NSObject <UIAccelerometerDelegate> {
-
-}
 
+@interface IronSceneDelegate : UIResponder <UIWindowSceneDelegate> {}
+@property (strong, nonatomic) UIWindow *window;
 @end

+ 130 - 225
base/sources/backends/ios_system.m

@@ -1,34 +1,42 @@
 #include "ios_system.h"
+#include <wchar.h>
 #include <iron_gpu.h>
 #include <iron_system.h>
-#import <Foundation/Foundation.h>
 #include <iron_math.h>
 #include <objc/runtime.h>
-#import <AVFAudio/AVFAudio.h>
-#include <wchar.h>
-#import <UIKit/UIKit.h>
-#include <iron_video.h>
-#import <AudioToolbox/AudioToolbox.h>
 #include <mach/mach_time.h>
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+#define touchmaxcount 20
 
-static const int touchmaxcount = 20;
+extern char mobile_title[1024];
 static void *touches[touchmaxcount];
+static int backing_width;
+static int backing_height;
+static bool shift_down = false;
+static bool visible;
+static MyView *myView;
+static MyViewController *myViewController;
+static bool keyboard_shown = false;
+static char language[3];
+static char sysid[512];
+static const char *video_formats[] = {"mp4", NULL};
+static void (*resize_callback)(int x, int y, void *data) = NULL;
+static void *resize_callback_data = NULL;
 
-static void initTouches(void) {
-	for (int i = 0; i < touchmaxcount; ++i) {
-		touches[i] = NULL;
-	}
-}
+void iron_internal_call_resize_callback(int width, int height);
 
-static int getTouchIndex(void *touch) {
+static int get_touch_index(void *touch) {
 	for (int i = 0; i < touchmaxcount; ++i) {
-		if (touches[i] == touch)
+		if (touches[i] == touch) {
 			return i;
+		}
 	}
 	return -1;
 }
 
-static int addTouch(void *touch) {
+static int add_touch(void *touch) {
 	for (int i = 0; i < touchmaxcount; ++i) {
 		if (touches[i] == NULL) {
 			touches[i] = touch;
@@ -38,7 +46,7 @@ static int addTouch(void *touch) {
 	return -1;
 }
 
-static int removeTouch(void *touch) {
+static int remove_touch(void *touch) {
 	for (int i = 0; i < touchmaxcount; ++i) {
 		if (touches[i] == touch) {
 			touches[i] = NULL;
@@ -48,17 +56,15 @@ static int removeTouch(void *touch) {
 	return -1;
 }
 
-static GLint backingWidth, backingHeight;
-
 int iron_window_width() {
-	return backingWidth;
+	return backing_width;
 }
 
 int iron_window_height() {
-	return backingHeight;
+	return backing_height;
 }
 
-@implementation GLView
+@implementation MyView
 
 + (Class)layerClass {
 	return [CAMetalLayer class];
@@ -68,62 +74,52 @@ int iron_window_height() {
 	CGPoint point = [recognizer locationInView:self];
 	float x = point.x * self.contentScaleFactor;
 	float y = point.y * self.contentScaleFactor;
-	// Pencil hover
-	iron_internal_pen_trigger_move(x, y, 0.0);
+	iron_internal_pen_trigger_move(x, y, 0.0); // Pencil hover
 }
 
 - (id)initWithFrame:(CGRect)frame {
 	self = [super initWithFrame:(CGRect)frame];
 	self.contentScaleFactor = [UIScreen mainScreen].scale;
+	backing_width = frame.size.width * self.contentScaleFactor;
+	backing_height = frame.size.height * self.contentScaleFactor;
 
-	backingWidth = frame.size.width * self.contentScaleFactor;
-	backingHeight = frame.size.height * self.contentScaleFactor;
-
-	initTouches();
+	for (int i = 0; i < touchmaxcount; ++i) {
+		touches[i] = NULL;
+	}
 
 	device = MTLCreateSystemDefaultDevice();
 	commandQueue = [device newCommandQueue];
 	library = [device newDefaultLibrary];
 
 	CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer;
-
 	metalLayer.device = device;
 	metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
 	metalLayer.framebufferOnly = YES;
-	// metalLayer.presentsWithTransaction = YES;
-
 	metalLayer.opaque = YES;
 	metalLayer.backgroundColor = nil;
 
 	[self addGestureRecognizer:[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hoverGesture:)]];
-
 	return self;
 }
 
-- (void)begin {
-}
-
-- (void)end {
-}
-
-void iron_internal_call_resize_callback(int width, int height);
+- (void)begin {}
+- (void)end {}
+- (void)dealloc {}
 
 - (void)layoutSubviews {
-	backingWidth = self.frame.size.width * self.contentScaleFactor;
-	backingHeight = self.frame.size.height * self.contentScaleFactor;
+	backing_width = self.frame.size.width * self.contentScaleFactor;
+	backing_height = self.frame.size.height * self.contentScaleFactor;
 
-	gpu_resize();
-	iron_internal_call_resize_callback(backingWidth, backingHeight);
-}
-
-- (void)dealloc {
+	gpu_resize(backing_width, backing_height);
+	iron_internal_call_resize_callback(backing_width, backing_height);
 }
 
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 	for (UITouch *touch in touches) {
-		int index = getTouchIndex((__bridge void *)touch);
-		if (index == -1)
-			index = addTouch((__bridge void *)touch);
+		int index = get_touch_index((__bridge void *)touch);
+		if (index == -1) {
+			index = add_touch((__bridge void *)touch);
+		}
 		if (index >= 0) {
 			CGPoint point = [touch locationInView:self];
 			float x = point.x * self.contentScaleFactor;
@@ -132,7 +128,6 @@ void iron_internal_call_resize_callback(int width, int height);
 				iron_internal_mouse_trigger_press(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
 			}
 			iron_internal_surface_trigger_touch_start(index, x, y);
-
 			if (touch.type == UITouchTypePencil) {
 				iron_internal_pen_trigger_press(x, y, 0.0);
 			}
@@ -142,7 +137,7 @@ void iron_internal_call_resize_callback(int width, int height);
 
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
 	for (UITouch *touch in touches) {
-		int index = getTouchIndex((__bridge void *)touch);
+		int index = get_touch_index((__bridge void *)touch);
 		if (index >= 0) {
 			CGPoint point = [touch locationInView:self];
 			float x = point.x * self.contentScaleFactor;
@@ -168,7 +163,7 @@ void iron_internal_call_resize_callback(int width, int height);
 
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
 	for (UITouch *touch in touches) {
-		int index = removeTouch((__bridge void *)touch);
+		int index = remove_touch((__bridge void *)touch);
 		if (index >= 0) {
 			CGPoint point = [touch locationInView:self];
 			float x = point.x * self.contentScaleFactor;
@@ -177,7 +172,6 @@ void iron_internal_call_resize_callback(int width, int height);
 				iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
 			}
 			iron_internal_surface_trigger_touch_end(index, x, y);
-
 			if (touch.type == UITouchTypePencil) {
 				iron_internal_pen_trigger_release(x, y, 0.0);
 			}
@@ -187,7 +181,7 @@ void iron_internal_call_resize_callback(int width, int height);
 
 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
 	for (UITouch *touch in touches) {
-		int index = removeTouch((__bridge void *)touch);
+		int index = remove_touch((__bridge void *)touch);
 		if (index >= 0) {
 			CGPoint point = [touch locationInView:self];
 			float x = point.x * self.contentScaleFactor;
@@ -196,7 +190,6 @@ void iron_internal_call_resize_callback(int width, int height);
 				iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
 			}
 			iron_internal_surface_trigger_touch_end(index, x, y);
-
 			if (touch.type == UITouchTypePencil) {
 				iron_internal_pen_trigger_release(x, y, 0.0);
 			}
@@ -204,10 +197,6 @@ void iron_internal_call_resize_callback(int width, int height);
 	}
 }
 
-static NSString *keyboardstring;
-static UITextField *myTextField = NULL;
-static bool shiftDown = false;
-
 - (void)showKeyboard {
 	[self becomeFirstResponder];
 }
@@ -223,14 +212,14 @@ static bool shiftDown = false;
 - (void)insertText:(NSString *)text {
 	if ([text length] == 1) {
 		unichar ch = [text characterAtIndex:[text length] - 1];
-		if (ch == 8212)
+		if (ch == 8212) {
 			ch = '_';
+		}
 		if (ch == L'\n') {
 			iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN);
 			iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN);
 			return;
 		}
-
 		if (ch == L'.') {
 			iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD);
 			iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD);
@@ -256,22 +245,21 @@ static bool shiftDown = false;
 			iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH);
 		}
 		else if (ch >= L'a' && ch <= L'z') {
-			if (shiftDown) {
+			if (shift_down) {
 				iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT);
-				shiftDown = false;
+				shift_down = false;
 			}
 			iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'a');
 			iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'a');
 		}
 		else {
-			if (!shiftDown) {
+			if (!shift_down) {
 				iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT);
-				shiftDown = true;
+				shift_down = true;
 			}
 			iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'A');
 			iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'A');
 		}
-
 		iron_internal_keyboard_trigger_key_press(ch);
 	}
 }
@@ -303,49 +291,31 @@ static bool shiftDown = false;
 
 @end
 
-static GLView *glView;
-static bool visible;
-
-void beginGL(void) {
-	if (!visible) {
-		return;
-	}
-	[glView begin];
-}
-
-void endGL(void) {
-	if (!visible) {
-		return;
-	}
-	[glView end];
-}
-
 void showKeyboard(void) {
-	[glView showKeyboard];
+	[myView showKeyboard];
 }
 
 void hideKeyboard(void) {
-	[glView hideKeyboard];
+	[myView hideKeyboard];
 }
 
 CAMetalLayer *getMetalLayer(void) {
-	return [glView metalLayer];
+	return [myView metalLayer];
 }
 
 id getMetalDevice(void) {
-	return [glView metalDevice];
+	return [myView metalDevice];
 }
 
 id getMetalQueue(void) {
-	return [glView metalQueue];
+	return [myView metalQueue];
 }
 
-@implementation GLViewController
+@implementation MyViewController
 
 - (void)loadView {
 	visible = true;
-	self.view = glView = [[GLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
+	self.view = myView = [[MyView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 	[self.view addInteraction: [[UIDropInteraction alloc] initWithDelegate: self]];
 	[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
 }
@@ -354,10 +324,6 @@ id getMetalQueue(void) {
 	visible = value;
 }
 
-#include <iron_system.h>
-
-extern char mobile_title[1024];
-
 void importFile(NSURL *url) {
 	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 	NSString *folderName = [NSString stringWithUTF8String:mobile_title];
@@ -386,11 +352,10 @@ void importFile(NSURL *url) {
 
 - (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id<UIDropSession>)session {
 	CGPoint point = [session locationInView:self.view];
-	float x = point.x * glView.contentScaleFactor;
-	float y = point.y * glView.contentScaleFactor;
+	float x = point.x * myView.contentScaleFactor;
+	float y = point.y * myView.contentScaleFactor;
 	iron_internal_mouse_trigger_move(x, y);
 	iron_internal_surface_trigger_move(0, x, y);
-
 	for (UIDragItem *item in session.items) {
 		[item.itemProvider loadInPlaceFileRepresentationForTypeIdentifier:item.itemProvider.registeredTypeIdentifiers[0] completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) {
 			importFile(url);
@@ -402,17 +367,13 @@ void importFile(NSURL *url) {
 	return [[UIDropProposal alloc] initWithDropOperation: UIDropOperationCopy];
 }
 
-- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
-{
+- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
     return UIRectEdgeAll;
 }
 
 @end
 
-@implementation IronAppDelegate
-
-static UIWindow *window;
-static GLViewController *glViewController;
+@implementation IronSceneDelegate
 
 void loadURL(const char *url) {
 	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
@@ -424,52 +385,51 @@ void loadURL(const char *url) {
 	}
 }
 
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
+	#ifdef IRON_A2
 	AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
 	NSError *error;
-
-	// set the session category
 	NSString *category = AVAudioSessionCategoryAmbient;
-	bool success = [sessionInstance setCategory:category error:&error];
-	if (!success)
-		NSLog(@"Error setting AVAudioSession category! %@\n", [error localizedDescription]);
-
-	window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-	[window setBackgroundColor:[UIColor blackColor]];
-
-	glViewController = [[GLViewController alloc] init];
-	glViewController.view.multipleTouchEnabled = YES;
-
-	[window setRootViewController:glViewController];
-	[window makeKeyAndVisible];
-
+	[sessionInstance setCategory:category error:&error];
+	#endif
+
+	UIWindowScene *windowScene = (UIWindowScene *)scene;
+    self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
+    // self.window.frame = windowScene.coordinateSpace.bounds;
+	self.window.frame = [UIScreen mainScreen].bounds;
+    [self.window setBackgroundColor:[UIColor blackColor]];
+
+	myViewController = [[MyViewController alloc] init];
+	myViewController.view.multipleTouchEnabled = YES;
+	[self.window setRootViewController:myViewController];
+	[self.window makeKeyAndVisible];
+
+	[myViewController setVisible:YES];
+    // iron_internal_foreground_callback();
 	[self performSelectorOnMainThread:@selector(mainLoop) withObject:nil waitUntilDone:NO];
-
-	return YES;
 }
 
-void IronUpdateKeyboard(void);
-
-- (void)applicationWillEnterForeground:(UIApplication *)application {
-	[glViewController setVisible:YES];
-	iron_internal_foreground_callback();
+- (void)sceneDidDisconnect:(UIScene *)scene {
+	[myViewController setVisible:NO];
+	iron_internal_shutdown_callback();
 }
 
-- (void)applicationDidBecomeActive:(UIApplication *)application {
-	iron_internal_resume_callback();
+- (void)sceneDidBecomeActive:(UIScene *)scene {
+    iron_internal_resume_callback();
 }
 
-- (void)applicationWillResignActive:(UIApplication *)application {
-	iron_internal_pause_callback();
+- (void)sceneWillResignActive:(UIScene *)scene {
+    iron_internal_pause_callback();
 }
 
-- (void)applicationDidEnterBackground:(UIApplication *)application {
-	[glViewController setVisible:NO];
-	iron_internal_background_callback();
+- (void)sceneWillEnterForeground:(UIScene *)scene {
+	[myViewController setVisible:YES];
+    iron_internal_foreground_callback();
 }
 
-- (void)applicationWillTerminate:(UIApplication *)application {
-	iron_internal_shutdown_callback();
+- (void)sceneDidEnterBackground:(UIScene *)scene {
+	[myViewController setVisible:NO];
+    iron_internal_background_callback();
 }
 
 @end
@@ -493,12 +453,7 @@ int iron_primary_display(void) {
 	return 0;
 }
 
-@implementation Motion
-
-@end
-
 void iron_internal_mouse_lock(void) {}
-
 void iron_internal_mouse_unlock(void) {}
 
 bool iron_mouse_can_lock(void) {
@@ -506,23 +461,17 @@ bool iron_mouse_can_lock(void) {
 }
 
 void iron_mouse_show(void) {}
-
 void iron_mouse_hide(void) {}
-
 void iron_mouse_set_position(int x, int y) {}
-
 void iron_mouse_get_position(int *x, int *y) {}
-
 void iron_mouse_set_cursor(int cursor_index) {}
 
-bool withAutoreleasepool(bool (*f)(void)) {
+bool with_autoreleasepool(bool (*f)(void)) {
 	@autoreleasepool {
 		return f();
 	}
 }
 
-static bool keyboardshown = false;
-
 const char *iphonegetresourcepath(void) {
 	return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:1];
 }
@@ -537,31 +486,24 @@ bool iron_internal_handle_messages(void) {
 
 void iron_set_keep_screen_on(bool on) {}
 
-void showKeyboard(void);
-void hideKeyboard(void);
-
 void iron_keyboard_show(void) {
-	keyboardshown = true;
+	keyboard_shown = true;
 	showKeyboard();
 }
 
 void iron_keyboard_hide(void) {
-	keyboardshown = false;
+	keyboard_shown = false;
 	hideKeyboard();
 }
 
 bool iron_keyboard_active(void) {
-	return keyboardshown;
+	return keyboard_shown;
 }
 
-void loadURL(const char *url);
-
 void iron_load_url(const char *url) {
 	loadURL(url);
 }
 
-static char language[3];
-
 const char *iron_language(void) {
 	NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0];
 	const char *lang = [nsstr UTF8String];
@@ -571,35 +513,17 @@ const char *iron_language(void) {
 	return language;
 }
 
-void IronUpdateKeyboard(void) {
-	if (keyboardshown) {
-		hideKeyboard();
-		showKeyboard();
-	}
-	else {
-		hideKeyboard();
-	}
-}
-
 void iron_internal_shutdown(void) {}
 
 void iron_init(const char *name, int width, int height, struct iron_window_options *win) {
-	iron_window_options_t defaultWin;
+	iron_window_options_t default_win;
 	if (win == NULL) {
-		iron_window_options_set_defaults(&defaultWin);
-		win = &defaultWin;
+		iron_window_options_set_defaults(&default_win);
+		win = &default_win;
 	}
 	gpu_init(win->depth_bits, true);
 }
 
-void endGL(void);
-
-void swapBuffersiOS(void) {
-	endGL();
-}
-
-static char sysid[512];
-
 const char *iron_system_id(void) {
 	const char *name = [[[UIDevice currentDevice] name] UTF8String];
 	const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String];
@@ -609,29 +533,20 @@ const char *iron_system_id(void) {
 	return sysid;
 }
 
-static const char *getSavePath(void) {
+const char *iron_internal_save_path(void) {
 	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
 	NSString *resolvedPath = [paths objectAtIndex:0];
 	NSString *appName = [NSString stringWithUTF8String:iron_application_name()];
 	resolvedPath = [resolvedPath stringByAppendingPathComponent:appName];
-
 	NSFileManager *fileMgr = [[NSFileManager alloc] init];
-
 	NSError *error;
 	[fileMgr createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error];
-
 	resolvedPath = [resolvedPath stringByAppendingString:@"/"];
 	return [resolvedPath cStringUsingEncoding:1];
 }
 
-const char *iron_internal_save_path(void) {
-	return getSavePath();
-}
-
-static const char *videoFormats[] = {"mp4", NULL};
-
 const char **iron_video_formats(void) {
-	return videoFormats;
+	return video_formats;
 }
 
 double iron_frequency(void) {
@@ -645,36 +560,15 @@ uint64_t iron_timestamp(void) {
 	return time;
 }
 
-#ifdef WITH_GAMEPAD
-
-const char *iron_gamepad_vendor(int gamepad) {
-	return "nobody";
-}
-
-const char *iron_gamepad_product_name(int gamepad) {
-	return "none";
-}
-
-bool iron_gamepad_connected(int num) {
-	return true;
-}
-
-void iron_gamepad_rumble(int gamepad, float left, float right) {}
-
-#endif
-
 int main(int argc, char *argv[]) {
-	int retVal = 0;
+	int res = 0;
 	@autoreleasepool {
-		[IronAppDelegate description]; // otherwise removed by the linker
-		retVal = UIApplicationMain(argc, argv, nil, @"IronAppDelegate");
+		[IronSceneDelegate description]; // otherwise removed by the linker
+		res = UIApplicationMain(argc, argv, nil, nil);
 	}
-	return retVal;
+	return res;
 }
 
-static void (*resizeCallback)(int x, int y, void *data) = NULL;
-static void *resizeCallbackData = NULL;
-
 int iron_window_x() {
 	return 0;
 }
@@ -684,29 +578,22 @@ int iron_window_y() {
 }
 
 void iron_window_resize(int width, int height) {}
-
 void iron_window_move(int x, int y) {}
-
 void iron_window_change_mode(iron_window_mode_t mode) {}
-
 void iron_window_destroy() {}
-
 void iron_window_show() {}
-
 void iron_window_hide() {}
-
 void iron_window_set_title(const char *title) {}
-
 void iron_window_create(iron_window_options_t *win) {}
 
 void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
-	resizeCallback = callback;
-	resizeCallbackData = data;
+	resize_callback = callback;
+	resize_callback_data = data;
 }
 
 void iron_internal_call_resize_callback(int width, int height) {
-	if (resizeCallback != NULL) {
-		resizeCallback(width, height, resizeCallbackData);
+	if (resize_callback != NULL) {
+		resize_callback(width, height, resize_callback_data);
 	}
 }
 
@@ -719,3 +606,21 @@ iron_window_mode_t iron_window_get_mode() {
 int iron_window_display() {
 	return 0;
 }
+
+#ifdef WITH_GAMEPAD
+
+const char *iron_gamepad_vendor(int gamepad) {
+	return "nobody";
+}
+
+const char *iron_gamepad_product_name(int gamepad) {
+	return "none";
+}
+
+bool iron_gamepad_connected(int num) {
+	return true;
+}
+
+void iron_gamepad_rumble(int gamepad, float left, float right) {}
+
+#endif

+ 2 - 6
base/sources/backends/macos_system.m

@@ -892,7 +892,7 @@ void iron_gamepad_rumble(int gamepad, float left, float right) {}
 
 #endif
 
-bool withAutoreleasepool(bool (*f)(void)) {
+bool with_autoreleasepool(bool (*f)(void)) {
 	@autoreleasepool {
 		return f();
 	}
@@ -1079,7 +1079,7 @@ const char *iron_language(void) {
 
 void iron_internal_shutdown(void) {}
 
-static const char *getSavePath(void) {
+const char *iron_internal_save_path(void) {
 	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
 	NSString *resolvedPath = [paths objectAtIndex:0];
 	NSString *appName = [NSString stringWithUTF8String:iron_application_name()];
@@ -1094,10 +1094,6 @@ static const char *getSavePath(void) {
 	return [resolvedPath cStringUsingEncoding:NSUTF8StringEncoding];
 }
 
-const char *iron_internal_save_path(void) {
-	return getSavePath();
-}
-
 #ifndef IRON_NO_MAIN
 int main(int argc, char **argv) {
 	return kickstart(argc, argv);

+ 2 - 2
base/sources/iron_system.c

@@ -121,7 +121,7 @@ static void (*paste_callback)(char *, void *) = NULL;
 static void *paste_callback_data = NULL;
 
 #if defined(IRON_IOS) || defined(IRON_MACOS)
-bool withAutoreleasepool(bool (*f)(void));
+bool with_autoreleasepool(bool (*f)(void));
 #endif
 
 void iron_set_update_callback(void (*callback)(void *), void *data) {
@@ -263,7 +263,7 @@ void iron_start(void) {
 #if !defined(IRON_WASM)
 
 #if defined(IRON_IOS) || defined(IRON_MACOS)
-	while (withAutoreleasepool(iron_internal_frame)) {
+	while (with_autoreleasepool(iron_internal_frame)) {
 	}
 #else
 	while (iron_internal_frame()) {

+ 4 - 0
base/sources/libs/kong/backends/util.c

@@ -96,7 +96,11 @@ bool execute_sync(const char *command, uint32_t *exit_code) {
 
 	return success != FALSE;
 #elif defined(__APPLE__)
+	#ifdef TARGET_OS_IPHONE
+	int status = -1;
+	#else
 	int status = system(command);
+	#endif
 
 	if (status < 0) {
 		return false;

+ 1 - 3
base/tools/make.js

@@ -936,7 +936,7 @@ class File {
 	}
 
 	isBuildFile() {
-		return this.filename.endsWith(".c") || this.filename.endsWith(".cpp") || this.filename.endsWith(".m") || this.filename.endsWith(".mm") || this.filename.endsWith(".cc") || this.filename.endsWith(".metal") || this.filename.endsWith(".storyboard");
+		return this.filename.endsWith(".c") || this.filename.endsWith(".cpp") || this.filename.endsWith(".m") || this.filename.endsWith(".mm") || this.filename.endsWith(".cc") || this.filename.endsWith(".metal");
 	}
 
 	getName() {
@@ -1196,8 +1196,6 @@ class XCodeExporter extends Exporter {
 		for (let file of files) {
 			let filetype = "unknown";
 			let fileencoding = "";
-			if (file.getName().endsWith(".storyboard"))
-				filetype = "file.storyboard";
 			if (file.getName().endsWith(".plist"))
 				filetype = "text.plist.xml";
 			if (file.getName().endsWith(".h"))