3 Replies
      Latest reply: Oct 13, 2016 3:03 AM by eskimo RSS
      Conan Shin Level 1 Level 1 (0 points)

        I'm a newbie in xCode Programming.

        I could successfully hide classes and variables using "@Private" annotation and given attribute "__attribute__((visibility('hidden'))".

        However, unlike any other classes, I find it difficult to hide interface since neither "@Private" annotation nor "__attribute__((visibility('hidden'))" is applicable.

        Is there an alternative easy way to hide interface?

         

        Thank you.

        • Re: Applying symbol hide on interface
          eskimo Apple Staff Apple Staff (6,310 points)

          I’m confused what you mean by “hide” in this context?  Can you post a tiny example that explains this.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Applying symbol hide on interface
              Conan Shin Level 1 Level 1 (0 points)

              Let me paraphrasemy question.

              When people use 'nm' command on certain library, call it library.a.

              And let's say library.a is referencing library.b, and I want to expose only a few methods and classes from library.b.

              I will be following these steps

              1. Eliminate any internal symbols required between modules by performing a single-object prelink. Set the Xcode build setting named "Perform Single-Object Prelink" to Yes (GENERATE_MASTER_OBJECT_FILE=YES). This causes ld to be run with the "-r" flag.
              2. Make sure that the setting "Strip Style" is set to "Non-global symbols" (STRIP_STYLE=non-global), this passes "-x" to ld.
              3. Stripping is only actually performed on static libraries if post-processing is enabled (and this is not the default). Set Xcode build setting "Deployment Postprocessing" to yes. (DEPLOYMENT_POSTPROCESSING=YES). Also make sure that "Use separate strip" is set to Yes (not always the default) (SEPARATE_STRIP=YES).
              4. If, in addition to local symbols, if you need to remove some of the global symbols you can supply additional options to the strip command, under the Xcode build setting "Additional strip flags". E.g. I commonly use the strip "-R somefile" option to provide a file with an additional list of symbols which I want removed from the global symbol table.

              provided in http://stackoverflow.com/questions/3276474/symbol-hiding-in-static-libraries-built-with-xcode-gcc

              However, I don't want to change xCode build configuration instead I want to achieve symbol hiding from the source level.

              Where developer can actually control his/her source's methods and classes(let's say these are from library.b) visibility.

              So when other people use 'nm' command on his library.a, they can't access the classes and methods that are hidden by the developer.

               

              Thank you.

                • Re: Applying symbol hide on interface
                  eskimo Apple Staff Apple Staff (6,310 points)

                  And let's say library.a is referencing library.b, and I want to expose only a few methods and classes from library.b.

                  What’s the high-level goạl?  Why do you care whether these symbols are exposed?  Are you trying to work around a linker performance issue?  Or is this some sort of security thing (you don’t want folks see the symbols within your library)?

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"