xcode ios项目结构是否有最佳实践或约定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7480575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:58:38  来源:igfitidea点击:

Is there any best practices or conventions for ios project structure

iosxcodenaming-conventionsdirectory-structureconventions

提问by itsaboutcode

I was wondering if there is any best practices or conventions to structure your iOS projects?

我想知道是否有任何最佳实践或约定来构建您的 iOS 项目?

Thanks.

谢谢。

回答by Chris Conway

Taken from iOS Coding Best PracticesSlideshare from Jean-Luc David:

摘自Jean-Luc David 的iOS 编码最佳实践Slideshare:

enter image description here

在此处输入图片说明

回答by Vitaly Kotivskyi

As for me, Architecting iOS Projectsolution works perfectly. I also added Cocoapods.

对我来说,Architecting iOS Project解决方案非常有效。我还添加了 Cocoapods。

Now my project looks like:

现在我的项目看起来像:

enter image description here

在此处输入图片说明

回答by Randika Vishman

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.

但是在浏览了这个线程和其他一些在线文章之后,我决定在一个新的文件夹代码 UI 下对几种类型进行分类。

  • Application (Config file with constants, AppDelegate)
  • Models
  • UI
    • Views
    • Controllers
    • If I use Nib files (.Xib)they should come under this or else the storyboard(s)
  • Resources (All resources like Images, Custom fonts, Audio files with each in different subfolders)
  • Services
  • Helpers/Utilities
  • Libraries
  • 应用程序(带有常量的配置文件,AppDelegate)
  • 楷模
  • 用户界面
    • 观看次数
    • 控制器
    • 如果我使用Nib 文件 (.Xib),它们应该属于这个或故事板(s)
  • 资源(所有资源,如图像、自定义字体、音频文件,每个资源都在不同的子文件夹中)
  • 服务
  • 助手/实用程序
  • 图书馆

But if you are using MVVM architecture, please customize this to your best fit.

但是,如果您使用的是 MVVM 架构,请根据您的需要进行自定义。

Cheers!

干杯!

回答by daneejela

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...

尽管我同意最常见的做法是按类型(即 ViewControllers、Models 等)对文件进行分组,但我要补充的是,在某些业务案例中,通过提供的功能组织代码更有用。例如,如果您为提供多种服务组合的公司工作,这些服务通常打包到共享某些元素的不同应用程序中,例如 - 地址簿、消息、文档管理等...

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.

在我的项目中,我通常有一个名为 Common 的文件夹,我将经常重复使用的东西放在其中,例如日期时间助手、IO 编写器等……我按功能分隔的其他东西。

回答by A.G

We follow a standard project structure so as the team can understand in a better way.

我们遵循标准的项目结构,以便团队可以更好地理解。

enter image description here

在此处输入图片说明