Xcode 10:无法附加数据库错误 [英] Xcode 10: unable to attach DB error

查看:439
本文介绍了Xcode 10:无法附加数据库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到Xcode 10时,iOS静态库目标无法构建.我尝试构建它的方式如下:

When updating to Xcode 10, iOS static library target fails to build. Way how I am trying to build it is following:

xcodebuild -target TargetName -configuration Release clean build

使用Xcode 9时,一切都可以顺利运行,但是当使用Xcode 10进行构建时,我得到以下错误(在清除运行顺利之后):

With Xcode 9 everything runs smoothly, but when Xcode 10 is used for build, I am getting following error (after clean runs smoothly):

注意:使用新的构建系统

note: Using new build system

注意:规划构建

注意:构造构造说明构造系统信息错误: 无法附加数据库:错误:正在访问生成数据库 "/Users/uerceg/random-path/build/XCBuildData/build.db":数据库为 锁定可能有两个并发构建在同一运行中 文件系统位置.

note: Constructing build description Build system information error: unable to attach DB: error: accessing build database "/Users/uerceg/random-path/build/XCBuildData/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location.

**生成失败**

**生成失败**

以下构建命令失败:PhaseScriptExecution MultiPlatform \构建 /Users/uerceg/random-path/build/Library.build/Release-iphoneos/LibraryTarget.build/Script-9DE7C9021AE68FA5001556E5.sh (1次失败)

The following build commands failed: PhaseScriptExecution MultiPlatform\ Build /Users/uerceg/random-path/build/Library.build/Release-iphoneos/LibraryTarget.build/Script-9DE7C9021AE68FA5001556E5.sh (1 failure)

这可能无关,但是我注意到新的Xcode 10构建系统标志将Copy Bundle Resource Info.plist文件复制为错误,因此我确保没有重复的条目,但是可能此错误与此无关事实.

This probably unrelated, but I noticed that new Xcode 10 build system flags duplicated Copy Bundle Resource Info.plist files as errors, so I did make sure that there're no duplicated entries, but probably this error is not related to this fact.

有人知道什么地方可能出问题吗?

Does anyone have any idea what might be wrong?

推荐答案

好的,看来我设法解决了.我在Build Phases中有一个/bin/sh脚本,该脚本试图构建胖静态库.在脚本中,我设置了OBJROOT路径,如下所示:

Okay, seems like I managed to solve it. I was having /bin/sh script in Build Phases that was trying to build fat static library. In the script, I had OBJROOT path set like this:

OBJROOT="${OBJROOT}"

似乎Xcode 10和新的构建系统在此途中改变了一些路径,而这一行是问题的根源.需要将其调整为:

Seems like Xcode 10 and new build system changed some paths on the way and this line was the source of the issue. It needs to be adjusted to:

OBJROOT="${OBJROOT}/DependentBuilds"

此后,xcodebuild设法在Xcode 10中引入的新构建系统没有问题的情况下构建了该目标.

After that, xcodebuild manages to build this target without issues with new build system introduced in Xcode 10.

我不是一个人解决这个问题,这要感谢Matt Gallagher和他在这里的帖子: https://github.com/mattgallagher/CwlSignal/issues/24#issuecomment-396931001

I didn't get to this solution by myself, big thanks to Matt Gallagher and his post in here: https://github.com/mattgallagher/CwlSignal/issues/24#issuecomment-396931001

按照@TMin的评论要求,这是我的脚本的样子:

As requested by @TMin in comment, here's how my script looks like:

set -e

# If we're already inside this script then die
if [ -n "$RW_MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then
exit 0
fi
export RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1

RW_FRAMEWORK_NAME=${PROJECT_NAME}
RW_INPUT_STATIC_LIB="lib${PROJECT_NAME}.a"
RW_FRAMEWORK_LOCATION="${BUILT_PRODUCTS_DIR}/static/${RW_FRAMEWORK_NAME}Sdk.framework"

function build_static_library {
    echo "1"
    echo "${BUILD_DIR}"
    # Will rebuild the static library as specified
    #     build_static_library sdk
    xcrun xcodebuild -project "${PROJECT_FILE_PATH}" \
    -target "${TARGET_NAME}" \
    -configuration "${CONFIGURATION}" \
    -sdk "${1}" \
    ONLY_ACTIVE_ARCH=NO \
    BUILD_DIR="${BUILD_DIR}" \
    OBJROOT="${OBJROOT}" \
    BUILD_ROOT="${BUILD_ROOT}" \
    SYMROOT="${SYMROOT}" $ACTION
}

function make_fat_library {
    # Will smash 2 static libs together
    #     make_fat_library in1 in2 out
    xcrun lipo -create "${1}" "${2}" -output "${3}"
}

# 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]; then
RW_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi

# 2 - Extract the version from the SDK
if [[ "$SDK_NAME" =~ ([0-9]+.*$) ]]; then
RW_SDK_VERSION=${BASH_REMATCH[1]}
else
echo "Could not find sdk version from SDK_NAME: $SDK_NAME"
exit 1
fi

# 3 - Determine the other platform
if [ "$RW_SDK_PLATFORM" == "iphoneos" ]; then
RW_OTHER_PLATFORM=iphonesimulator
else
RW_OTHER_PLATFORM=iphoneos
fi

# 4 - Find the build directory
if [[ "$BUILT_PRODUCTS_DIR" =~ (.*)$RW_SDK_PLATFORM$ ]]; then
RW_OTHER_BUILT_PRODUCTS_DIR="${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}"
else
echo "Could not find other platform build directory."
exit 1
fi

# Build the other platform.
build_static_library "${RW_OTHER_PLATFORM}${RW_SDK_VERSION}"

# If we're currently building for iphonesimulator, then need to rebuild
#   to ensure that we get both i386 and x86_64
if [ "$RW_SDK_PLATFORM" == "iphonesimulator" ]; then
build_static_library "${SDK_NAME}"
fi

# Join the 2 static libs into 1 and push into the .framework
make_fat_library "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk"

# Ensure that the framework is present in both platform's build directories
cp -a "${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/static/${RW_FRAMEWORK_NAME}Sdk.framework/Versions/A/${RW_FRAMEWORK_NAME}Sdk"

# Copy the framework to the project directory
ditto "${RW_FRAMEWORK_LOCATION}" "${SRCROOT}/Frameworks/static/${RW_FRAMEWORK_NAME}Sdk.framework"

此行的build_static_library方法中存在问题:

Problem is in build_static_library method in this line:

OBJROOT="${OBJROOT}" \

将该行更改为:

OBJROOT="${OBJROOT}/DependantBuilds" \

为我解决了这个问题.

这篇关于Xcode 10:无法附加数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆