Alternatives to exports file for using Xcode frameworks in iOS

Hi, I have an iOS project with the following app targets:

  • main iOS application
  • a notification service extension
  • 5 static libs containing some swift files with public methods
  • 1 dynamic framework with above static libs as dependencies.

The framework only contains 2 files - a default .h file and 1 .exp file. This exports file contains mangled-names of all the public methods that are exposed by the 5 static libs present as framework's dependencies. I obtained these symbols using the nm command for each static lib.

The main iOS app target has 2 dependencies - the framework and the notification extension.

The notification extension only depends on the framework.

This setup works perfectly fine. I wanted to understand:

  • If using the exports file is the only way to make this setup work?
  • If not, what else can I do?
  • What way does Apple recommend?

According to my requirements, I only need at-most 2-3 functions to be exposed by the framework - thus using a exports file just for that seems to bug me.

Thank you.

Answered by DTS Engineer in 867801022
thus using a exports file just for that seems to bug me.

What part of this do you think is a bug?

In my experience, a .exp file is a great way to manage the symbols exported by your framework because it gives you explicit control. Other mechanisms tend to rely on implicit behaviour, which is a lot harder to understand.

So, are you concerned about the use of a .exp file at all? Or the mechanism you use to generate that file? Or that exporting all that extraneous stuff will costly?

Depending on what your actual concern is, there are a variety of less explicit options available to you. To learn more, search the ld man page for export and hidden.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

thus using a exports file just for that seems to bug me.

What part of this do you think is a bug?

In my experience, a .exp file is a great way to manage the symbols exported by your framework because it gives you explicit control. Other mechanisms tend to rely on implicit behaviour, which is a lot harder to understand.

So, are you concerned about the use of a .exp file at all? Or the mechanism you use to generate that file? Or that exporting all that extraneous stuff will costly?

Depending on what your actual concern is, there are a variety of less explicit options available to you. To learn more, search the ld man page for export and hidden.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, I'm looking for ways to achieve the same behavior without using an .exp file at all.

Using the exports file is neither an issue nor any bug (apologies for the wrong terminology), I'm just looking for any other ways that do not use an exports file.

Thanks.

Right. You certainly have a bunch of options for that, but it’s hard to say exactly which one is best. For example, I played around with the -all_load flag and it seem to do pretty much what you wanted. However, that’s a really heavy hammer, in that it pretty much disables all dead stripping. Whether that matters depends on your exact circumstances.

Again, I recommend that you read the ld man page to learn more about these options. It’s terminology is… well… dense, so you might want to avail yourself of An Apple Library Primer.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Alternatives to exports file for using Xcode frameworks in iOS
 
 
Q