Wednesday, February 25, 2026
HomeiOS DevelopmentConventions for Xcode - The.Swift.Dev.

Conventions for Xcode – The.Swift.Dev.


Discover ways to set up your codebase. In case you are fighting Xcode mission construction, recordsdata, naming conventions, learn this.

Apple has a lot frameworks and APIs that I don’t even know lots of them. We’re additionally residing within the age of software extensions. In case you are making an attempt to create a model new goal in Xcode, you would possibly find yourself scratching your head. 🤔

Conventions for Xcode – The.Swift.Dev.

That is nice for each for builders and end-users, however after creating a couple of targets and platforms (your mission grows and) you would possibly ask the query:

How ought to I organise my codebase?

Don’t fear an excessive amount of about it, I may need the best reply for you! 😉

The issue with complicated tasks

You possibly can create apps in Xcode for all the foremost working programs: iOS, macOS, tvOS, watchOS. Within the newest model of Xcode you too can add greater than 20 extension only for iOS, plus there are many app extensions accessible for macOS as nicely. Think about a posh software with a number of extensions & targets. This case can result in inconsistent bundle identifiers and extra ad-hoc naming options. Oh, by the best way watchOS purposes are only a particular extensions for iOS targets and don’t neglect about your assessments, these are particular person targets as nicely! ⚠️

So far as I can see, in case you are making an attempt to help a number of platforms you’re going to have quite a lot of targets inside your Xcode mission, moreover each new goal will comprise some sort of supply recordsdata and belongings. Ought to I point out schemes too? 😂

Even Apple eliminated it’s Lister pattern code, that demonstrated certainly one of a hellish Xcode mission with 14 targets, 11 schemes, however the general mission contained solely 71 Swift supply recordsdata. That’s not an excessive amount of code, however you may see the problem right here, proper?

It’s time to learn to organise your mission! 💡

Xcode mission group

So my primary concept is to have an affordable naming conceptand folder construction contained in the mission. This entails targets, schemes, bundle identifiers, location of supply recordsdata and belongings on the disk. Let’s begin with a easy instance that comprises a number of targets to have a greater understanding. 🤓

NOTE: In case you are utilizing the Swift Package deal Supervisor eg. for Swift backends, SPM will generate your Xcode mission recordsdata for you, so that you shoudn’t care an excessive amount of about conventions and namings in any respect. 🤷‍♂️

Challenge title

Are you creating a brand new software? Be happy to call your mission as you need. 😉

Are you going to make a framework? Lengthen your mission title with the Equipment suffix. Individuals often choose to make use of the ProjectKit type for libraries in order that’s the right technique to go. If in case you have a killer title, use that as an alternative of the package type! 😛

Out there platforms

At all times use the next platform names:

Goal naming conference

Identify your targets like:

[platform] [template name]

Don’t embrace mission title within the targets (that might be only a duplicate)
Use the extension names from the brand new goal window (eg. Right this moment Extension)
Use “Utility” template title for the primary software targets
Use “Framework” as template title for framework targets
Order your targets in a logical means (see the instance)

Scheme names

Merely use goal names for schemes too (prefix with mission title if required).

[project] - [platform] [template name]

You possibly can prefix schemes together with your mission title if you would like, however the generic rule is right here to make use of the very same title as your goal. I additionally wish to separate framework schemes visually from the schems that comprise software logic, that’s why I at all times transfer them to the highest of the listing. Nevertheless a greater strategy is to separate frameworks right into a standalone git repository & join them by way of a package deal supervisor. 📦

Bundle identifiers

This one is difficult due to code signing. You possibly can go along with one thing like this:

[reverse domain].[project].[platform].[template name]

Listed here are the principles:

  • Begin together with your reverse area title (com.instance)
  • After the area, insert your mission title
  • Embody platform names, apart from iOS, I don’t append that one.
  • Use the template title as a suffix (like .todayextension)
  • Don’t add software as a template title
  • Use .watchkitapp, .watchkitextension for legacy watchOS targets
  • Don’t use greater than 4 dots (see instance under)!

NOTE: If you’re going to use com.instance.mission.ios.as we speak.extension that’s not going to work, as a result of it comprises greater than 4 dots. So it’s best to merely go along with com.instance.mission.ios.todayextension and names like that. 😢

Anyway, simply at all times attempt to signal your app and undergo the shop. Good luck. 🍀

Challenge folders

The factor is that I at all times create bodily folders on the disk. Should you make a gaggle in Xcode, nicely by default that’s not going to be an precise folder and all of your supply recordsdata and belongings will likely be positioned underneath the mission’s foremost listing.

I do know it’s a private choice however I don’t wish to name a large “wasteland” of recordsdata as a mission. I’ve seen many chaotic tasks with out correct file group. 🤐

It doesn’t matter what, however I at all times comply with this primary sample:

  • Create folders for the targets
  • Create a Sources folder for the Swift supply recordsdata
  • Create an Belongings folder for all the pieces else (pictures, and so forth).

Below the Sources I at all times make extra subfolders for particular person VIPER modules, or just for controllers, fashions, objects, and so forth.

Instance use case

Here’s a fast instance mission in Xcode that makes use of my conventions.

Xcode naming conventions

As you may see I adopted the sample from above. Let’s assume that my mission title is TheSwiftDev. Here’s a fast overview of the complete setup:

Goal & scheme names (with bundle identifiers):

  • iOS Utility (com.tiborbodecs.theswiftdev)
  • iOS Utility Unit Checks (n/a)
  • iOS Utility UI Checks (n/a)
  • iOS Right this moment Extension (com.tiborbodecs.theswiftdev.todayextension)
  • watchOS Utility (com.tiborbodecs.theswiftdev.watchos)
  • watchOS Utility Extension (com.tiborbodecs.theswiftdev.watchos.extension)
  • tvOS Utility (com.tiborbodecs.theswiftdev.macos)
  • macOS Utility (com.tiborbodecs.theswiftdev.tvos)

NOTE: Should you rename your iOS goal with a WatchKit companion app, watch out!!! You even have to vary the WKCompanionAppBundleIdentifier property inside your watch software goal’s Data.plist file by hand. ⚠️

This technique would possibly seems like an overkill at first sight, however belief me it’s price to comply with these conventions. As your app grows, finally you’ll face the identical points as I discussed to start with. It’s higher to have a plan for the long run.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments