How do You structure an iPhone Xcode project?

前端 未结 3 1078
面向向阳花
面向向阳花 2021-01-30 02:38

What are good ways of building groups/folders?

I\'ve tried by feature (UI for a feature plus model etc) with a common group. I\'ve also tried by UI, model, etc.

相关标签:
3条回答
  • 2021-01-30 02:59

    The standard Xcode MVC folder structure is as follows.

    1. CoreData : Contains DataModel and Entity Classes.

    2. Extension : Contain One class(default apple class extensions+project class extensions.)

    3. Helper: Contain Third Party classes/Frameworks (eg. SWRevealController) + Bridging classes (eg. Obj C class in Swift based project)

    4. Model : Make a singleton class (eg.AppModel - NSArray,NSDictionary, String etc.) for saving data. The Web Service Response parsing and storing data is also done here.

    5. Services : Contain Web Service processes (eg. Login Verification, HTTP Request/Response)

    6. View : Contain storyboard, LaunchScreen.XIB and View Classes. Make a sub folder Cells - contain UITableViewCell, UICollectionViewCell etc.

    7. Controller: Contain Logic or Code related to UIElements (eg. UIButton’s reference+ clicked action)

    0 讨论(0)
  • 2021-01-30 03:08

    It's going to be very project dependent. In my last project I had mostly views, and so I organized the views by view-type.

    0 讨论(0)
  • 2021-01-30 03:24

    Although John has a point, I actually created a project to demonstrate what I consider my general go-to Xcode project structure for a small or mid-sized code base. You can find it here.

    Here's an outline of it:

    • Source - All source code
      • Account - Account-related classes (session-related classes, account logic, etc)
      • Application - Application-related classes. App delegate, configuration classes, etc
      • Core Additions - Extensions and subclasses stemming from apple's classes
        • Utilities - General utility classes. Useful extensions, formatting utilities, convenience classes and such
        • Element-based folders - Folder for UIView, UITableViewCell, etc
      • Local Persistence - Local persistence layer. All interactions with local database (realm, core data)
        • Repositories - All model-related local persistence logic
      • Constants - All constants. URLs, fonts, colors, errors, etc
      • Models - All models (server-side entities' representation). We would also throw here any object mapping logic
      • Modules - Here we can find each of the application's pieces divided by functionality
        • Module-based folders - Each folder contains all module-specific view controllers, views, delegates and related classes
      • Networking - The app's networking layer (e.g. classes responsible for interacting with web services)
        • Services - All model-related web logic
    • Storyboards - Contains all storyboard files
    • Resources - Any additionaly resources like media, documents, localization files and such
    0 讨论(0)
提交回复
热议问题