<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95699>95699</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
macOS llvm toolchain No known class method for selector 'stringWithFormat:'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cosmin42
</td>
</tr>
</table>
<pre>
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?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWF9vI7kN_zTKiyDDo_HfBz8kcdymzZ_DJttcnwKOxJnRRSPNSho7uU9fSHKcOLt73SuKAt3FIrZJiqTInyhS4L1qDOKKTM_IdH0CQ2itWwnrO2Um_KSy8mWl9bajxWJUjOZkvCbj0w7E7R29s8Z2QIvJaJrJ9y1S0cETUmG7DoykoYVAL-ngUdJgaTUoHYlIg7VatKAMKU_zYjIb7_-nn1kPW19d_eP68eLm9Ozq4vGXT7d_uzi_vyPlWmgwDSXT8yxNKVufX5_-_eLx7PPl1frx_p-_XJBy_Qk1gsd3cnuF558uTu8vHn89v11fPN7f3l6d__X08oaU69ubr4X31j99vrm_vL6I1gnnwna90uiYC6Q806oSz8-HL1Cp_H0wO2Uk4fzI1b9Qwvlno57pNTxhrTT6DyKjEeGbGPZvxib_fWjRUAFaK9PQ0CpP68GIoKyhUXJ6dnN3F1xk-vTxoEKbCTHmkzHh_JlwTqZrUp6R2ZjWznYU6Kij0aWUppwwPwhE6UfZ7mWgNSjtaWt3uEVHd8eOIPXQ4ZszSW0kj7q95p0KbaLUVmu7i8vQOetIeUq_ueED11j6ZOzOUKHBe9phaK2ktXXUo0YRrKOEz7-1Xz5_jS0tppTMz2n892ej9P1s3McEKJ-2tWutPpyB7wH8PAPonBK--ezRecI3-dh1qgVF-OZKVQ7cC-GbNW5R2x4d4ZtfhZWYaE5tUa4hAOGbXdg6Vrmtlfj7l22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