diff --git a/templates/ios-make/Makefile b/templates/ios-make/Makefile index 7026c77..a938e41 100644 --- a/templates/ios-make/Makefile +++ b/templates/ios-make/Makefile @@ -28,14 +28,13 @@ PLUGIN_DIR ?= src API_DIR ?= $(PLUGIN_DIR) MKINC_DIR ?= $(COMMON_DIR) -BUILD_BIN_DIR := build/gen/src -BUILD_DATA_DIR := build/gen/src +BUILD_BIN_DIR := build/gen/res +BUILD_DATA_DIR := build/gen/res -include $(MKINC_DIR)/vars-pre.mk SOURCES := \ $(DATA_DIR)/src/data.h \ - $(DATA_DIR)/src/index.html \ $(COMMON_DIR)/src/app.swift \ $(COMMON_DIR)/src/native.mm \ $(COMMON_DIR)/src/app-Bridging-Header.h \ @@ -46,7 +45,10 @@ SOURCES := \ $(SRCS_EXTRA) SOURCES_OUT := $(addprefix build/gen/src/, $(notdir $(SOURCES))) -DIRS := build build/gen build/gen/src +RESOURCES := $(DATA_DIR)/src/index.html +RESOURCES_OUT := $(addprefix build/gen/res/, $(notdir $(RESOURCES))) + +DIRS := build build/gen build/gen/src build/gen/res ALL := build/gen/$(BUNDLE_NAME).xcodeproj @@ -54,7 +56,7 @@ ALL := build/gen/$(BUNDLE_NAME).xcodeproj all: $(ALL) -build/gen/$(BUNDLE_NAME).xcodeproj: $(SOURCES_OUT) +build/gen/$(BUNDLE_NAME).xcodeproj: $(SOURCES_OUT) $(RESOURCES_OUT) xcodegen generate --spec project.yml -r build/gen -p build/gen $(DIRS): @@ -74,4 +76,7 @@ PERCENT := % $(SOURCES_OUT): build/gen/src/%: $$(filter $$(PERCENT)/%,$$(SOURCES)) | build/gen/src cp -R $^ $@ +$(RESOURCES_OUT): build/gen/res/%: $$(filter $$(PERCENT)/%,$$(RESOURCES)) | build/gen/res + cp -R $^ $@ + -include $(MKINC_DIR)/rules-secondexp-extra.mk diff --git a/templates/ios-make/project.yml b/templates/ios-make/project.yml index 17be2c0..5f4d08d 100644 --- a/templates/ios-make/project.yml +++ b/templates/ios-make/project.yml @@ -30,6 +30,8 @@ targets: type: application sources: - path: src + - path: res + type: folder {{?it.ios_make.dependencies}} dependencies: diff --git a/templates/ios/src/app.swift b/templates/ios/src/app.swift index d92db0c..ec83d95 100644 --- a/templates/ios/src/app.swift +++ b/templates/ios/src/app.swift @@ -67,7 +67,8 @@ struct WebView: UIViewRepresentable { func makeUIView(context: Context) -> WKWebView { let configuration = WKWebViewConfiguration() - configuration.userContentController.addScriptMessageHandler(Coordinator(), contentWorld: .page, name: "listener") + configuration.userContentController.addScriptMessageHandler(Coordinator(), contentWorld: .page, name: "messageHandler") + configuration.setValue(true, forKey: "allowUniversalAccessFromFileURLs") let webView = WKWebView(frame: .zero, configuration: configuration) //webView.isInspectable = true return webView @@ -81,7 +82,7 @@ struct WebView: UIViewRepresentable { struct ContentView: View { var body: some View { - let url = Bundle.main.url(forResource: "index", withExtension: "html") + let url = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "res") WebView(url: url!) } } diff --git a/templates/ios/src/index.html b/templates/ios/src/index.html index ce7e217..ce2ca26 100644 --- a/templates/ios/src/index.html +++ b/templates/ios/src/index.html @@ -26,7 +26,7 @@