4

I'm having problem with the infamous:

"/Users/n/Library/Developer/Xcode/DerivedData/Build/Intermediates/XCBuildData/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location

How do I fix broken "modern" build system getting stuck with a locked database?

I tried:

  • Cleaning the project
  • Deleting derived data
  • Updating cocoapods (sudo gem...) and pod install
  • Full nuking of Xcode folder with a fresh reinstall from App Store

Now I'm with a fresh Xcode installation, the project worked for a dozen builds(real device and simulator) and the problem comes back, making me unable to work on a project. How I can reset the locks on build.db or delete it?

I see this question asked multiple times, and the answers do not solve my problem. I'm not using build scripts, all I have is a couple cocoapods. Please do not close this question, as I'm asking specifically about lack of:

  • NO CUSTOM SCRIPTS
  • NO CONSOLE BUILDS
  • NO COMPOSITE TARGETS

The only thing that lets me continue working is turning to the legacy build system:

enter image description here

enter image description here

How can I use the legacy build system with Xcode 10's `xcodebuild`?

Xcode 10: unable to attach DB error

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex Stone
  • 46,408
  • 55
  • 231
  • 407

5 Answers5

3

I encountered this when tinkering with cli, swift run democli. The error I got was:

unable to attach DB: error: accessing build database "/Users/xman/Desktop/democli/.build/x86_64-apple-macosx/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location.

I just remove the build.db, and the DB error is gone.

wzso
  • 3,482
  • 5
  • 27
  • 48
1

So far the only way to fix this is to turn the "Legacy Build system" on in File > Workspace settings. After certain number of computer restarts (or time elapsed?) the setting can be changed to the "new" build system again and it will build.

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
0

I managed to compile my project by adding to the xcodebuild command line:

OBJROOT="${OBJROOT}/DependentBuilds"

Thanks to this post: https://github.com/mattgallagher/CwlSignal/issues/24#issuecomment-396931001

Nicolas Buquet
  • 3,880
  • 28
  • 28
0

I encountered the same issue while using Fastlane and the New Build System.

After switching from xcodebuild( ) to build_app( ), the issue was resolved.

smoothBlue
  • 203
  • 4
  • 12
0

The legacy build solution is too temporary. You can only use that from within XCode. You can't use it within VSCode, so you lose the Hot Reload sweetness.

ouflak
  • 2,458
  • 10
  • 44
  • 49