Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Xcode 10 How to fix broken "New build system" - build.db: database is locked Possibly there are two concurrent builds

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

like image 670
Alex Stone Avatar asked Oct 20 '25 05:10

Alex Stone


1 Answers

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.

like image 99
Benjamin Wen Avatar answered Oct 22 '25 04:10

Benjamin Wen