diff --git a/conan/tools/apple/xcodedeps.py b/conan/tools/apple/xcodedeps.py index 6011e030bd7..2cc64fbe6e6 100644 --- a/conan/tools/apple/xcodedeps.py +++ b/conan/tools/apple/xcodedeps.py @@ -245,7 +245,9 @@ def _content(self): # Generate the config files for each component with name conan_pkgname_compname.xcconfig # If a package has no components the name is conan_pkgname_pkgname.xcconfig # Then all components are included in the conan_pkgname.xcconfig file - for dep in self._conanfile.dependencies.host.values(): + host_req = self._conanfile.dependencies.host + test_req = self._conanfile.dependencies.test + for dep in list(host_req.values()) + list(test_req.values()): dep_name = _format_name(dep.ref.name) include_components_names = [] diff --git a/conans/test/functional/toolchains/apple/test_xcodedeps_components.py b/conans/test/functional/toolchains/apple/test_xcodedeps_components.py index fb345883185..397b3d1fbc4 100644 --- a/conans/test/functional/toolchains/apple/test_xcodedeps_components.py +++ b/conans/test/functional/toolchains/apple/test_xcodedeps_components.py @@ -202,3 +202,28 @@ def package_info(self): assert "tcp/1.0: Hello World Release!" in client.out assert "client/1.0: Hello World Release!" in client.out assert "chat/1.0: Hello World Release!" in client.out + + +@pytest.mark.skipif(platform.system() != "Darwin", reason="Only for MacOS") +@pytest.mark.tool_cmake +def test_xcodedeps_test_require(): + client = TestClient() + client.run("new gtest/1.0 -m cmake_lib") + # client.run("new cmake_lib -d name=app -d version=1.0") + client.run("create . -tf=None") + + # Create library having build and test requires + conanfile = textwrap.dedent(r''' + from conan import ConanFile + class HelloLib(ConanFile): + settings = "os", "compiler", "build_type", "arch" + def build_requirements(self): + self.test_requires('gtest/1.0') + ''') + client.save({"conanfile.py": conanfile}, clean_first=True) + client.run("install . -g XcodeDeps") + assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest.xcconfig")) + assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest.xcconfig")) + assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest_release_x86_64.xcconfig")) + assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest_vars_release_x86_64.xcconfig")) + assert '#include "conan_gtest.xcconfig"' in client.load("conandeps.xcconfig")