You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macOS: UIImagePNGRepresentation and UIImageJPEGRepresentation fail to link from Objective-C++ #3137
UIImagePNGRepresentation and UIImageJPEGRepresentation are declared in RCTUIImage.h without extern "C", but defined in RCTUIImage.m, an Objective-C file. So the library exports C symbols, and an Objective-C++ caller looks for C++-mangled ones: any .mm file that calls either function on macOS fails to link.
We hit it with react-native-svg 15.16, which calls UIImagePNGRepresentation from RNSVGSvgView.mm on macOS, so RNSVG failed to link in our app. The other two functions in the same header, UIImageGetScale and UIImageGetCGImageRef, are already wrapped in extern "C".
Steps to reproduce
With nothing but the two files from main (8941740):
Undefined symbols for architecture arm64:
"UIImagePNGRepresentation(NSImage*)", referenced from:
_main in caller.o
NOTE: found '_UIImagePNGRepresentation' in RCTUIImage.o, declaration possibly missing 'extern "C"'
ld: symbol(s) not found for architecture arm64
Reproducer
The two commands above, against main. A PR with a fix follows.
One thing for the fix: RCTImageLoader.mm defines its own copy of both functions (the #1611 workaround). As C++ those copies have mangled names, so they never clashed with RCTUIKit's. Declared extern "C", they become duplicate symbols in a static build such as RNTester's, so the copy has to go too.
Activity