Fuse Community

"Module not found" Error - Native Interop of Swift Via Objective-C in JS Module

Trying to figure out a “Module not found” error previewing on iPad, yet no errors on the (Windows) desktop. I already searched through this forum looking for answers. I made sure to register the module and run uno clean.

I’m new to native modules and foreign code, trying to get an implementation of Swift working via Objective-C. I’m using Fuse Studio 1.10.0-rc1.

My .uno file:

using Uno;
using Uno.Collections;
using Uno.Compiler.ExportTargetInterop;
using Uno.UX;
using Fuse;
using Fuse.Scripting;
	
[ForeignInclude(Language.ObjC, "testMod-Swift.h")]

[UXGlobalModule]
public class testMod : NativeModule
{
	static readonly testMod _instance;

	public testMod() {
		if(_instance != null) return;

		_instance = this;
		Resource.SetGlobalKey(_instance, "testMod");
		AddMember(new NativeFunction("ViewController", (NativeCallback)ViewController));
	}

	static object ViewController(Context c, object[] args) {
		ViewControllerImpl();
		return null;
	}

	public static extern(!Mobile) void ViewControllerImpl() {
		debug_log("Not supported on this platform.");	
	}

    [Foreign(Language.ObjC)]
    public static extern(iOS) void ViewControllerImpl()
    @{
        ViewController* x = [[ViewController alloc] init];
    @}
}

My MainView.ux file:

<App>
	<Panel>
		<JavaScript>
			var jsMod = require("testMod");
			
			function alertTest() {
				jsMod.ViewController();
			}
			module.exports ={
				alertTest : alertTest
			};
		</JavaScript>
		<Button Text="Did it work?" Clicked="{alertTest}" />
	</Panel>
</App>

My .unoproj file:

{
  "RootNamespace":"",
  "Packages": [
    "Fuse",
    "FuseJS",
    "Fuse.Scripting"
  ],
  "Includes": [
    "*",
    "Test.swift:Swift:iOS"
  ]
}