conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.17k stars 974 forks source link

[bug] `XcodeDeps` seems not to work with current Xcode versions #16526

Closed andiwand closed 3 months ago

andiwand commented 3 months ago

Describe the bug

The generated xcconfig files from XcodeDeps seem not to work with a recent version of Xcode. I tested Xcode 15.3 and 15.4 with Conan 2.4.1. The problem seems to be that conditional variables cannot be assigned to other unconditional variables.

Example of the xcconfig content

OTHER_LDFLAGS_miniz_miniz[config=Debug][arch=arm64][sdk=iphonesimulator*] =  -lminiz  

...

OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_miniz_miniz)

This results in OTHER_LDFLAGS being empty as the conditional variable OTHER_LDFLAGS_miniz_miniz seems not to be appendable.

I am not sure if this is a bug of Xcode or the intended behavior but ultimately this seems to break the current xcconfig file generation of XcodeDeps.

Environment details: MacOS 14.5 (23F79), apple-clang, Conan version 2.4.1, Xcode Version 15.4 (15F31d)

How to reproduce it

FOO = hi
FOO[arch=arm64] = ih
SYSTEM_HEADER_SEARCH_PATHS = $(FOO)

This results in SYSTEM_HEADER_SEARCH_PATHS being empty. This mechanism (which might have worked in the past?) seems not to work with the current Xcode versions.

czoido commented 3 months ago

Hi @andiwand,

Thanks a lot for reporting. I have been trying to reproduce (also MacOS 14.5 23F79, Xcode Version 15.4 15F31d) this but apparently is working for me, could you please check in case I'm missing something?

I made this small example to test it. It's an app example project that depends on bye Conan package. bye sets some definitions that are conditional to build type so the generated xcconfig file has something like:

GCC_PREPROCESSOR_DEFINITIONS_bye_bye[config=Debug][arch=x86_64][sdk=macosx*] = "MY_DEFINITION=\"DefDebug\""

and then in other file:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) $(GCC_PREPROCESSOR_DEFINITIONS_bye_bye)

The app will output the definitions and apparently it's working correctly.

Could you please check the example here: https://github.com/czoido/issue-16526 and tell us if that works for you?

git clone https://github.com/czoido/issue-16526.git
cd issue-16526 
conan export bye
conan install . -s build_type=Debug -s arch=x86_64 --build=missing
conan install . -s build_type=Release -s arch=x86_64 --build=missing
xcodegen generate
xcodebuild -project app.xcodeproj -configuration Release -arch x86_64
./build/Release/app
xcodebuild -project app.xcodeproj -configuration Debug -arch x86_64
./build/Debug/app
andiwand commented 3 months ago

Thanks for the detailed examples @czoido ! You are right this works perfectly fine. I suppose there is a problem with our XCode setup. I will try to debug this comparing it to your examples. Thanks again!

czoido commented 3 months ago

Thank you so much for reporting @andiwand, please do not hesitate to reopen or open another issue if you find anything that does not work for you

andiwand commented 3 months ago

I fear I am still facing the same issue but I do not have a small reproducible example. The biggest difference I see between our setups is that I am targeting iOS. But it might still come from a problem with the XCode project configuration since it works with your MacOS example. Do you know if there is a small iOS+conan example similar to yours @czoido ?

czoido commented 3 months ago

I fear I am still facing the same issue but I do not have a small reproducible example. The biggest difference I see between our setups is that I am targeting iOS. But it might still come from a problem with the XCode project configuration since it works with your MacOS example. Do you know if there is a small iOS+conan example similar to yours @czoido ?

I added here a run_ios.sh that uses an ios profile to build, could you please check? Is it useful?

andiwand commented 3 months ago

Ultimately it seems to be a problem with Pods and Conan. Pods sets some LIBRARY_SEARCH_PATHS which seems to kill the one from Conan even tho it looks correct in both cases. Potentially this could also be an Xcode issue. Thanks again @czoido !