stdStringForString returns empty string (webRTC)

Hi, I'm facing a very strange issue where all the calls to  stdStringForString returns an empty string This only happens on macOS Monterey with Intel hardware in the archived version of the app (even if the archive was made with debug config) Running the app with Xcode or on M1's runs flawlessly.

Here is the function:

+ (std::string)stdStringForString:(NSString *)nsString {
 NSData *charData = [nsString dataUsingEncoding:NSUTF8StringEncoding];
 return std::string(reinterpret_cast<const char *>(charData.bytes),
           charData.length);
}

This function always comes back empty.

Thank you!

There are two ‘obvious’ ways this could happen:

  • charData is nil

  • charData.length is 0

Add debug logging for these cases. Does the problem still reproduce with your logging in place? If so, what do you see?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I solve the issue by renaming the names of the methods to something different, I don't know why this solved the issue.

stdStringForString returns empty string (webRTC)
 
 
Q