使用bundler自动化构建Xcode项目时遇到的问题。

报错信息:
Multiple commands produce '/Users/wjw/Library/Developer/Xcode/DerivedData/Moments-dgddojujkmrazagmddjvfywoqzwo/Build/Products/Debug-iphonesimulator/Moments.app/Info.plist':

  1. Target 'Moments' (project 'Moments') has copy command from '/Users/wjw/Documents/Projects24/swift/Moments/Moments/Info.plist' to '/Users/wjw/Library/Developer/Xcode/DerivedData/Moments-dgddojujkmrazagmddjvfywoqzwo/Build/Products/Debug-iphonesimulator/Moments.app/Info.plist'
  2. Target 'Moments' (project 'Moments') has process command with output '/Users/wjw/Library/Developer/Xcode/DerivedData/Moments-dgddojujkmrazagmddjvfywoqzwo/Build/Products/Debug-iphonesimulator/Moments.app/Info.plist'

警告信息:
duplicate output file '/Users/wjw/Library/Developer/Xcode/DerivedData/Moments-dgddojujkmrazagmddjvfywoqzwo/Build/Products/Debug-iphonesimulator/Moments.app/Info.plist' on task: ProcessInfoPlistFile /Users/wjw/Library/Developer/Xcode/DerivedData/Moments-dgddojujkmrazagmddjvfywoqzwo/Build/Products/Debug-iphonesimulator/Moments.app/Info.plist /Users/wjw/Documents/Projects24/swift/Moments/Moments/Moments/Info.plist

在构建我们的Target时,命令从项目源代码里的Info.plist 被copy到了Xcode/DerivedData/.../Monments.app/Info.plist 这一步骤被执行了两次。

苹果开发者论坛里有前辈遇到过这些问题
https://forums.developer.apple.com/forums/thread/129896

使用bundler 自动化构建脚本的时候,bundler会自动拷贝一份 info.plist 到 project.bundlePhase files。
大佬给出的方案是在buildPhase 构建脚本中加入以下语句。

#!/bin/bash
bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
bN=$((bN += 1))
bN=$(printf "%d" $bN)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"

以上方法对我来说并没有作用
我又找到stackoverflow上面相关资料,

需要把 Target -> build phases中 -> copy Bundle Resources 中的Info.plist删除掉。
程序可以正常构建成功了!

posted @ 2024-04-05 19:11  wjwdive  阅读(8)  评论(0编辑  收藏  举报