# How to use XCODE\_SCHEME\_ARGUMENTS?

**URL:** https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332
**Category:** Code
**Tags:** gen:xcode
**Created:** [December 9, 2020, 7:47pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332 "2020-12-09T19:47:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sfp](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@sfp](https://discourse.cmake.org/u/sfp)
#### Post date: [December 9, 2020, 7:47pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/1 "2020-12-09T19:47:52Z")

</div>

How do I set this property to specify some default arguments for an executable when using the Xcode generator?

I have something like this:

```
add_executable (test test.c ...)
if (CMAKE_GENERATOR MATCHES "Xcode")
    set_property (TARGET test PROPERTY XCODE_SCHEME_ARGUMENTS "blah")
endif ()

```

If I open Xcode and select “Edit Scheme…” for this target, it doesn’t seem to have any effect (default arguments are empty).

---

<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: [December 9, 2020, 9:20pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/2 "2020-12-09T21:20:56Z")

</div>

No need to test if `CMAKE_GENERATOR` matches `Xcode` since other generators will ignore the `XCODE_SCHEME_...` properties.

I’d also recommend not calling your executable target “test”, since this will conflict with a target that CMake will create when `enable_testing()` has been called.

Do you enable schema creation? To do that, you would need to either set the `CMAKE_XCODE_GENERATE_SCHEME` variable or else set `XCODE_GENERATE_SCHEME` on each target.

---

<div class="post-metadata">

### Author: ![sfp](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@sfp](https://discourse.cmake.org/u/sfp)
#### Post date: [December 9, 2020, 9:25pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/3 "2020-12-09T21:25:21Z")

</div>

Ah, the name “test” is just a placeholder I came up with for this post. The actual target name is “basic\_solve”.

I do not enable schema creation. I checked the docs for XCODE\_GENERATE\_SCHEME, but I’m not well-versed enough with CMake to know how to proceed.

---

<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: [December 9, 2020, 9:38pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/4 "2020-12-09T21:38:47Z")

</div>

In your top level CMakeLists.txt file, you probably want something like this:

```cmake
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)

```

Try adding that to your project and see if that causes the arguments to then appear. Not sure if you will need to wipe your existing build directory or not (probably not, but something to try if it doesn’t seem to work initially).

---

<div class="post-metadata">

### Author: ![sfp](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@sfp](https://discourse.cmake.org/u/sfp)
#### Post date: [December 9, 2020, 9:45pm UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/5 "2020-12-09T21:45:53Z")

</div>

That works! Thanks a lot for the speedy assistance, Craig.

I also found that by passing the arguments as separate strings, I was able to have the arguments populate as separate entries under Xcode. E.g., calling:

```
set_property (TARGET basic_solve PROPERTY XCODE_SCHEME_ARGUMENTS "blah" "hello")

```

results in the following:

![Screen Shot 2020-12-09 at 4.45.15 PM](https://discourse.cmake.org/uploads/default/original/2X/a/a08547d8e86c36203afe80b048026fe35a353bd6.png)

---

<div class="post-metadata">

### Author: ![srpgilles](https://discourse.cmake.org/user_avatar/discourse.cmake.org/srpgilles/32/4951_2.png) [@srpgilles](https://discourse.cmake.org/u/srpgilles)
#### Post date: [September 20, 2024, 11:24am UTC](https://discourse.cmake.org/t/how-to-use-xcode-scheme-arguments/2332/6 "2024-09-20T11:24:38Z")

</div>

Hi! A follow-up question regarding the XCODE\_SCHEME\_ARGUMENTS: is there a possibility to provide an argument with the box unticked? (on the example above “blah” and “hello” are both with a tick).

In the XCode scheme file there is for each a field "isEnabled = “YES” but I haven’t found whether there is a way to set it to NO for some of them

Thanks!
