Latest 0.1.0
License MIT
Platforms ios 8.0


IdentifierKit allows you to easily replace String and Int identifier with strongly typed identifiers.


  • [x] 💪 Strongly typed identifiers
  • [x] 🐟 Full Codeable compatibility


  • iOS 8.0+
  • Xcode 9.3
  • Swift 4.1



pod 'IdentifierKit'


github "NicholasFFox/IdentifierKit"

Swift Package Manager

  • Coming Soon


Use IdentifierKit to replace weakly typed String and Int identifiers in your model layer with strongly typed identifier objects.

Step 1: Create an unique type to represent your identifier – empty enums work great for this!

enum UserIdentifier: Identifier {}

Step 2: Use a typealias to give yourself syntactic sugar and avoid typing the generic syntax everywhere.

typealias UserId = IntIdentifier<UserIdentifier>

Step 3: Replace your Int (or String) identifer with your newly created type.

struct User: Codable {
  let id: UserId
  let firstName: String
  let lastName: String

IdentifierKit works seamlessly with the Codable protocol, so you won’t have to make any changes to your existing JSON.

let json = """
  "id": 2,
  "firstName": "Tim",
  "lastName": "Cook"
""".data(using: .utf8)!

let user = try JSONDecoder().decode(User.self, from: json)


Thanks to Daniel Steinberg for inspiring this framework with your talk on phantom types.


IdentifierKit is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "IdentifierKit",
    "version": "0.1.0",
    "summary": "Strongly typed identifiers for your model layer.",
    "description": "Replace your Int/String identifiers with strongly typed Identifier objects.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": "Nick Fox",
    "source": {
        "git": "",
        "tag": "0.1.0"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "IdentifierKit/**/*",
    "swift_version": "4.1"

Pin It on Pinterest

Share This