Skip to content

Commit

Permalink
Add Constant And Module Object
Browse files Browse the repository at this point in the history
  • Loading branch information
jihoonahn committed Dec 13, 2024
1 parent ce5002c commit c18949c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ProjectDescriptionHelpers/Constant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ProjectDescription

/// Constant value Property wrapper
///
/// Used for Constant Management.
/// ```swift
/// @Constant var env = Constants()
/// ```
@propertyWrapper public struct Constant<ObjectType> where ObjectType: ModuleObject {
private var value: ObjectType

public init(wrappedValue: ObjectType) {
self.value = wrappedValue
}

public var wrappedValue: ObjectType { value }

public var projectedValue: Constant<ObjectType> {
get { return self }
}
}
13 changes: 13 additions & 0 deletions ProjectDescriptionHelpers/Object/ModuleObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ProjectDescription

/// ModuleObject Type
/// Helps manage module variables that are used repeatedly by Tuist.
///
/// ```swift
/// struct Constants: ModuleObject {
/// static var version: String! = "x.y.z"
/// static let config = AppConfig()
///}
/// ```
///
public protocol ModuleObject {}

0 comments on commit c18949c

Please sign in to comment.