Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 16b1 • Undefined symbols #9

Closed
Brett-Best opened this issue Jun 11, 2024 · 3 comments
Closed

Xcode 16b1 • Undefined symbols #9

Brett-Best opened this issue Jun 11, 2024 · 3 comments

Comments

@Brett-Best
Copy link
Contributor

Using Xcode 16b1 we are currently unable to compile because of:

Undefined symbols for architecture arm64:
  "methodInfo.unsafeMutableAddressor : Reproducer.RCTMethodInfo in Static #1 in static Reproducer.CalendarModule.__rct_export__createEvent() -> Swift.UnsafePointer<Reproducer.RCTMethodInfo>?", referenced from:
      static Reproducer.CalendarModule.__rct_export__createEvent() -> Swift.UnsafePointer<Reproducer.RCTMethodInfo>? in noop-file.o
ld: symbol(s) not found for architecture arm64

Reproducer:

@ReactModule(jsName: "Calendar")
class CalendarModule: NSObject, RCTBridgeModule {
  
  @ReactMethod
  @objc func createEvent(title: String, location: String) {
    print("Create event '\(title)' at '\(location)'")
  }
}

Workaround, inline the macro source:

@ReactModule(jsName: "Calendar")
class CalendarModule: NSObject, RCTBridgeModule {
  @objc func createEvent(title: String, location: String) {
    print("Create event '\(title)' at '\(location)'")
  }
  
  @objc static func __rct_export__createEvent() -> UnsafePointer<RCTMethodInfo>? {
    struct Static {
      static let jsName = strdup("createEvent")
      static let objcName = strdup("createEventWithTitle:(NSString * _Nonnull)title location:(NSString * _Nonnull)location")
      nonisolated (unsafe) static var methodInfo = RCTMethodInfo(jsName: jsName, objcName: objcName, isSync: false)
    }
    return withUnsafePointer(to: &Static.methodInfo) {
      $0
    }
  }

Feels like an Xcode and/or Swift bug at this point given the inlined source works fine.

@ikhvorost
Copy link
Owner

ikhvorost commented Jun 13, 2024

Hi!
I'm able to reproduce the same on Xcode 16 beta and it looks like a Xcode's issue with macros because it throws the error for Swift 5. Lets wait next beta to test.

@Brett-Best
Copy link
Contributor Author

Yeah agreed, I'll get a feedback raised and TSI with Apple and post any updates I receive 🙂

@ikhvorost
Copy link
Owner

The issue is fixed on Xcode 16 beta in 1.2.0. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants