Foreign Code - undefined in JavaScript


Not sure what I am doing wrong, but I have followed this guide ( on how to add foreign code.

My MainView.ux has

<App Theme="Basic">
<BarcodeScanner ux:Global="BarcodeScanner"/>
      var BarcodeScanner = require("BarcodeScanner");
      function press(){
      module.exports = {
          "press": press
    <StackPanel Margin="0,50,0,0" Padding="20">
        <Button Text="Button" Clicked="{press}"/>


My *.uno file is

using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Scripting;

using Uno.Compiler.ExportTargetInterop;

//[Require("Source.Include", "MTBBarcodeScanner.h")]
public class BarcodeScanner : NativeModule {

    public BarcodeScanner(){
        AddMember(new NativeFunction("scanner", 
    object Scanner(Context c, object[] args){

        return null;

    static extern(iOS) void Scanner()
        NSLog(@"Hi, %@", @"Please respond");
        //[[MTBBarcodeScanner alloc] initWithPreviewView:self.previewView];
    static extern(!iOS) void Scanner(){
        debug_log("Barcode Scanner is not supported on this platform");


I haven’t started on MTBBarcodeScanner code yet and commented it out. When I click my button I get the following error

    Preview detected an unhandled exception: Uno.AggregateException: One or more errors occurred.
       at Fuse.UpdateManager.Update(Fuse.Stage)
       at Fuse.UpdateManager.Update()
       at Fuse.AppBase.OnUpdate()
       at Fuse.App.OnUpdate()
       at Outracks.Simulator.Application.OnUpdate()
       at Fuse.App.OnTick(object,Uno.Platform.TimerEventArgs)
       at Uno.Platform2.Display.OnTick(Uno.Platform.TimerEventArgs)
    Name: TypeError
    Error message: BarcodeScanner.Scanner is not a function. (In 'BarcodeScanner.Scanner()', 'BarcodeScanner.Scanner' is undefined)
    File name: file:///MainView.ux
    Line number: 3
    JS stack trace: press@file:///MainView.ux:3:33

Not really sure what I am doing wrong here, seems like everything is done the same as in the video guide. I would appreciate some pointers, thanks!

Oh wow, I have been calling the object name (first capital letter), and not the name given in NativeFunction (small caps). close this please :slight_smile: