skip to Main Content

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


  1. Chosen as BEST ANSWER

    As for keeping the auto-generated _AlexSDKVersionNumber exported, I came up with a not-so-dirty hack:

    1. add a header file to my project, call it AlexSDK_vers.h:

      extern __attribute__ ((visibility("default"))) const double AlexSDKVersionNumber;
      
    2. in Build Settings, add OTHER_CFLAGS=-include${PWD}/AlexSDK/AlexSDK_vers.h


  2. You should configure your project settings correctly for Stripping to hide internal names.

    Go to Your target > Build Settings > Deployment:

    1. Set Deployment Postprocessing to YES to enable Stripping.

    2. Set Strip Style to Non-Global Symbols.

    Now nm should provide global (external) symbols only for your binary.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search