diff --git a/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart b/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart index da822b9b9..274cc170c 100644 --- a/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart +++ b/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart @@ -104,10 +104,15 @@ List _generateClassProperties(ClassDeclaration declaration) { return declaration.properties.map( (property) { final header = StringBuffer(); + if (property.hasObjCAnnotation) { header.write('@objc '); } + if (property.isStatic) { + header.write('static '); + } + header.write('public var ${property.name}: ${property.type.name} {'); final getterLines = [ diff --git a/pkgs/swift2objc/test/integration/classes_and_static_properties_output.swift b/pkgs/swift2objc/test/integration/classes_and_static_properties_output.swift index cb6dd16c6..bb6a4d13f 100644 --- a/pkgs/swift2objc/test/integration/classes_and_static_properties_output.swift +++ b/pkgs/swift2objc/test/integration/classes_and_static_properties_output.swift @@ -13,13 +13,13 @@ import Foundation @objc public class MyClassWrapper: NSObject { var wrappedInstance: MyClass - @objc public var customGetterVariable: MyOtherClassWrapper { + @objc static public var customGetterVariable: MyOtherClassWrapper { get { MyOtherClassWrapper(MyClass.customGetterVariable) } } - @objc public var customSetterVariable: MyOtherClassWrapper { + @objc static public var customSetterVariable: MyOtherClassWrapper { get { MyOtherClassWrapper(MyClass.customSetterVariable) } @@ -28,13 +28,13 @@ import Foundation } } - @objc public var customConstantProperty: MyOtherClassWrapper { + @objc static public var customConstantProperty: MyOtherClassWrapper { get { MyOtherClassWrapper(MyClass.customConstantProperty) } } - @objc public var customVariableProperty: MyOtherClassWrapper { + @objc static public var customVariableProperty: MyOtherClassWrapper { get { MyOtherClassWrapper(MyClass.customVariableProperty) } @@ -43,13 +43,13 @@ import Foundation } } - @objc public var representableGetterVariable: Int { + @objc static public var representableGetterVariable: Int { get { MyClass.representableGetterVariable } } - @objc public var representableSetterVariable: Int { + @objc static public var representableSetterVariable: Int { get { MyClass.representableSetterVariable } @@ -58,13 +58,13 @@ import Foundation } } - @objc public var representableConstantProperty: Int { + @objc static public var representableConstantProperty: Int { get { MyClass.representableConstantProperty } } - @objc public var representableVariableProperty: Int { + @objc static public var representableVariableProperty: Int { get { MyClass.representableVariableProperty } diff --git a/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift b/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift index 5aceef0f6..79e680af0 100644 --- a/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift +++ b/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift @@ -3,13 +3,13 @@ import Foundation @objc public class GlobalsWrapper: NSObject { - @objc public var globalCustomConstantWrapper: MyOtherClassWrapper { + @objc static public var globalCustomConstantWrapper: MyOtherClassWrapper { get { MyOtherClassWrapper(globalCustomConstant) } } - @objc public var globalCustomVariableWrapper: MyOtherClassWrapper { + @objc static public var globalCustomVariableWrapper: MyOtherClassWrapper { get { MyOtherClassWrapper(globalCustomVariable) } @@ -18,13 +18,13 @@ import Foundation } } - @objc public var globalRepresentableConstantWrapper: Int { + @objc static public var globalRepresentableConstantWrapper: Int { get { globalRepresentableConstant } } - @objc public var globalRepresentableVariableWrapper: Int { + @objc static public var globalRepresentableVariableWrapper: Int { get { globalRepresentableVariable } diff --git a/pkgs/swift2objc/test/integration/structs_and_static_properties_output.swift b/pkgs/swift2objc/test/integration/structs_and_static_properties_output.swift index ed417f169..7633573ed 100644 --- a/pkgs/swift2objc/test/integration/structs_and_static_properties_output.swift +++ b/pkgs/swift2objc/test/integration/structs_and_static_properties_output.swift @@ -13,13 +13,13 @@ import Foundation @objc public class MyStructWrapper: NSObject { var wrappedInstance: MyStruct - @objc public var customGetterVariable: MyOtherStructWrapper { + @objc static public var customGetterVariable: MyOtherStructWrapper { get { MyOtherStructWrapper(MyStruct.customGetterVariable) } } - @objc public var customSetterVariable: MyOtherStructWrapper { + @objc static public var customSetterVariable: MyOtherStructWrapper { get { MyOtherStructWrapper(MyStruct.customSetterVariable) } @@ -28,13 +28,13 @@ import Foundation } } - @objc public var customConstantProperty: MyOtherStructWrapper { + @objc static public var customConstantProperty: MyOtherStructWrapper { get { MyOtherStructWrapper(MyStruct.customConstantProperty) } } - @objc public var customVariableProperty: MyOtherStructWrapper { + @objc static public var customVariableProperty: MyOtherStructWrapper { get { MyOtherStructWrapper(MyStruct.customVariableProperty) } @@ -43,13 +43,13 @@ import Foundation } } - @objc public var representableGetterVariable: Int { + @objc static public var representableGetterVariable: Int { get { MyStruct.representableGetterVariable } } - @objc public var representableSetterVariable: Int { + @objc static public var representableSetterVariable: Int { get { MyStruct.representableSetterVariable } @@ -58,13 +58,13 @@ import Foundation } } - @objc public var representableConstantProperty: Int { + @objc static public var representableConstantProperty: Int { get { MyStruct.representableConstantProperty } } - @objc public var representableVariableProperty: Int { + @objc static public var representableVariableProperty: Int { get { MyStruct.representableVariableProperty }