From 3c36d80e259b438ed3dc9847387dd5ef374ea799 Mon Sep 17 00:00:00 2001 From: osy <50960678+osy@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:13:46 -0800 Subject: [PATCH] process: disable macOS code from iOS builds --- Services/UTMProcess.m | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Services/UTMProcess.m b/Services/UTMProcess.m index ecf368c2c..5f450b447 100644 --- a/Services/UTMProcess.m +++ b/Services/UTMProcess.m @@ -35,7 +35,9 @@ @interface UTMProcess () @implementation UTMProcess { NSMutableArray *_argv; NSMutableArray *_urls; +#if TARGET_OS_OSX NSXPCConnection *_connection; +#endif } static void *startProcess(void *args) { @@ -92,7 +94,11 @@ - (NSURL *)libraryURL { } - (BOOL)hasRemoteProcess { +#if TARGET_OS_OSX return _connection != nil; +#else + return NO; +#endif } - (NSString *)arguments { @@ -219,6 +225,7 @@ - (void)startDylibThread:(nonnull NSString *)dylib completion:(nonnull void (^)( completion(nil); } +#if TARGET_OS_OSX - (void)startQemuRemote:(nonnull NSString *)name completion:(nonnull void (^)(NSError * _Nullable))completion { NSError *error; NSData *libBookmark = [self.libraryURL bookmarkDataWithOptions:0 @@ -253,6 +260,7 @@ - (void)startQemuRemote:(nonnull NSString *)name completion:(nonnull void (^)(NS } }]; } +#endif - (void)startProcess:(nonnull NSString *)name completion:(nonnull void (^)(NSError * _Nullable))completion { #if TARGET_OS_IPHONE @@ -262,18 +270,24 @@ - (void)startProcess:(nonnull NSString *)name completion:(nonnull void (^)(NSErr #endif NSString *dylib = [NSString stringWithFormat:@"%@.framework/%@%@", name, base, name]; self.processName = name; +#if TARGET_OS_OSX if (_connection) { [self startQemuRemote:dylib completion:completion]; } else { +#endif [self startDylibThread:dylib completion:completion]; +#if TARGET_OS_OSX } +#endif } - (void)stopProcess { +#if TARGET_OS_OSX if (_connection) { [[_connection remoteObjectProxy] terminate]; [_connection invalidate]; } +#endif for (NSURL *url in _urls) { [url stopAccessingSecurityScopedResource]; } @@ -320,11 +334,15 @@ - (void)accessDataWithBookmark:(NSData *)bookmark { } - (void)accessDataWithBookmark:(NSData *)bookmark securityScoped:(BOOL)securityScoped completion:(void(^)(BOOL, NSData * _Nullable, NSString * _Nullable))completion { +#if TARGET_OS_OSX if (_connection) { [[_connection remoteObjectProxy] accessDataWithBookmark:bookmark securityScoped:securityScoped completion:completion]; } else { +#endif [self accessDataWithBookmarkThread:bookmark securityScoped:securityScoped completion:completion]; +#if TARGET_OS_OSX } +#endif } - (void)stopAccessingPathThread:(nullable NSString *)path { @@ -342,11 +360,15 @@ - (void)stopAccessingPathThread:(nullable NSString *)path { } - (void)stopAccessingPath:(nullable NSString *)path { +#if TARGET_OS_OSX if (_connection) { [[_connection remoteObjectProxy] stopAccessingPath:path]; } else { +#endif [self stopAccessingPathThread:path]; +#if TARGET_OS_OSX } +#endif } - (NSError *)errorWithMessage:(nullable NSString *)message {