在 macOS Big Sur 上安装 React Native 时出现“未定义符号:Swift.ExpressibleByFloatLiteral 的协议描述符”问题

Qui*_*inn 15 xcode ios swift react-native react-native-ios

我试图在我的系统上安装 React Native,但发现它无法安装该模板错误所需的 CocoaPods 依赖项。

sudo arch -x86_64 gem install ffi修复了这个问题,但最终出现event-config.h" file not found错误。

我将 pod 文件中的更改后的鳍状肢版本更改为use_flipper!({'Flipper'=>'0.76.0'}),然后我遇到了上面提到的错误。对此问题的任何帮助将不胜感激。

node version : 15.10.0
react-native version: 0.63.4
Xcode version: 12.4
Run Code Online (Sandbox Code Playgroud)

错误说明如下:

Showing Recent Messages

Could not find or use auto-linked library 'swiftCoreGraphics'
Could not find or use auto-linked library 'swiftUIKit'
Could not find or use auto-linked library 'swiftDarwin'
Could not find or use auto-linked library 'swiftFoundation'
Could not find or use auto-linked library 'swiftMetal'
Could not find or use auto-linked library 'swiftObjectiveC'
Could not find or use auto-linked library 'swiftCoreFoundation'
Could not find or use auto-linked library 'swiftDispatch'
Could not find or use auto-linked library 'swiftCoreImage'
Could not find or use auto-linked library 'swiftQuartzCore'
Could not find or use auto-linked library 'swiftCore'
Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral
Undefined symbol: associated type descriptor for Swift.ExpressibleByIntegerLiteral.IntegerLiteralType

Undefined symbol: associated conformance descriptor for Swift.ExpressibleByIntegerLiteral.Swift.ExpressibleByIntegerLiteral.IntegerLiteralType: Swift._ExpressibleByBuiltinIntegerLiteral

Undefined symbol: method descriptor for Swift.ExpressibleByFloatLiteral.init(floatLiteral: A.FloatLiteralType) -> A

Undefined symbol: protocol descriptor for Swift.ExpressibleByIntegerLiteral
Undefined symbol: value witness table for Builtin.Int32
Undefined symbol: __swift_FORCE_LOAD_$_swiftCoreImage
Undefined symbol: associated type descriptor for Swift.ExpressibleByFloatLiteral.FloatLiteralType
Undefined symbol: __swift_FORCE_LOAD_$_swiftQuartzCore
Undefined symbol: __swift_FORCE_LOAD_$_swiftDispatch
Undefined symbol: method descriptor for Swift.ExpressibleByIntegerLiteral.init(integerLiteral: A.IntegerLiteralType) -> A
Undefined symbol: __swift_FORCE_LOAD_$_swiftCoreFoundation
Undefined symbol: protocol witness table for Swift.Int : Swift._ExpressibleByBuiltinIntegerLiteral in Swift
Undefined symbol: __swift_FORCE_LOAD_$_swiftObjectiveC
Undefined symbol: __swift_FORCE_LOAD_$_swiftCoreGraphics
Undefined symbol: _swift_getForeignTypeMetadata
Undefined symbol: __swift_FORCE_LOAD_$_swiftFoundation
Undefined symbol: associated conformance descriptor for Swift.ExpressibleByFloatLiteral.Swift.ExpressibleByFloatLiteral.FloatLiteralType: Swift._ExpressibleByBuiltinFloatLiteral
Undefined symbol: __swift_FORCE_LOAD_$_swiftUIKit
Undefined symbol: __swift_FORCE_LOAD_$_swiftMetal
Undefined symbol: Swift.Float.init(Swift.Double) -> Swift.Float
Undefined symbol: __swift_FORCE_LOAD_$_swiftDarwin
Undefined symbol: protocol witness table for Swift.Float : Swift._ExpressibleByBuiltinFloatLiteral in Swift
Run Code Online (Sandbox Code Playgroud)

小智 22

如果您使用的是 M1 mac,则需要排除架构 arm64。 请检查这张图片

还要在 pod 文件的末尾添加此代码

post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

执行 pod install,清理构建文件夹并重新启动构建,它将解决问题。


小智 5

对我真正有用的是,只添加这个排除的架构,你会没事的,当然如果你使用的是带有 M1 的 Mac

在此处输入图片说明


ric*_*rbh 2

我通过向 Xcode 中的项目添加一个空的 swift 文件来解决这个问题。这具有创建桥接头文件的副作用,该文件(至少对我来说)使我的项目得以编译。