Public announcement of the day: on the Objective C++ compiler than ships with Xcode 26.6 (and maybe before, who knows), the option -fshort-wchar is broken, unless you also specify -fno-builtin-wcslen, and it only manifests in release builds. The evidence is overwhelming.
My iOS app is a port from Windows [CE], where wchar_t has been a synonym for unsigned short since days immemorial, and the C/C++ run-time library provides the wide-character versions for all the string functions - wcslen, wcschr, wcsspn, etc. The calls to those were all over the codebase. When porting to iOS, many years ago, I had to specify -fshort-wchar to keep the binary compatibility. Naturally, all the widechar RTL calls broke, since the Apple's RTL was assuming 4 byte wchar_t, and the linker was smart enough to scream on that discrepancy. So I did the lazy thing: provided naive but workable implementations for all widechar RTL functions used, and #defined them in. E. g:
size_t w2_wcslen(LPCWSTR s)
{
size_t n = 0;
while(*s++)
n++;
return n;
}
// And then globally:
#define wcslen w2_wcslen
For the record, in order to debug a release build of an app on an iOS device without changing the signing options under project settings, do this:
- Archive the app
- In the Organizer, select the archive, click Distribute
- Select the "Debugging" option, choose a path
- In the "Devices and simulators" window, connect to the device
- Install the freshly exported IPA of the app with the + button underneath the list of apps on the device
- Run the app
- In Xcode, select the device as the build/run target
- In the menu, select Debug/Attach to process by name or ID
- Type the app name, OK
No comments:
Post a Comment