So, I've been racking my brain with this bug I have. I inherited this React Native bridge module. It calls a library that I wrote in Swift. I've managed to fix a few issues with it, but now there's one issue with the linker that I can't simply wrap my head around:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RNModuleSdk", referenced from:
objc-class-ref in RNModuleSdk-eba6e9a8c28f116def4103b848536d6fd0a1a766f6fb5a382f24541d40db702c.o
__OBJC_$_CATEGORY_RNModuleSdk_$_RCTExternModule in RnModuleSdk-eba6e9a8c28f116def4103b848536d6fd0a1a766f6fb5a382f24541d40db702c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think the issue stems from the linker not being able to see either RNModuleSdk or, more likely, RCTExternModule. To me, this makes sense because the architecture it complains about changes relative to the target I'm aiming for (a device or the simulator, arm64 or x86-64, respectively)
This is really my first React Native project, so I've been comparing what I have with other sites to see if I missed something in the Native Bridge, but so far nothing stands out. Abstracted code below
RNModuleSdk.swift
import Foundation
import UIKit
import ModuleSdk
@objc(RNModuleSdk)
class RNModuleSdk: NSObject {
.
.
.
}
RNModuleSdk.m
#import <React/RCTBridgeModule.h>
//#import "React/RCTViewManager.h"
@interface RCT_EXTERN_REMAP_MODULE(SdkManager, RNModuleSdk, NSObject)
.
.
.
@end
RNModuleSdk-Bridging-Header.h
#import <React/RCTBridgeModule.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTRootView.h>
#import <React/RCTUtils.h>
#import <React/RCTConvert.h>
#import <React/RCTBundleURLProvider.h>
I use the RCT_EXTERN_REMAP_MODULE function so it matches with the name the javascript code expects it to be. I've tried before with just RCT_EXTERN_MODULE, I get the same error.
I've checked the library search paths, everything seems to be in order (though, if I'm missing linking against a React or React Native library, I'm unsure). The project uses Cocoapods and has at the end the use_native_modules! line, which I think handles the linking for me? I could be wrong, which would make everything make sense, but I'm at my wit's end and don't know what else to do.
Help?