5

添加了一个运行的构建脚本步骤

ibtool ./Mobile/Base.lproj/MainStoryboard_iPad.storyboard --generate-strings-file ./Mobile/Base.lproj/MainStoryboard_iPad.strings

这使构建失败

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.ibtool.errors</key>
<array>
    <dict>
        <key>description</key>
        <string>Interface Builder could not open the document "MainStoryboard_iPad.storyboard" because it does not exist.</string>
    </dict>
</array>
</dict>
</plist>
Command /bin/sh failed with exit code 1

项目先清理再建,第一次就成功了。

我试图在示例项目中复制它,但无法复制它。我们的实际项目要复杂得多……有 6 种语言,项目有两个目标(一个用于企业构建,一个用于商店构建)。许多课程和两个大型故事板。

有没有人建议尝试做不同的事情来找出导致问题的原因以确定它是否是工具错误?

4

4 回答 4

4

我在使用带有常规 xib 文件的 Xcode 5 时遇到了同样的问题。ibtools 随机工作。使用 sudo 终于为我解决了问题。

这是一个例子:

$ibtool --generate-strings-file en.lproj/MyVC.strings en.lproj/MyVC.xib
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"     
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.ibtool.errors</key>
<array>
    <dict>
        <key>description</key>
        <string>Interface Builder could not open the document "MyVC.xib" because it does not exist.</string>
    </dict>
</array>
</dict>
</plist>

每次使用 sudo 都有效,尽管它有时会抱怨“用户域将不稳定”

$sudo ibtool --generate-strings-file en.lproj/MyVC.strings en.lproj/MyVC.xib
2013-10-01 10:04:35.943 Interface Builder Cocoa Touch Tool[1717:303] CFPreferences: user       
home directory at file:///var/root/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.
$
于 2013-10-01T14:24:56.447 回答
1

ibtool 在错误的目录中运行。始终使用 ibtool 的绝对路径,而不是相对路径。

这很奇怪,绝对是一个错误;可能是 ibtool 实际上是在告诉 Xcode 的运行副本来完成这项工作。

如果您使用ibtool --output-format human-readable-text,则错误消息包括它试图打开的实际路径,从而揭示了问题。

这是一个很难解决的问题,因为 OSX 缺少基本工具——没有 strace,并且 dtruss 只能以 root 身份工作。

于 2014-03-06T16:23:13.157 回答
0

我也收到类似“Interface Builder 无法打开文档“YourStupid.xib”的消息,因为它不存在。”

对我有用的是设置默认的 Xcode。我的系统上有两个版本的 Xcode,虽然我从不使用旧版本,但它仍然存在。我从下载页面而不是通过 App Store 安装了我的 Xcode。我在这里谈论的是 Xcode 5.0。要设置要使用的默认 Xcode,请使用 sudo 运行以下命令。xcode-select 需要 sudo 才能运行。

sudo xcode-select -s /Applications/Xcode.app

之后我的 ibtool 再次工作。对我来说,它可以在没有这里提到的 sudo 解决方案的情况下工作。

在安装文档集后,我感觉这个问题突然出现了。在阅读了这里的一些帖子并思考了哪些变化之后,我想到了我过去在第一次安装 Jenkins、Xcode 和权限(sudo 命令)时遇到的问题,然后又回到了这个命令。

到目前为止,这对我有用,从那以后我没有看到任何问题。你的旅费可能会改变。

于 2013-12-16T21:28:17.260 回答
0

我知道这是一个老问题,但我的故事板遇到了类似的问题,并更新了我在 Internet 上找到的一个脚本,该脚本在调用 ibtool 时使用了故事板的完整路径。您将在下面找到脚本

#!/bin/sh
# Update storyboard string files
#
# by 2013 André Pinto andredsp@gmail.com
# based on http://forums.macrumors.com/showthread.php?t=1467446

storyboardExt=".storyboard"
stringsExt=".strings"
newStringsExt=".strings.new"
oldStringsExt=".strings.old"
localeDirExt=".lproj"
baselprojName="Base.lproj"

# Find Base internationalization folders
find . -name "$baselprojName" | while read baselprojPath
do
    # Get Base project dir
    baselprojDir=$(dirname "$baselprojPath")

    # Find storyboard file full path inside base project folder
    find "$baselprojPath" -name "*$storyboardExt" | while read storyboardPath
    do
        # Get Base strings file full path
        baseStringsPath=$(echo "$storyboardPath" | sed "s/$storyboardExt/$stringsExt/")

        # Get storyboard file name and folder
        storyboardFile=$(basename "$storyboardPath")
        storyboardDir=$(dirname "$storyboardPath")

        #Get the full path of the storyboard and the temporary string files. This is the fix for ibtool error
        storyboardFullPath=$(echo $(echo `pwd`)$(echo "$storyboardPath" | cut  -c2-))
        newBaseStringsFullPath=$(echo `pwd`"/Main.strings.new")

        echo "Full path of the storyboard $storyboardFullPath"
        echo "Full path of the temporary string files $newBaseStringsFullPath"

        # Get New Base strings file full path and strings file name
        stringsFile=$(basename "$baseStringsPath")

        # Create strings file only when storyboard file newer
        newer=$(find "$storyboardPath" -prune -newer "$baseStringsPath")
        [ -f "$baseStringsPath" -a -z "$newer" ] && {
            echo "$storyboardFile file not modified."
            continue
        }

        echo "Creating default $stringsFile for $storyboardFile..."

        ibtool --export-strings-file "$newBaseStringsFullPath" "$storyboardFullPath"
        iconv -f UTF-16 -t UTF-8 "$newBaseStringsFullPath" > "$baseStringsPath"
        rm "$newBaseStringsFullPath"

        # Get all locale strings folder with same parent as Base
        ls -d "$baselprojDir/"*"$localeDirExt" | while read localeStringsDir
        do
            # Skip Base strings folder
            [ "$localeStringsDir" = "$storyboardDir" ] && continue

            localeDir=$(basename "$localeStringsDir")
            localeStringsPath="$localeStringsDir/$stringsFile"

            # Just copy base strings file on first time
            if [ ! -e "$localeStringsPath" ]; then
                echo "Copying default $stringsFile for $localeDir..."
                cp "$baseStringsPath" "$localeStringsPath"
            else
                echo "Merging $stringsFile changes for $localeDir..."
                oldLocaleStringsPath=$(echo "$localeStringsPath" | sed "s/$stringsExt/$oldStringsExt/")
                cp "$localeStringsPath" "$oldLocaleStringsPath"

                # Merge baseStringsPath to localeStringsPath
                awk '
NR == FNR && /^\/\*/ {
    x=$0
    getline
    a[x]=$0
    next
}
/^\/\*/ {
    x=$0
    print
    getline
    $0=a[x]?a[x]:$0
    printf $0"\n\n"
}'  "$oldLocaleStringsPath" "$baseStringsPath" > "$localeStringsPath"

                rm "$oldLocaleStringsPath"
            fi
        done
    done
done
于 2013-12-10T12:22:08.933 回答