ios resources are now bundled with xcodegen beneplacito

This commit is contained in:
Paolo Marrone 2024-12-18 18:15:34 +01:00
parent 322e7e0239
commit 6abbbf11ff
4 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -30,6 +30,8 @@ targets:
type: application
sources:
- path: src
- path: res
type: folder
{{?it.ios_make.dependencies}}
dependencies:

View File

@ -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!)
}
}

View File

@ -26,7 +26,7 @@
<title>{{=it.product.name}}</title>
<script type="text/javascript">
function request(data) {
return window.webkit.messageHandlers.listener.postMessage(data);
return window.webkit.messageHandlers.messageHandler.postMessage(data);
}
function needAudioPermission() {