Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS llvm xcode toolchain No known class method for selector 'stringWithFormat:' #95699

Open
cosmin42 opened this issue Jun 16, 2024 · 0 comments

Comments

@cosmin42
Copy link

llvm 18.1.7
macOS Sonoma 14.5
The cmake command that I used to build the toolchain:

cmake -DLLVM_ENABLE_PROJECTS=clang \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_CREATE_XCODE_TOOLCHAIN=ON \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
  -G "Unix Makefiles" \
  ../llvm

When calling this function [NSString stringWithString:@"x"]; from a .m file the build suceeds.
It fails however when calling the same function from the .mm file with the following error:

error: no known class method for selector 'stringWithString:'
   15 |     [NSString stringWithString:@"x"];

This is the whole command:

CompileC /Users/cosminmihai/Library/Developer/Xcode/DerivedData/wtvr-brvodezqvflfuofupqgrmpccchmn/Build/Intermediates.noindex/wtvr.build/Debug/wtvr.build/Objects-normal/x86_64/Test2.o /Users/cosminmihai/wtvr/Test2.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'wtvr' from project 'wtvr')
    cd /Users/cosminmihai/wtvr
    /Library/Developer/Toolchains/LLVM18.1.7.xctoolchain/usr/bin/clang -x objective-c++ -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fno-color-diagnostics -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/cosminmihai/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability @/Users/cosminmihai/Library/Developer/Xcode/DerivedData/wtvr-brvodezqvflfuofupqgrmpccchmn/Build/Intermediates.noindex/wtvr.build/Debug/wtvr.build/Objects-normal/x86_64/af3fcb34312c57c0f52879cdce924b91-common-args.resp -MMD -MT dependencies -MF /Users/cosminmihai/Library/Developer/Xcode/DerivedData/wtvr-brvodezqvflfuofupqgrmpccchmn/Build/Intermediates.noindex/wtvr.build/Debug/wtvr.build/Objects-normal/x86_64/Test2.d --serialize-diagnostics /Users/cosminmihai/Library/Developer/Xcode/DerivedData/wtvr-brvodezqvflfuofupqgrmpccchmn/Build/Intermediates.noindex/wtvr.build/Debug/wtvr.build/Objects-normal/x86_64/Test2.dia -c /Users/cosminmihai/wtvr/Test2.mm -o /Users/cosminmihai/Library/Developer/Xcode/DerivedData/wtvr-brvodezqvflfuofupqgrmpccchmn/Build/Intermediates.noindex/wtvr.build/Debug/wtvr.build/Objects-normal/x86_64/Test2.o

This is a minimum project that reproduces the problem https://github.com/cosmin42/BridgingSample
Note the same call below that fails in the second file.
https://github.com/cosmin42/BridgingSample/blob/53fd305511b2e3baf8d8a2b0ea32aa02a25fcf7b/Test.m#L15

https://github.com/cosmin42/BridgingSample/blob/53fd305511b2e3baf8d8a2b0ea32aa02a25fcf7b/Test2.mm#L15

Any idea of a workaround?

@cosmin42 cosmin42 changed the title macOS llvm toolchain No known class method for selector 'stringWithFormat:' macOS llvm xcode toolchain No known class method for selector 'stringWithFormat:' Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants