From 7d672cc52eb4a54aa522af9a40fa2214467dc503 Mon Sep 17 00:00:00 2001 From: Petr Chmelar Date: Wed, 20 Jul 2022 14:36:05 +0200 Subject: [PATCH] Add SPM support --- Package.swift | 35 ++++++++++ README.md | 9 +++ Sources/C/include/.gitkeep | 0 Sources/{ => C}/ytcpsocket.c | 0 Sources/{ => C}/yudpsocket.c | 0 Sources/{ => Swift}/Result.swift | 0 Sources/{ => Swift}/Socket.swift | 0 Sources/{ => Swift}/TCPClient.swift | 0 Sources/{ => Swift}/UDPClient.swift | 0 SwiftSocket.podspec | 4 +- SwiftSocket.xcodeproj/project.pbxproj | 96 +++++++++++++-------------- 11 files changed, 94 insertions(+), 50 deletions(-) create mode 100644 Package.swift create mode 100644 Sources/C/include/.gitkeep rename Sources/{ => C}/ytcpsocket.c (100%) rename Sources/{ => C}/yudpsocket.c (100%) rename Sources/{ => Swift}/Result.swift (100%) rename Sources/{ => Swift}/Socket.swift (100%) rename Sources/{ => Swift}/TCPClient.swift (100%) rename Sources/{ => Swift}/UDPClient.swift (100%) diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..54aa604 --- /dev/null +++ b/Package.swift @@ -0,0 +1,35 @@ +// swift-tools-version: 5.6 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftSocket", + platforms: [ + .iOS(.v9), + .macOS(.v10_10), + .tvOS(.v9) + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "SwiftSocket", + targets: [ + "SwiftSocketC", + "SwiftSocket" + ] + ) + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "SwiftSocketC", + path: "Sources/C" + ), + .target( + name: "SwiftSocket", + path: "Sources/Swift" + ) + ] +) diff --git a/README.md b/README.md index ab02a56..8d8a2b1 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,15 @@ And run then `pod install` github "swiftsocket/SwiftSocket" ``` +## Swift Package Manager +The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. +Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. +```swift +dependencies: [ + .package(url: "https://github.com/swiftsocket/SwiftSocket", .upToNextMajor(from: "2.0.0")) +] +``` + # Code examples ## Create client socket diff --git a/Sources/C/include/.gitkeep b/Sources/C/include/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Sources/ytcpsocket.c b/Sources/C/ytcpsocket.c similarity index 100% rename from Sources/ytcpsocket.c rename to Sources/C/ytcpsocket.c diff --git a/Sources/yudpsocket.c b/Sources/C/yudpsocket.c similarity index 100% rename from Sources/yudpsocket.c rename to Sources/C/yudpsocket.c diff --git a/Sources/Result.swift b/Sources/Swift/Result.swift similarity index 100% rename from Sources/Result.swift rename to Sources/Swift/Result.swift diff --git a/Sources/Socket.swift b/Sources/Swift/Socket.swift similarity index 100% rename from Sources/Socket.swift rename to Sources/Swift/Socket.swift diff --git a/Sources/TCPClient.swift b/Sources/Swift/TCPClient.swift similarity index 100% rename from Sources/TCPClient.swift rename to Sources/Swift/TCPClient.swift diff --git a/Sources/UDPClient.swift b/Sources/Swift/UDPClient.swift similarity index 100% rename from Sources/UDPClient.swift rename to Sources/Swift/UDPClient.swift diff --git a/SwiftSocket.podspec b/SwiftSocket.podspec index be00bbb..88cd361 100644 --- a/SwiftSocket.podspec +++ b/SwiftSocket.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'SwiftSocket' - s.version = '2.0.2' + s.version = '2.2.0' s.summary = 'A cool framework to work with TCP and UDP sockets' s.description = <<-DESC @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.author = { 'Dan Shevlyuk' => 'danshevlyuk@icloud.com' } s.social_media_url = 'http://twitter.com/danshevluk' - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' s.source = { diff --git a/SwiftSocket.xcodeproj/project.pbxproj b/SwiftSocket.xcodeproj/project.pbxproj index 0e42045..445277e 100644 --- a/SwiftSocket.xcodeproj/project.pbxproj +++ b/SwiftSocket.xcodeproj/project.pbxproj @@ -8,42 +8,36 @@ /* Begin PBXBuildFile section */ 3723138F1DCF84CA0042DA87 /* SwiftSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 3723138D1DCF84CA0042DA87 /* SwiftSocket.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 372313921DCF84D80042DA87 /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313901DCF84D80042DA87 /* UDPClient.swift */; }; - 372313931DCF84D80042DA87 /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313911DCF84D80042DA87 /* yudpsocket.c */; }; - 372313961DCF84E30042DA87 /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313941DCF84E30042DA87 /* TCPClient.swift */; }; - 372313971DCF84E30042DA87 /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313951DCF84E30042DA87 /* ytcpsocket.c */; }; - 3723139A1DCF84EC0042DA87 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313981DCF84EC0042DA87 /* Result.swift */; }; - 3723139B1DCF84EC0042DA87 /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313991DCF84EC0042DA87 /* Socket.swift */; }; 3723139C1DCF85270042DA87 /* SwiftSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 3723138D1DCF84CA0042DA87 /* SwiftSocket.h */; settings = {ATTRIBUTES = (Public, ); }; }; 37454ED71E0615FE00800AE5 /* SwiftSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 3723138D1DCF84CA0042DA87 /* SwiftSocket.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 37454ED81E06163C00800AE5 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313981DCF84EC0042DA87 /* Result.swift */; }; - 37454ED91E06163C00800AE5 /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313991DCF84EC0042DA87 /* Socket.swift */; }; - 37454EDA1E06163C00800AE5 /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313941DCF84E30042DA87 /* TCPClient.swift */; }; - 37454EDB1E06163C00800AE5 /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313951DCF84E30042DA87 /* ytcpsocket.c */; }; - 37454EDC1E06163C00800AE5 /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313901DCF84D80042DA87 /* UDPClient.swift */; }; - 37454EDD1E06163C00800AE5 /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313911DCF84D80042DA87 /* yudpsocket.c */; }; - 37454EDF1E06163D00800AE5 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313981DCF84EC0042DA87 /* Result.swift */; }; - 37454EE01E06163D00800AE5 /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313991DCF84EC0042DA87 /* Socket.swift */; }; - 37454EE11E06163D00800AE5 /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313941DCF84E30042DA87 /* TCPClient.swift */; }; - 37454EE21E06163D00800AE5 /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313951DCF84E30042DA87 /* ytcpsocket.c */; }; - 37454EE31E06163D00800AE5 /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372313901DCF84D80042DA87 /* UDPClient.swift */; }; - 37454EE41E06163D00800AE5 /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 372313911DCF84D80042DA87 /* yudpsocket.c */; }; 375C48301DDC4C56008C701D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 375C482F1DDC4C56008C701D /* AppDelegate.swift */; }; 375C48321DDC4C56008C701D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 375C48311DDC4C56008C701D /* ViewController.swift */; }; 375C48351DDC4C56008C701D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375C48331DDC4C56008C701D /* Main.storyboard */; }; 375C48371DDC4C56008C701D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 375C48361DDC4C56008C701D /* Assets.xcassets */; }; 375C483A1DDC4C56008C701D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375C48381DDC4C56008C701D /* LaunchScreen.storyboard */; }; + 4564C901288841CB00138EBD /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C8FF288841CB00138EBD /* Socket.swift */; }; + 4564C902288841CB00138EBD /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C8FF288841CB00138EBD /* Socket.swift */; }; + 4564C903288841CB00138EBD /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C8FF288841CB00138EBD /* Socket.swift */; }; + 4564C904288841CB00138EBD /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C900288841CB00138EBD /* Result.swift */; }; + 4564C905288841CB00138EBD /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C900288841CB00138EBD /* Result.swift */; }; + 4564C906288841CB00138EBD /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C900288841CB00138EBD /* Result.swift */; }; + 4564C908288841D300138EBD /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C907288841D300138EBD /* TCPClient.swift */; }; + 4564C909288841D300138EBD /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C907288841D300138EBD /* TCPClient.swift */; }; + 4564C90A288841D300138EBD /* TCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C907288841D300138EBD /* TCPClient.swift */; }; + 4564C90C288841DD00138EBD /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90B288841DD00138EBD /* UDPClient.swift */; }; + 4564C90D288841DD00138EBD /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90B288841DD00138EBD /* UDPClient.swift */; }; + 4564C90E288841DD00138EBD /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90B288841DD00138EBD /* UDPClient.swift */; }; + 4564C910288841E400138EBD /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90F288841E400138EBD /* ytcpsocket.c */; }; + 4564C911288841E400138EBD /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90F288841E400138EBD /* ytcpsocket.c */; }; + 4564C912288841E400138EBD /* ytcpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C90F288841E400138EBD /* ytcpsocket.c */; }; + 4564C914288841EC00138EBD /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C913288841EC00138EBD /* yudpsocket.c */; }; + 4564C915288841EC00138EBD /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C913288841EC00138EBD /* yudpsocket.c */; }; + 4564C916288841EC00138EBD /* yudpsocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4564C913288841EC00138EBD /* yudpsocket.c */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 3723138C1DCF84CA0042DA87 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Sources/Info.plist; sourceTree = SOURCE_ROOT; }; 3723138D1DCF84CA0042DA87 /* SwiftSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SwiftSocket.h; path = Sources/SwiftSocket.h; sourceTree = SOURCE_ROOT; }; - 372313901DCF84D80042DA87 /* UDPClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UDPClient.swift; path = Sources/UDPClient.swift; sourceTree = SOURCE_ROOT; }; - 372313911DCF84D80042DA87 /* yudpsocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yudpsocket.c; path = Sources/yudpsocket.c; sourceTree = SOURCE_ROOT; }; - 372313941DCF84E30042DA87 /* TCPClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TCPClient.swift; path = Sources/TCPClient.swift; sourceTree = SOURCE_ROOT; }; - 372313951DCF84E30042DA87 /* ytcpsocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ytcpsocket.c; path = Sources/ytcpsocket.c; sourceTree = SOURCE_ROOT; }; - 372313981DCF84EC0042DA87 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Sources/Result.swift; sourceTree = SOURCE_ROOT; }; - 372313991DCF84EC0042DA87 /* Socket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Socket.swift; path = Sources/Socket.swift; sourceTree = SOURCE_ROOT; }; 37454ECA1E06158200800AE5 /* SwiftSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 37454EE81E0617F300800AE5 /* Info-tvOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Info-tvOS.plist"; path = "Sources/Info-tvOS.plist"; sourceTree = SOURCE_ROOT; }; 375C482D1DDC4C56008C701D /* iOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -55,6 +49,12 @@ 375C483B1DDC4C56008C701D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 377DAA691DCDE40200009697 /* SwiftSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 377DAA761DCDE45D00009697 /* SwiftSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4564C8FF288841CB00138EBD /* Socket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Socket.swift; path = Sources/Swift/Socket.swift; sourceTree = SOURCE_ROOT; }; + 4564C900288841CB00138EBD /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Sources/Swift/Result.swift; sourceTree = SOURCE_ROOT; }; + 4564C907288841D300138EBD /* TCPClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TCPClient.swift; path = Sources/Swift/TCPClient.swift; sourceTree = SOURCE_ROOT; }; + 4564C90B288841DD00138EBD /* UDPClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UDPClient.swift; path = Sources/Swift/UDPClient.swift; sourceTree = SOURCE_ROOT; }; + 4564C90F288841E400138EBD /* ytcpsocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ytcpsocket.c; path = Sources/C/ytcpsocket.c; sourceTree = SOURCE_ROOT; }; + 4564C913288841EC00138EBD /* yudpsocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yudpsocket.c; path = Sources/C/yudpsocket.c; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -92,8 +92,8 @@ 375BC51D1DCDE86B006AD8F6 /* TCPSocket */ = { isa = PBXGroup; children = ( - 372313941DCF84E30042DA87 /* TCPClient.swift */, - 372313951DCF84E30042DA87 /* ytcpsocket.c */, + 4564C907288841D300138EBD /* TCPClient.swift */, + 4564C90F288841E400138EBD /* ytcpsocket.c */, ); name = TCPSocket; sourceTree = ""; @@ -101,8 +101,8 @@ 375BC51E1DCDE878006AD8F6 /* UDPSocket */ = { isa = PBXGroup; children = ( - 372313901DCF84D80042DA87 /* UDPClient.swift */, - 372313911DCF84D80042DA87 /* yudpsocket.c */, + 4564C90B288841DD00138EBD /* UDPClient.swift */, + 4564C913288841EC00138EBD /* yudpsocket.c */, ); name = UDPSocket; sourceTree = ""; @@ -154,8 +154,8 @@ 5518C83119A329100049DC22 /* Source */ = { isa = PBXGroup; children = ( - 372313981DCF84EC0042DA87 /* Result.swift */, - 372313991DCF84EC0042DA87 /* Socket.swift */, + 4564C900288841CB00138EBD /* Result.swift */, + 4564C8FF288841CB00138EBD /* Socket.swift */, 375BC51D1DCDE86B006AD8F6 /* TCPSocket */, 375BC51E1DCDE878006AD8F6 /* UDPSocket */, 377DAA6A1DCDE40200009697 /* Supporting Files */, @@ -357,12 +357,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 37454EE31E06163D00800AE5 /* UDPClient.swift in Sources */, - 37454EE01E06163D00800AE5 /* Socket.swift in Sources */, - 37454EE41E06163D00800AE5 /* yudpsocket.c in Sources */, - 37454EDF1E06163D00800AE5 /* Result.swift in Sources */, - 37454EE21E06163D00800AE5 /* ytcpsocket.c in Sources */, - 37454EE11E06163D00800AE5 /* TCPClient.swift in Sources */, + 4564C916288841EC00138EBD /* yudpsocket.c in Sources */, + 4564C90A288841D300138EBD /* TCPClient.swift in Sources */, + 4564C90E288841DD00138EBD /* UDPClient.swift in Sources */, + 4564C903288841CB00138EBD /* Socket.swift in Sources */, + 4564C906288841CB00138EBD /* Result.swift in Sources */, + 4564C912288841E400138EBD /* ytcpsocket.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -379,12 +379,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 372313931DCF84D80042DA87 /* yudpsocket.c in Sources */, - 3723139A1DCF84EC0042DA87 /* Result.swift in Sources */, - 3723139B1DCF84EC0042DA87 /* Socket.swift in Sources */, - 372313921DCF84D80042DA87 /* UDPClient.swift in Sources */, - 372313971DCF84E30042DA87 /* ytcpsocket.c in Sources */, - 372313961DCF84E30042DA87 /* TCPClient.swift in Sources */, + 4564C914288841EC00138EBD /* yudpsocket.c in Sources */, + 4564C908288841D300138EBD /* TCPClient.swift in Sources */, + 4564C90C288841DD00138EBD /* UDPClient.swift in Sources */, + 4564C901288841CB00138EBD /* Socket.swift in Sources */, + 4564C904288841CB00138EBD /* Result.swift in Sources */, + 4564C910288841E400138EBD /* ytcpsocket.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -392,12 +392,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 37454EDC1E06163C00800AE5 /* UDPClient.swift in Sources */, - 37454ED91E06163C00800AE5 /* Socket.swift in Sources */, - 37454EDD1E06163C00800AE5 /* yudpsocket.c in Sources */, - 37454ED81E06163C00800AE5 /* Result.swift in Sources */, - 37454EDB1E06163C00800AE5 /* ytcpsocket.c in Sources */, - 37454EDA1E06163C00800AE5 /* TCPClient.swift in Sources */, + 4564C915288841EC00138EBD /* yudpsocket.c in Sources */, + 4564C909288841D300138EBD /* TCPClient.swift in Sources */, + 4564C90D288841DD00138EBD /* UDPClient.swift in Sources */, + 4564C902288841CB00138EBD /* Socket.swift in Sources */, + 4564C905288841CB00138EBD /* Result.swift in Sources */, + 4564C911288841E400138EBD /* ytcpsocket.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };