Home > Software design >  Does adding a file to multiple targets increases binary size?
Does adding a file to multiple targets increases binary size?

Time:01-24

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?

CodePudding user response:

If the file is a resource, it will be included in the resource directory of each target. If it is source code, it will be compiled separately and linked into each target. So, yes, it will take up twice as much space.

If you don't want that and your NotificationService is a dependency of the main target, you can provide a public API in the NotificationService target to get the file or its content, if it is a resource. If it's Swift code, you can just make some of its APIs public and import it as a module in your main target.

  • Related