ios项目结构有没有最佳实践或约定
我想知道是否有任何最佳实践或约定来构建您的 iOS 项目?
谢谢。
I was wondering if there is any best practices or conventions to structure your iOS projects?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
摘自 Jean-Luc David 的 iOS 编码最佳实践 Slideshare:
Taken from iOS Coding Best Practices Slideshare from Jean-Luc David:
对我来说,架构 iOS 项目 解决方案工作得很好。我还添加了 Cocoapods。
现在我的项目看起来像:
As for me, Architecting iOS Project solution works perfectly. I also added Cocoapods.
Now my project looks like:
我一直在我的项目中使用与以下类似的工具。
但在浏览完这个帖子和其他一些在线文章后,我决定在新的文件夹代码 UI 下对几种类型进行分类。
但是如果您使用的是 MVVM 架构,请根据您的情况进行自定义。
干杯!
I've been using a similar one to the following for my projects.
But after going through this thread and some other articles online, I decided to categorize few types under a new folder code UI.
But if you are using MVVM architecture, please customize this to your best fit.
Cheers!
尽管我同意最常见的做法是按类型(即 ViewController、模型等)对文件进行分组,但我想补充一点,在某些业务案例中,按提供的功能组织代码更有用。例如,如果您在提供多种服务组合的公司工作,这些服务通常打包到共享某些元素的不同应用程序中,例如地址簿、消息、文档管理等...
在我的项目中,我通常有一个名为 Common 的文件夹,其中我放置了我经常重复使用的东西,比如日期时间助手、IO 编写器等......
其他的东西我按功能分开。
Although I agree that most common practice is to have files grouped by types (i.e. ViewControllers, Models etc.), I would add that there are some business cases where it is more useful to organize code by provided functionality. For example if you work for company that offers multiple combination of services, usually packed into different apps that share some of elements, for example - AddressBook, Messages, Document Management, etc...
In my projects I usually have a folder called Common where I put things that I reuse often, like datetime helpers, IO writers etc...
Other things I separate by functionality.
我们遵循标准的项目结构,以便团队能够更好地理解。
We follow a standard project structure so as the team can understand in a better way.