Skip to content

Commit

Permalink
fix(runtime,extension): fix buld for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Jan 9, 2025
1 parent 7e6d730 commit 04e4101
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 33 deletions.
3 changes: 3 additions & 0 deletions src/extension/process.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "extension.hh"

#if !SOCKET_RUNTIME_PLATFORM_IOS
using ssc::runtime::process::exec;
#endif

using ssc::runtime::string::trim;

const sapi_process_exec_t* sapi_process_exec (
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/app.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace ssc::runtime::app {
willContinueUserActivityWithType: (NSString*) userActivityType;
#endif

@property (nonatomic, assign) ssc::runtime::app::App* app;
@property (nonatomic, assign) ssc::runtime::SharedPointer<ssc::runtime::app::App> app;
@end
#endif

Expand Down
35 changes: 7 additions & 28 deletions src/runtime/app/apple.mm
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#include "../app.hh"

using namespace ssc::runtime;
using namespace ssc::runtime::app;
using ssc::runtime::window::Window;
using ssc::runtime::config::isDebugEnabled;
using ssc::runtime::config::getUserConfig;
using ssc::runtime::config::getDevHost;
using ssc::runtime::config::getDevPort;
using ssc::runtime::string::parseStringList;
using ssc::runtime::string::split;
using ssc::runtime::string::trim;

static dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class(
DISPATCH_QUEUE_CONCURRENT,
Expand Down Expand Up @@ -198,7 +204,7 @@ - (BOOL) application: (UIApplication*) application
argv.push_back("'" + trim(arg) + "'");
}

auto windowManagerOptions = WindowManagerOptions {};
auto windowManagerOptions = window::ManagerOptions {};

for (const auto& arg : split(self.app->runtime.userConfig["ssc_argv"], ',')) {
if (arg.find("--test") == 0) {
Expand All @@ -216,37 +222,10 @@ - (BOOL) application: (UIApplication*) application
static const auto port = getDevPort();
static const auto host = getDevHost();

if (
self.app->runtime.userConfig["webview_service_worker_mode"] != "hybrid" &&
self.app->runtime.userConfig["permissions_allow_service_worker"] != "false"
) {
auto serviceWorkerWindowOptions = Window::Options {};
auto serviceWorkerUserConfig = self.app->runtime.userConfig;

serviceWorkerUserConfig["webview_watch_reload"] = "false";
serviceWorkerWindowOptions.shouldExitApplicationOnClose = false;
serviceWorkerWindowOptions.index = SOCKET_RUNTIME_SERVICE_WORKER_CONTAINER_WINDOW_INDEX;
serviceWorkerWindowOptions.headless = Env::get("SOCKET_RUNTIME_SERVICE_WORKER_DEBUG").size() == 0;
serviceWorkerWindowOptions.userConfig = serviceWorkerUserConfig;
serviceWorkerWindowOptions.features.useGlobalCommonJS = false;
serviceWorkerWindowOptions.features.useGlobalNodeJS = false;

auto serviceWorkerWindow = self.app->runtime.windowManager.createWindow(serviceWorkerWindowOptions);
self.app->serviceWorkerContainer.init(&serviceWorkerWindow->bridge);

serviceWorkerWindow->navigate(
"socket://" + self.app->runtime.userConfig["meta_bundle_identifier"] + "/socket/service-worker/index.html"
);
}

auto defaultWindow = self.app->runtime.windowManager.createDefaultWindow(Window::Options {
.shouldExitApplicationOnClose = true
});

if (self.app->runtime.userConfig["webview_service_worker_mode"] == "hybrid") {
self.app->serviceWorkerContainer.init(&defaultWindow->bridge);
}

defaultWindow->setTitle(self.app->runtime.userConfig["meta_title"]);

if (isDebugEnabled() && port > 0 && host.size() > 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/core/services/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#include "platform.hh"

using ssc::runtime::url::decodeURIComponent;

#if !SOCKET_RUNTIME_PLATFORM_IOS
using ssc::runtime::process::exec;
#endif

namespace ssc::runtime::core::services {
void Platform::event (
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/window/apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ - (void) userContentController: (WKUserContentController*) userContentController
const auto uri = String(string.UTF8String);

#if SOCKET_RUNTIME_PLATFORM_IOS
const auto msg = IPC::Message(uri);
const auto msg = ipc::Message(uri);
if (msg.name == "application.exit" || msg.name == "process.exit") {
const auto code = std::stoi(msg.get("value", "0"));

if (code > 0) {
CLI::notify(SIGTERM);
ssc::cli::notify(SIGTERM);
} else {
CLI::notify(SIGUSR2);
ssc::cli::notify(SIGUSR2);
}
}
#endif
Expand Down Expand Up @@ -431,7 +431,7 @@ - (void) scrollViewDidScroll: (UIScrollView*) scrollView {
processInfo.operatingSystemVersion.majorVersion,
processInfo.operatingSystemVersion.minorVersion,
processInfo.operatingSystemVersion.patchVersion,
SSC::VERSION_STRING.c_str()
ssc::runtime::VERSION_STRING.c_str()
];
#endif

Expand Down

0 comments on commit 04e4101

Please sign in to comment.