Browse Source

Fix HelloWorld examples (#1512)

Resolves #1511
George Barnett 3 years ago
parent
commit
0332b34990

+ 8 - 0
Sources/Examples/HelloWorld/Client/main.swift → Sources/Examples/HelloWorld/Client/HelloWorldClient.swift

@@ -21,6 +21,7 @@ import NIOCore
 import NIOPosix
 
 @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+@main
 struct HelloWorld: AsyncParsableCommand {
   @Option(help: "The port to connect to")
   var port: Int = 1234
@@ -67,4 +68,11 @@ struct HelloWorld: AsyncParsableCommand {
     }
   }
 }
+#else
+@main
+enum HelloWorld {
+  static func main() {
+    fatalError("This example requires swift >= 5.6")
+  }
+}
 #endif // compiler(>=5.6)

+ 8 - 0
Sources/Examples/HelloWorld/Server/main.swift → Sources/Examples/HelloWorld/Server/HelloWorldServer.swift

@@ -21,6 +21,7 @@ import NIOCore
 import NIOPosix
 
 @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+@main
 struct HelloWorld: AsyncParsableCommand {
   @Option(help: "The port to listen on for new connections")
   var port = 1234
@@ -43,4 +44,11 @@ struct HelloWorld: AsyncParsableCommand {
     try await server.onClose.get()
   }
 }
+#else
+@main
+enum HelloWorld {
+  static func main() {
+    fatalError("This example requires swift >= 5.6")
+  }
+}
 #endif // compiler(>=5.6)