### Swift Package Manager Installation Source: https://github.com/hainayanda/swiftenvironment/blob/main/README.md Instructions for installing the SwiftEnvironment library using Swift Package Manager, both via Xcode and directly in the Package.swift file. ```swift dependencies: [ .package(url: "https://github.com/hainayanda/SwiftEnvironment.git", .upToNextMajor(from: "4.1.4")) ] ``` ```swift .target( name: "MyModule", dependencies: ["SwiftEnvironment"] ) ``` -------------------------------- ### Setting Global Values Source: https://github.com/hainayanda/swiftenvironment/blob/main/README.md Illustrates different methods for setting global values, including basic setting, transient values (new instantiation on access), and weak references (allowing deallocation). ```swift GlobalValues.environment(\.myValue, SomeNewValue()) ``` ```swift GlobalValues.transient(\.myValue, SomeNewValue()) ``` ```swift GlobalValues.weak(\.myValue, SomeNewValue()) ``` -------------------------------- ### Advanced Global Value Options Source: https://github.com/hainayanda/swiftenvironment/blob/main/README.md Explains advanced options for setting global values, such as using closures for value creation and specifying the DispatchQueue for value access. ```swift GlobalValues.environment(\.myValue) { SomeNewValue() } ``` ```swift GlobalValues.environment(\.myValue, resolveOn: .main, SomeNewValue()) ``` -------------------------------- ### Defining Global Values with @GlobalEntry Source: https://github.com/hainayanda/swiftenvironment/blob/main/README.md Demonstrates how to define global values using the `@GlobalEntry` macro within an extension of `GlobalValues`. ```swift extension GlobalValues { @GlobalEntry var myValue: SomeDependency = SomeDependency() } ``` -------------------------------- ### Accessing Global Values Source: https://github.com/hainayanda/swiftenvironment/blob/main/README.md Shows how to access globally defined values directly or by using the `@GlobalEnvironment` property wrapper in SwiftUI views for automatic updates. ```swift let value = GlobalValue.myValue ``` ```swift @GlobalEnvironment(\myValue) var myValue struct MyView: View { @GlobalEnvironment(\myValue) var myValue var body: some View { Text(myValue.description) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.