I have a bunch of code I am using in multiple projects. Right now, I am doing it by copy-and-paste, which is less t开发者_如何学JAVAhan ideal. As I understand it, to have multiple projects refer to the same source code, I have at least two options:
1) Create a static library and include it in multiple projects
2) Create a project with the shared source code, and import that into all of the other projects.
What are the advantages and disadvantages of these approaches? When might I prefer one over the other?
You can include project with static library, which will use all advantages from static library and included project :) It works well, cannot say anything about significant disadvantages of such approach.
The only disadvantage of including a static external librairy to your project would be the size of it; if you are using a library that will be "universal" (working on the simulator + the device), you'll have to target i386 and arm (today armv7). So you will inflate your project with "dead code" that can't be used on for your mobile solution.
If you include a project with share source code, you'll be able to compile just what you need for you mobile device, but everybody can see your code ...
精彩评论