簡體   English   中英

Objective-c class 通過橋接暴露 header 從 Z818056DBD7E201248206B9CCD8

[英]Objective-c class exposed via bridging header not visible from swift when archiving release

在我的 react native 項目中,我嘗試將 swift function 公開給 javascript 代碼。 它在調試模式下運行良好,但在嘗試歸檔時,我的 swift 文件出現Use of undeclared type RCTEventEmitter錯誤。

RCTEventEmitter被導入到我的RNUtils.m文件和橋接 header 中。

所以我猜在存檔的某個地方,橋接 header 失敗了,但我不知道在哪里。 如果我要求一個不存在的導入,它會告訴我它無法編譯橋接 header,因此在構建過程中會考慮該文件。

// Utils.m
#import "React/RCTBridgeModule.h"
#import "React/RCTConvert.h"
#import "React/RCTEventEmitter.h"

@interface RCT_EXTERN_REMAP_MODULE(RNUtils, RNUtils, RCTEventEmitter)

@end

// Utils.swift
import Foundation

@objc(RNUtils)
class RNUtils: RCTEventEmitter {
  // my native code emitting events
}
// MyApp-Bridging-header.h
#ifndef MyApp_Bridging_Header_h
#define MyApp_Bridging_Header_h

#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

#endif
  • react-native 0.61.5
  • xcode 11.5
  • Swift 5

看來我需要在每個 swift 文件中添加“導入反應”。 現在存檔就好了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM