Conan 1.42 brings several significant new features. We have added a new conan.tool.XcodeDeps generator, which supports multiple configurations and easy integration with the Xcode IDE. Also, Conan now comes with OSX Monterey support in its default settings. Finally, Conan now generates a script to deactivate all the aggregated environments as it did for activating them.

New XcodeDeps multi-config generator

The new XcodeDeps generator allows easy integration with the Xcode IDE. It supports multiple configurations, so if you install the packages for different Release and Debug configurations, you can switch between those two configurations in the IDE and the dependency information is updated to match the active configuration requirements.

Let’s see how you can use the files generated by Conan in your Xcode project. Imagine you have a simple Xcode project with this structure:

.
└── MyApplication
    ├── MyApplication
    │   ├── conanfile.txt
    │   └── main.cpp
    └── MyApplication.xcodeproj

With a conanfile.txt like this, with just fmt as dependency and adding the XcodeDeps generator:

[requires]
fmt/8.0.1
[generators]
XcodeDeps

You can install the dependencies for both Release and Debug configurations:

$ conan install . -s build_type=Debug
$ conan install . -s build_type=Release

Conan will install all the required packages and generate several .xcconfig files with all the information about those dependencies. In this case, as ftm is a library with no transitive dependencies, the generated files are:

conan_fmt.xcconfig
conan_fmt_debug_x86_64.xcconfig
conan_fmt_release_x86_64.xcconfig
conan_fmt_vars_debug_x86_64.xcconfig
conan_fmt_vars_release_x86_64.xcconfig
conandeps.xcconfig

Those files define information like where to search the headers of the dependencies, compiler flags, the location for the libraries, frameworks needed to compile the application, etc., for both Debug and Release configurations. It will also generate one single file (conandeps.xcconfig) aggregating all the files for the direct dependencies (just fmt in this case).

Go to your Xcode project, click on the project and select Add files to…

Project, Add files to...

Add those files to your project:

Select xcconfig files to add

Click on the project again. In the Info/Configurations section, choose conandeps for Release and Debug.

Set configuration files for Debug and Release

Now build as usual. Xcode will link with the information that Conan provides for the configuration that’s active.

Build the project

Besides this new generator, we now support macOS Monterey in the default settings that come with the Conan installation.

Deactivate aggregated environments easily

We keep improving the Conan tools for managing environments. Up to this point, the environments were grouped for activation in the conanbuild and conanrun scripts but no aggregated script was generated for deactivation. From this version, a new deactivate_conanbuild or deactivate_conanrun is generated together with those files to deactivate all the environments at once.

Also, please note that we made some changes to the environment classes. Now, Environment is just a generic class used by others like the conan.tools.gnu autotools helpers, and the VirtualBuildEnv and VirtualRunEnv generator. If you want to use it, a specialization for the current context EnvVars object needs to be obtained from it with the vars() method. Let’s see an example:

from conans import ConanFile
from conan.tools.env import Environment

class Pkg(ConanFile):

    def generate(self):
        env1 = Environment()
        env1.define("env_name", "env1")
        env1.vars(self).save_script("env1_launcher")
        env2 = Environment()
        env2.define("env_name", "env2")
        env2.vars(self).save_script("env2_launcher")
        env3 = Environment()
        env2.define("env_name", "env3")
        env2.vars(self).save_script("env3_launcher")

Note the change in syntax compared to the previous implementation. Now, after running a conan install ., these files are generated:

├── conanbuild.sh
├── deactivate_conanbuild.sh
├── env1_launcher.sh
├── env2_launcher.sh
└── env3_launcher.sh

You can use conanbuild.sh to activate all the environments at once and deactivate_conanbuild.sh to deactivate them in the correct order. Please check the documentation for more information about this topic.



Besides the items listed above, there were some minor bug fixes you may wish to read about. If so, please refer to the changelog for the complete list.

We hope you enjoy this release, and look forward to your feedback.