3 ms·
I believe the new Swift compiler announced at WWDC does dead code removal, so including a large library for not a lot of actual use should affect the binary siz
by danpalmer 9y ago
I believe the new Swift compiler announced at WWDC does dead code removal, so including a large library for not a lot of actual use should affect the binary size much less now.
- pjmlp 9y agoYou can already do it with Swift 3 as well, provided you enable LTO, with the side effect of slower build times.
- majewsky 9y agoI'm not familiar with Swift, but I'd be weary of treating dead-code removal as an excuse for piling on libraries. Deciding whether code is actually dead looks like a halting-problem-level type of problem. For example, if I write the following Golang code: str := "World" fmt.Printf("Hello %s\n", str) Then the compiler pulls in the entire fmt library, which can render all kinds of datatypes as part of Printf(); there are even reflection-based format strings like %#v which generates a Go literal for the value that you pass in. Without knowing how Printf() works, the compiler cannot understand that I'm never going to visit these branches of the Printf() function, so it cannot tree-shake these (or any of the functions called by these branches).