Factory icon indicating copy to clipboard operation
Factory copied to clipboard

why remove Aliases file?

Open brave723 opened this issue 2 months ago • 0 comments

Why was the Aliases file removed from FactoryKit?

Problem

The Aliases.swift file was removed from FactoryKit, causing naming conflicts and breaking backward compatibility, especially for CocoaPods users.

Current Situation

The aliases that were previously available:

public typealias FactoryAutoRegistering = AutoRegistering
public typealias FactoryContainer = Container
public typealias FactoryContainerManager = ContainerManager
public typealias FactoryManagedContainer = ManagedContainer
public typealias FactoryResolving = Resolving
public typealias FactoryScope = Scope
public typealias FactorySharedContainer = SharedContainer

This file exists in Sources/Factory/Factory/Aliases.swift but NOT in Sources/FactoryKit/FactoryKit/Aliases.swift.

Impact

1. CocoaPods Users

According to Factory.podspec:

  • Pod name: Factory → module name is Factory (users import as import Factory)
  • Source files: Sources/FactoryKit/**/*.swiftno Aliases.swift included

Result: CocoaPods users who import Factory cannot use FactoryContainer, FactoryScope, etc., even though these aliases were specifically added in version 2.3.1 (Issue #154) to avoid naming conflicts.

2. Naming Conflicts with Other Libraries

When using FactoryKit together with libraries like XCoordinator, both define a Container type:

  • FactoryKit: public final class Container
  • XCoordinator: protocol Container

Without aliases, this causes compiler errors or ambiguous type references.

Example conflict:

import Factory
import XCoordinator  // Also has a Container protocol

// This fails without FactoryContainer alias
extension Container {  // ❌ Ambiguous: which Container?
    var myService: Factory<MyServiceType> {
        self { MyService() }
    }
}

Expected Behavior

Users should be able to use aliases to avoid naming conflicts:

import Factory  // CocoaPods, or import FactoryKit via SPM

extension FactoryContainer {  // ✅ Clear, no ambiguity
    var myService: Factory<MyServiceType> {
        self { MyService() }
    }
}

Workaround

Currently, users have to:

  1. Use module qualifiers: FactoryKit.Container (but this doesn't work for CocoaPods users using import Factory)
  2. Create their own aliases file in their project (workaround, not a solution)

Proposed Solution

Please restore the Aliases.swift file in Sources/FactoryKit/FactoryKit/ to:

  1. ✅ Support CocoaPods users who import as Factory
  2. ✅ Provide a clean way to avoid naming conflicts with other libraries (like XCoordinator)
  3. ✅ Maintain backward compatibility with code that relies on these aliases

The aliases were specifically added to address naming conflicts (Issue #154), and their removal breaks this functionality, especially for CocoaPods users.

Environment

  • Factory version: 2.5.3
  • Installation method: CocoaPods
  • Use case: Integration with XCoordinator (which also has a Container protocol)

brave723 avatar Nov 03 '25 05:11 brave723