9

I updated my Xcode to 10 beta after that when I build I am getting bellow error with build failure..

accessing build database "/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.

I have my script in Build phases like below

  set -e
  if [ -d "${PROJECT_DIR}/Frameworks" ]; then
  rm -rf "${PROJECT_DIR}/Frameworks"
  fi
  mkdir "${PROJECT_DIR}/Frameworks"
  #FRAMEWORKS_PATH="${PROJECT_DIR}/../Frameworks"
  xcodebuild -project 

  "${PROJECT_DIR}/../iOS/Frameworks/sdk/SDK.xcodeproj" -scheme 
  "SDKAggregate" -sdk "iphoneos" -configuration "Build"

 cp -r 
 ${PROJECT_DIR}/../iOS/Frameworks/sdk/"SDK.framework" 
 "${PROJECT_DIR}/Frameworks"

I FOUND THIS LINK [Xcode 10: unable to attach DB error

But my case is different please help me thanks in advance..

Note: If I choose New build system then only i am getting this error. For Legacy build system everything works fine.

tp2376
  • 690
  • 1
  • 7
  • 23

5 Answers5

10

I found a solution, if you are running your xcodebuild from terminal to an specific target (The Aggregate one) just add the OBJROOT="${OBJROOT}/DependentBuilds" example:

sudo xcodebuild -project YourProject.xcodeproj -target YourProject-Universal -destination "platform=iOS,name=generic/iOS" OBJROOT="${OBJROOT}/DependentBuilds"

I added the sudo to allow Xcode to create the DependentBuilds directory, but you can change your folder permission and it will work.

David Cortes
  • 535
  • 4
  • 14
  • 1
    This seems to work though "DependentBuilds" could be anything. I'm not sure I completely understand the root cause and how this addresses it, but this seems to move things out of the way of being in contention. – levigroker Nov 15 '18 at 23:48
2

option:1

As I said with Legacy build system everything working fine but not with new build system.

option:2

Removed script and manually added SDK binary to my project tested with new build system works fine..

I am thinking with new build system when I am building SDK with help of script it's taking as two builds concurrently and throwing error.

tp2376
  • 690
  • 1
  • 7
  • 23
  • How can we add the iPhoneos 11.3 SDK in Our project. please suggest. I got the error when I make a build after I updated to Xcode 10. – Avinash Mishra Sep 21 '18 at 07:25
2

I replaced -schema with -target and it worked nicely (might only work in my specific case though).

afi
  • 488
  • 1
  • 5
  • 7
0

I was getting this error when running xcodebuild from Terminal. I noticed that inside DerivedData I had two folders for my project instead of one. I deleted both of them (one regenerated automatically) and I stopped getting the error.

Allanah Fowler
  • 1,251
  • 16
  • 17
0

I added the file WorkspaceSettings.xcsettings in myProject.xcodeproj/project.xcworkspace/xcshareddata

<?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>BuildSystemType</key>
    <string>Original</string>
</dict>
</plist>

and this fixed it

Alberto M
  • 1,608
  • 1
  • 18
  • 42