diff --git a/conan/tools/apple/xcodedeps.py b/conan/tools/apple/xcodedeps.py index 17b85f32761..8c216fc26f3 100644 --- a/conan/tools/apple/xcodedeps.py +++ b/conan/tools/apple/xcodedeps.py @@ -206,9 +206,10 @@ def _all_xconfig_file(self, deps, content): """ content_multi = content or self._all_xconfig - for req, dep in deps.items(): - dep_name = _format_name(dep.ref.name) - content_multi = content_multi + '\n#include "conan_{}.xcconfig"\n'.format(dep_name) + for dep in deps.values(): + include_file = f'conan_{_format_name(dep.ref.name)}.xcconfig' + if include_file not in content_multi: + content_multi = content_multi + f'\n#include "{include_file}"\n' return content_multi def _pkg_xconfig_file(self, components): @@ -301,8 +302,9 @@ def _transitive_components(component): result.update(component_content) else: public_deps = [] + transitive_requires = [r for r, _ in get_transitive_requires(self._conanfile, dep).items()] for r, d in dep.dependencies.direct_host.items(): - if not r.visible: + if r not in transitive_requires: continue if d.cpp_info.has_components: sorted_components = d.cpp_info.get_sorted_components().items() diff --git a/conans/test/integration/toolchains/apple/test_xcodedeps.py b/conans/test/integration/toolchains/apple/test_xcodedeps.py index ea456cea176..bfc83682a04 100644 --- a/conans/test/integration/toolchains/apple/test_xcodedeps.py +++ b/conans/test/integration/toolchains/apple/test_xcodedeps.py @@ -6,7 +6,7 @@ from conans.test.assets.genconanfile import GenConanfile from conans.test.integration.toolchains.apple.test_xcodetoolchain import _get_filename -from conans.test.utils.tools import TestClient +from conans.test.utils.tools import TestClient, NO_SETTINGS_PACKAGE_ID _expected_dep_xconfig = [ "HEADER_SEARCH_PATHS = $(inherited) $(HEADER_SEARCH_PATHS_{name}_{name})", @@ -456,3 +456,25 @@ def package_info(self): assert '#include "conan_lib_c_cmp1.xcconfig"' in lib_b_xconfig assert '#include "conan_lib_c_cmp1.xcconfig"' in lib_b_xconfig assert '#include "conan_lib_c_lib_c.xcconfig"' not in lib_b_xconfig + + +@pytest.mark.skipif(platform.system() != "Darwin", reason="Only for MacOS") +def test_skipped_not_included(): + # https://github.com/conan-io/conan/issues/13818 + client = TestClient() + pkg_info = {"components": {"component": {"defines": ["SOMEDEFINE"]}}} + + client.save({"dep/conanfile.py": GenConanfile().with_package_type("header-library") + .with_package_info(cpp_info=pkg_info, + env_info={}), + "pkg/conanfile.py": GenConanfile().with_requirement("dep/0.1") + .with_package_type("library") + .with_shared_option(), + "consumer/conanfile.py": GenConanfile().with_requires("pkg/0.1") + .with_settings("os", "build_type", "arch")}) + client.run("create dep --name=dep --version=0.1") + client.run("create pkg --name=pkg --version=0.1") + client.run("install consumer -g XcodeDeps -s arch=x86_64 -s build_type=Release") + client.assert_listed_binary({"dep/0.1": (NO_SETTINGS_PACKAGE_ID, "Skip")}) + dep_xconfig = client.load("consumer/conan_pkg_pkg.xcconfig") + assert "conan_dep.xcconfig" not in dep_xconfig