4

I found that it is possible to create XCode project from command line with a help of CMake (are there any other options?). Is there any tool to create XCode workspace and pin projects into it?

If not, can I create it manually? My current version of XCode (7.3 beta) makes a workspace that consists of below file structure:

WORKSPACE_NAME.xcworkspace/
  contents.xcworkspacedata
  xcuserdata/
    USER_NAME.xcuserdatad/
      UserInterfaceState.xcuserstate

Content of contents.xcworkspacedata looks straightforward and I guess this is the file that pins projects into workspace. UserInterfaceState.xcuserstate is a binary file that can be generated when workspace is opened in XCode.

Summing up, if there is no command line tool for creating workspace and pinning projects into it, can I just generate proper contents.xcworkspacedata file or should I do something more?

mkk
  • 675
  • 6
  • 17

1 Answers1

1

If your project has a CMakeLists.txt file, CMake can generate an XCode project file from it (on the command line), and you can then build it as well (from the command line).

Assuming you are currently in your project's source directory and it contains a CMakeLists.txt:

$ mkdir build && cd build $ cmake -G "Xcode" ../ $ cmake --build .

Alternatively you can remove the -G option, it'll then generate a Makefile, and then you can do make and it will build on the command-line too, using the Xcode build tools.

Ela782
  • 5,041
  • 5
  • 53
  • 66
  • Hi @Ela782, thanks for your reply. This will create a project however, I was rather interested in generating a workspace that has a project inside. Is there any way to create such a workspace and attach to it some projects? – mkk Mar 11 '18 at 22:53
  • 1
    Hi @mkk, ah, I think I fully understand now what you want to do. I unfortunately don't have a solution for that. I found a few related links, but I think none of them helps. Some of them are also a bit dated. https://cmake.org/pipermail/cmake/2011-October/046848.html, https://stackoverflow.com/questions/24748553/generate-an-xcscheme-file-from-the-command-line/29747196, http://neurocline.github.io/dev/2016/04/16/xcode-xcworkspace-and-xcodeproj.html. It seems quite uncommon what you want to do, sorry :-( – Ela782 Mar 12 '18 at 18:52