首页 > 解决方案 > React Native iOS 构建在本地成功,但在 CI 服务器上失败

问题描述

AsyncStorage我最近将一个 React Native 项目更新到了 0.59 版本,现在不推荐使用内置的。所以我@react-native-community/react-native-async-storage按照建议安装了包,并通过运行链接包react-native link @react-native-community/async-storage

现在在本地 Xcode 中运行构建成功。但是,当我尝试在 Azure DevOps 的 CI 管道中运行构建时,它在链接过程中失败:

# ...

▸ Compiling main.m
▸ Linking MyApp
⚠️  ld: directory not found for option '-L/Users/vsts/agent/2.149.2/work/1/s/ios/MyApp/System/Library/Frameworks'

❌  ld: library not found for -lRNCAsyncStorage



❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)


▸ Linking MyApp
⚠️  ld: directory not found for option '-L/Users/vsts/agent/2.149.2/work/1/s/ios/MyApp/System/Library/Frameworks'

❌  ld: library not found for -lRNCAsyncStorage



❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)


** BUILD FAILED **


The following build commands failed:
    Ld /Users/vsts/Library/Developer/Xcode/DerivedData/MyApp-asjjausbybqgpsdjodrbvoyzaeqx/Build/Intermediates.noindex/MyApp.build/BetaRelease-iphoneos/MyApp.build/Objects-normal/armv7/MyApp normal armv7
    Ld /Users/vsts/Library/Developer/Xcode/DerivedData/MyApp-asjjausbybqgpsdjodrbvoyzaeqx/Build/Intermediates.noindex/MyApp.build/BetaRelease-iphoneos/MyApp.build/Objects-normal/arm64/MyApp normal arm64
(2 failures)
##[error]Error: /usr/bin/xcodebuild failed with return code: 65
##[section]Finishing: Xcode build, sign and export

再往上看,它确实看起来已经建成:

# ...

▸ Building RNCAsyncStorage/RNCAsyncStorage [(Release)]
▸ Check Dependencies
▸ Building library libRNCAsyncStorage.a
▸ Building library libRNCAsyncStorage.a
▸ Copying RNCAsyncStorage.h
▸ Copying RNCAsyncStorageDelegate.h

# ...

有什么想法可能导致这种情况吗?

标签: iosxcodereact-nativeazure-devops

解决方案


添加这个${PODS_CONFIGURATION_BUILD_DIR}/RNCAsyncStorageLibrary Search Paths我有用。

在此处输入图像描述


推荐阅读