当前位置: 首页 > 工具软件 > REACT-CPP > 使用案例 >

react-native 0.63.4 Xcode升级到13后遇到的问题

司马项明
2023-12-01

原来Xcode版本是12.2,xcode版本太低,连接ios14.6 和ios15系统的手机没办法真机测试,查了下官网,xcode13支持ios15,于是就是升级后遇到的一连串报错。

一 :首先碰到的就是Flipper-Folly插件报错:
The following build commands failed:
CompileC /Users/itkey/Library/Developer/Xcode/DerivedData/speedrn-gdnmwquzchcterhjmywhtacsnjev/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/itkey/mac/rn/speedrn/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
解决办法:
修改/ios/podfile文件

添加一个字符串替换的方法

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
    text = File.read(name)
    replace = text.gsub(findstr,replacestr)
    if text != replace
      puts "Fix: " + name
      File.open(name, "w") { |file| file.puts replace }
      STDOUT.flush
    end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
 end

然后在"pod_install"Hooks 中 调用这个替换方法,例:

  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
    # 在这里————————————————添加以下方法调用
    find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
    "atomic_notify_one(state)", "folly::atomic_notify_one(state)")

    find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
    "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
  end
end

修改完后:

  1. 删除/ios/Pod 目录
  2. 执行 pod install 或者 pod install --verbose (可以看到pod在做什么)
  3. yarn ios

二:lottie-react-native插件报错:
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in t
arget ‘lottie-react-native’ from project ‘Pods’)
MergeSwiftModule normal x86_64 (in target ‘lottie-react-native’ from project
‘Pods’)
(2 failures)

解决方法:
lottie-react-native 升级到5.0.1
lottie-ios 升级到3.2.3

三:Swift桥接头文件缺失报错:
Undefined symbol: _swift_FORCE_LOAD$_swiftFileProvider

解决方法:
xcode中右键单击项目为项目添加一个新的Swift文件,步骤:
new file -->swift file --> next --> targets 选中项目 --> create
然后会弹一个弹窗,选择Create Bridging Header,最后重新运行项目。

参考链接:
https://www.csdn.net/tags/NtzaQgzsMTkzMjMtYmxvZwO0O0OO0O0O.html

https://stackoverflow.com/questions/52536380/why-do-i-get-ios-linker-errors-with-my-static-libraries/53101587#53101587

 类似资料: