How do You structure an iPhone Xcode project?

前端 未结 3 1167
面向向阳花
面向向阳花 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 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

提交回复
热议问题