Trying to bubble a function I made in Swift file to the main App.tsx
HelloWorld.swift
@objc(HelloWorldModule)
class HelloWorldModule: NSObject {
@objc
func ShowMessage()->Void
{
print("hello world")
}
}
HelloWorld.m
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(HelloWorldModule, NSObject)
RCT_EXTERN_METHOD(ShowMessage)
@end
App.tsx. -- the main app from react native
import React, { useEffect, useRef, useState } from 'react';
import { Alert, Button, Image, NativeModules } from 'react-native';
import styled from 'styled-components/native';
console.log(NativeModules.HelloWorldModule);
NativeModules.HelloWorldModule.ShowMessage();
Goal:
Trying to get the terminal log to output "hello world"
from App.tsx
Actual Output:
LOG {"ShowMessage": [Function nonPromiseMethodWrapper], "getConstants": [Function anonymous]}
WARN Module HelloWorldModule requires main queue setup since it overrides `init` but doesn't
implement `requiresMainQueueSetup`. In a future release React Native will default to initializing
all native modules on a background thread unless explicitly opted-out of.