# CMake 3.19 / Xcode 12 fails when cross-compiling for iOS unless -T buildsystem=1 is specified

**URL:** https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463
**Category:** Usage
**Tags:** gen:xcode
**Created:** [January 3, 2021, 5:41pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463 "2021-01-03T17:41:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![herzbube](https://discourse.cmake.org/user_avatar/discourse.cmake.org/herzbube/32/1060_2.png) [@herzbube](https://discourse.cmake.org/u/herzbube)
#### Post date: [January 3, 2021, 5:41pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463/1 "2021-01-03T17:41:14Z")

</div>

From the CMake 3.19 release notes:

> The Xcode generator now uses the Xcode “new build system” when generating for Xcode 12.0 or higher. See the `CMAKE_XCODE_BUILD_SYSTEM` variable. One may use `-T buildsystem=1` to switch to the legacy build system.

When I’m cross-compiling for iOS with CMake 3.19 and Xcode 12, using the new build system causes the build to consistently fail with this error message:

```
error: unable to attach DB: error: accessing build database "/path/to/project/build/ios/build/XCBuildData/build.db":
  database is locked Possibly there are two concurrent builds running in the same filesystem location.

```

The issue seems to be a post-build rule that CMake creates for the `install` target. In that post-build rule a second build is initiated while the first one is still in progress.

For the moment I can make the build work again by specifying `-T buildsystem=1`, but this seems to be a temporary workaround only, because Xcode’s legacy build system has been deprecated and, knowing Apple’s relentless innovation drive, will go away rather sooner than later.

Is there a better way how to make cross-compiling for iOS work again without having to resort to `-T buildsystem=1`?

Also the iOS cross-compiling section on the [cmake-toolchains](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-toolchain) docs page fails to mention `-T buildsystem=1` - it would be nice to update the page with a hint.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 3, 2021, 10:08pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463/2 "2021-01-03T22:08:25Z")

</div>

Please try CMake 3.19.2 with Xcode 12.2 or later, I think this has already been fixed.

---

<div class="post-metadata">

### Author: ![herzbube](https://discourse.cmake.org/user_avatar/discourse.cmake.org/herzbube/32/1060_2.png) [@herzbube](https://discourse.cmake.org/u/herzbube)
#### Post date: [January 4, 2021, 6:12pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463/3 "2021-01-04T18:12:49Z")

</div>

I don’t think this is already fixed. My question/report already is for CMake 3.19.2 (installed via Homebrew) and Xcode 12.3. The OS is macOS Big Sur 11.1. Sorry for not being more specific.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 4, 2021, 11:15pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463/4 "2021-01-04T23:15:42Z")

</div>

Could you please report a new issue in [CMake’s issue tracker](https://gitlab.kitware.com/cmake/cmake/-/issues) for this. Include as much detail as you can about your system, versions used, etc. including different variations you’ve tried. This sounds like a combination that should already be covered by nightly builds, so I’m surprised it doesn’t work. There may be something slightly different about your setup compared to what has been tested so far.

---

<div class="post-metadata">

### Author: ![herzbube](https://discourse.cmake.org/user_avatar/discourse.cmake.org/herzbube/32/1060_2.png) [@herzbube](https://discourse.cmake.org/u/herzbube)
#### Post date: [January 5, 2021, 7:34pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463/5 "2021-01-05T19:34:15Z")

</div>

Thanks for the issue tracker link. I found [issue 21282](https://gitlab.kitware.com/cmake/cmake/-/issues/21282) which exactly describes my problem. The issue is still open so I didn’t create a new one.

Apologies for wasting time here in the forum, I should have searched the tracker first before posting here.
