Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
React-Native Module in Swift with async function throws is not a recognized Objective-C method

I am trying to export a swift module according to react-native's documentation but I run into the following error when I try to call this function in my javascript file. I believe the issue has to do with calling an async method in my swift code. So I'm not sure how to export and call an async method from my swift file when creating a native module in react-native.

exception error object-c methor

Here is the AppleMusicAuth.swift file that contains the async method I'm trying to export

//
//  AppleMusicAuth.swift
//
//
//

import Foundation
import MusicKit

@available(iOS 15.0, *)
@objc(AppleMusicAuth)
class AppleMusicAuth: NSObject {

  @objc
  func getAuthStatus() async -> Void {
    let response = await MusicAuthorization.request()
    print(response)
  }
}

Along with my AppleMusicAuth.m file that makes use of RCT_EXTERN_METHOD method for exporting the module to my JS application

//
//  AppleMusicAuth.m
//
//
//

#import <Foundation/Foundation.h>

#import <React/RCTBridgeModule.h>


@interface RCT_EXTERN_MODULE(AppleMusicAuth, NSObject)

RCT_EXTERN_METHOD(getAuthStatus)

@end

And the Javascript files that import and call the module and method for use

import { NativeModules } from 'react-native';
const { AppleMusicAuth } = NativeModules;
export default AppleMusicAuth;
import React from 'react';
import {Button} from 'react-native';
import AppleMusicAuth from '../nativeModules/AppleMusicAuth';

type Props = {};

const App: React.FC<Props> = () => {
  return (
        <Button
          onPress={() => {
            AppleMusicAuth.getAuthStatus();
          }}
          title="Button"
          color="#841584"
        />
  );
};

export default App;

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!