diff --git a/Generator/Sources/NeedleFramework/Generating/Serializers/DependencyProviderClassSerializer.swift b/Generator/Sources/NeedleFramework/Generating/Serializers/DependencyProviderClassSerializer.swift index da76c77c..2617126b 100644 --- a/Generator/Sources/NeedleFramework/Generating/Serializers/DependencyProviderClassSerializer.swift +++ b/Generator/Sources/NeedleFramework/Generating/Serializers/DependencyProviderClassSerializer.swift @@ -49,6 +49,7 @@ final class DependencyProviderClassSerializer: Serializer { } return """ + @MainActor private class \(classNameSerializer.serialize()): \(provider.unprocessed.dependency.name) { \(propertiesSerializer.serialize()) \(sourceComponentsSerializer.serialize()) diff --git a/Generator/Sources/NeedleFramework/Generating/Serializers/OutputSerializer.swift b/Generator/Sources/NeedleFramework/Generating/Serializers/OutputSerializer.swift index fb051a88..423ad865 100644 --- a/Generator/Sources/NeedleFramework/Generating/Serializers/OutputSerializer.swift +++ b/Generator/Sources/NeedleFramework/Generating/Serializers/OutputSerializer.swift @@ -132,6 +132,7 @@ class OutputSerializer: Serializer { \(registrationHelpers) + @MainActor public func registerProviderFactories() { \(registrationBody) } diff --git a/Generator/Sources/NeedleFramework/Generating/Serializers/Pluginized/PluginExtensionContentSerializer.swift b/Generator/Sources/NeedleFramework/Generating/Serializers/Pluginized/PluginExtensionContentSerializer.swift index cc347131..cb309bbc 100644 --- a/Generator/Sources/NeedleFramework/Generating/Serializers/Pluginized/PluginExtensionContentSerializer.swift +++ b/Generator/Sources/NeedleFramework/Generating/Serializers/Pluginized/PluginExtensionContentSerializer.swift @@ -41,6 +41,7 @@ class PluginExtensionContentSerializer: Serializer { let nonCoreComponentPropertyName = component.nonCoreComponent.name.lowercasedFirstChar() return """ + @MainActor /// \(component.data.name) plugin extension private class \(extensionClassName): \(component.pluginExtension.name) { \(properties) diff --git a/Sources/NeedleFoundation/Component.swift b/Sources/NeedleFoundation/Component.swift index 0ac6fc70..da38f3bb 100644 --- a/Sources/NeedleFoundation/Component.swift +++ b/Sources/NeedleFoundation/Component.swift @@ -17,11 +17,13 @@ import Foundation /// The base protocol of a dependency, enabling Needle's parsing process. +@MainActor public protocol Dependency: AnyObject {} /// The base protocol of a DI scope. Application code should inherit /// from the `Component` base class, instead of using this protocol /// directly. +@MainActor public protocol Scope: AnyObject { /// The path to reach this component on the dependnecy graph. var path: [String] { get } @@ -35,6 +37,7 @@ public protocol Scope: AnyObject { /// contains a set of properties it provides to units of its scope as well /// as child scopes. A component instantiates child components that define /// child scopes. +@MainActor @dynamicMemberLookup open class Component: Scope { diff --git a/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift b/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift index c5d8ff8b..ccd43633 100644 --- a/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift +++ b/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift @@ -26,6 +26,7 @@ import Foundation // method in the base component class. Generate extensions to all the // component subclasses that override the method to instantiate the // dependnecy providers. +@MainActor public class __DependencyProviderRegistry { /// The singleton instance. diff --git a/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift b/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift index 2d85c93e..edcc3982 100644 --- a/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift +++ b/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift @@ -25,6 +25,7 @@ import Foundation // method in the base pluginized component class. Generate extensions to // all the pluginized component subclasses that override the method to // instantiate the dependnecy providers. +@MainActor public class __PluginExtensionProviderRegistry { /// The singleton instance.