我们正在开发一个 React Native 项目。我的一位团队成员在 Linux 上添加了一些本机模块并链接了 android。那时我正在尝试链接 iOS 中的内容,但构建总是失败并出现这种错误跟踪。 Android项目正在正常构建。
我删除了
xyz.xcworkspace
和Podfile.lock
然后尝试了pod install
。node_modules
,然后删除 yarn install
,然后删除 yarn link
。
react-native-cli: 2.0.1
react-native: 0.61.4
yarn 1.19.1
Pod 1.8.4
XCode Version 11.2.1 (11B500)
macOS Catalina 10.15.1 (19B88)
xyz 警告
duplicate output file '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/AntDesign.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/faisal/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Intermediates.noindex/xyz.build/Debug-iphonesimulator/xyz.build/Script-47F818C57EEC47EA3303EA1B.sh
xyz 工作空间错误
Multiple commands produce '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf':
1) Target 'xyz' (project 'xyz') has copy command from '/Users/user/Desktop/xyz/native/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf'
2) That command depends on command in Target 'xyz' (project 'xyz'): script phase “[CP] Copy Pods Resources”
有多个这样的错误和警告,但具有相同的格式和不同的文件名。
问题是由于 RN 自动链接,您有重复的资源。 要解决这个问题
对于 xCode 11+ 和 React-native 0.60+,
答案复制自此 GitHub 问题答案
问题似乎是由新的
功能引起的 React Native 0.60 -autolinking
中的use_native_modules!
行 意味着当您执行ios/Podfile
时,在pod install
中找到的任何 pod 都是 自动链接。这意味着所有字体文件的链接都是 添加到 [CP] 复制 Pods 资源,当您这样做时node_modules
。pod install
如果您之前通过以下方式手动安装了
将字体文件添加到复制捆绑资源中,然后您将获得 “多个命令产生...”致命构建错误。react-native-vector-icons
因此,要解决此问题,只需从 Copy Bundle 中删除字体文件即可 资源,以便它们仅位于 [CP] 复制 Pods 资源中。
所以关于库的存储库的官方文档已经过时并且没有提到它。您应该按照安装步骤将字体列表添加到
info.plist
,并且不要创建 Fonts
文件夹组并将字体复制粘贴到该文件夹中。
对我来说解决这个问题的是删除多个条目
[CP] Embed Pods Frameworks /
和 / [CP] Copy Pods Resources */,
在 buildPhases
文件中的单个 project.pbxproj
块内。这些是在将 RN 版本升级到 0.68.7
时添加的。
例如:
buildPhases = (
...
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
E235C05ADACE081382539298 /* [CP] Embed Pods Frameworks */, <== newly added
...
);
删除旧条目(在本例中为
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks*/
)以及相应的代码块 /* Begin PBXShellScriptBuildPhase section */
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputFileListPaths = (
...
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
...
);
...
};
使错误消失。
我所做的是
第 1 步:恢复到工作代码 步骤2:从assets/fonts中删除所有react-native-fonts字体文件 步骤 3:npx 反应本机资产 步骤4:cd ios 第5步:吊舱安装 第6步:打开xcode并运行模拟器
注意我没有使用 rn-fonts,很多地方我主要使用 svg 文件
一切对我来说都很好,尝试一下
我可以按照此步骤解决该问题。 您所要做的就是打开项目文件夹 -> 转到 /ios 并打开文件
YourProjectName.xcodeproj
然后按照此操作 https://lifesaver.codes/answer/error-multiple-commands-product-in-xcode-10 ,那么你只需删除那里的所有字体并运行 npx react-native run-ios