Does adding a file to multiple targets increases binary size?

Imagine I have a big file in my main target and I have another target NotificationService to process notifications. If I add that big file also as a target for my NotificationService, will that file end up eating twice as much disk space? Or will it create a symlink and be efficient?

Or will it create a symlink and be efficient?

That definitely doesn’t happen.

The traditional way to handle this is to put the code and its associated resources in a framework and then have both the app and the appex reference that framework.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

So does this means I can add files to multiple targets without increasing the binary size of my app?

So does this means I can add files to multiple targets without
increasing the binary size of my app?

No. A framework is a new target. So, the idea is to have three targets:

  • Your app

  • Your appex

  • Your framework

If add the file to the framework target and the app and appex import the framework and use its functionality.

Note that the framework will engender some overhead, so it only makes sense to do this if the file — or, in the case of Swift code, the generated code — is big enough to outweigh that overhead.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

Aaaaaah. Now I get it. Thanks!

1 Like