I am building an .xcframework which contains an iphonesimulator and iphoneos frameworks. There is some Swift code, and some C++ code, which is linked into a shared object (Mach-O 64-bit dynamically linked shared library arm64). I build my C++ with -fvisibility=hidden
, and only the symbols that I explicitly mark, are exported. But, when I run nm -gC
, I see all kinds of symbols that are still there – and they are visible even in the iOS app that is built using this framework. For example, I have an inner class Secret
(it is only used in one cpp file). And nm -gC
shows me (and all hackers out there)
00010292 t Secret::getString() const
Is there a way to hide this and other sensitive information?
And, on the other hand, how can I keep the auto-generated _AlexSDKVersionNumber
exported?
2
Answers
As for keeping the auto-generated
_AlexSDKVersionNumber
exported, I came up with a not-so-dirty hack:add a header file to my project, call it AlexSDK_vers.h:
in Build Settings, add
OTHER_CFLAGS=-include${PWD}/AlexSDK/AlexSDK_vers.h
You should configure your project settings correctly for Stripping to hide internal names.
Go to
Your target
>Build Settings
>Deployment
:Set
Deployment Postprocessing
toYES
to enable Stripping.Set
Strip Style
toNon-Global Symbols
.Now
nm
should provide global (external) symbols only for your binary.