gpt4 book ai didi

ios - Xcode 10 : unable to attach DB error

转载 作者:IT王子 更新时间:2023-10-29 07:44:52 25 4
gpt4 key购买 nike

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

xcodebuild -target TargetName -configuration Release clean build

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

note: Using new build system

note: Planning build

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.

** BUILD FAILED **

** BUILD FAILED **

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 文件标记为错误,所以我确实确保没有重复的条目,但可能此错误与此事实无关。

有谁知道哪里出了问题?

最佳答案

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

OBJROOT="${OBJROOT}"

似乎 Xcode 10 和新的构建系统改变了一些路径,这一行是问题的根源。需要调整为:

OBJROOT="${OBJROOT}/DependentBuilds"

之后,xcodebuild 成功地构建了这个目标,而 Xcode 10 中引入的新构建系统没有出现问题。

我自己没有得到这个解决方案,非常感谢 Matt Gallagher 和他在这里的帖子:https://github.com/mattgallagher/CwlSignal/issues/24#issuecomment-396931001


根据@TMin 在评论中的要求,我的脚本如下所示:

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 方法中:

OBJROOT="${OBJROOT}" \

将该行更改为:

OBJROOT="${OBJROOT}/DependantBuilds" \

帮我解决了这个问题。

关于ios - Xcode 10 : unable to attach DB error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51153525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com