From c3b05cde3043eca8d980a88d76bda4b640395343 Mon Sep 17 00:00:00 2001 From: Sergey Lem Date: Fri, 28 Sep 2018 13:20:22 +0100 Subject: [PATCH 1/4] Squashed commit of the following: commit 467334e818f188ef75c9c16a76133c7f7582b3cb Author: Sergey Lem Date: Fri Sep 28 10:47:53 2018 +0100 Remove old file commit 631c25645abc0b083fdf09f886e153e02ea4b05f Author: Sergey Lem Date: Fri Sep 28 09:51:15 2018 +0100 Fix project settings commit d629a65c20f16146764da0bed7d5fcbe193f37c6 Merge: 6371914 7f12731 Author: Sergey Lem Date: Wed Sep 26 14:58:20 2018 +0100 Merge branch 'master' of github.com:turbulem/Starscream # Conflicts: # Starscream.xcodeproj/project.pbxproj commit 637191444a9889bf777b9e4969786ab98be7a0c7 Author: Sergey Lem Date: Mon Sep 10 09:45:21 2018 +0100 Add NSString+SHA1 to test target commit 33846d16f51b2850e3a578c8b7f6a5e27a98002e Author: Sergey Lem Date: Mon Sep 10 09:40:09 2018 +0100 Fix project inclusion and add missing linker flag commit 74e3c637e5c349ed0fa307356f16bad762000b50 Author: Sergey Lem Date: Wed Jul 25 10:47:16 2018 +0100 Pull master branch from daltoniam/Starscream commit 912e7da6a18eeac452e3272f901f962031ce6376 Author: Sergey Lem Date: Thu Jun 28 11:30:51 2018 +0100 Fix return type for SHA1 digest and cast warning commit 70234bc6bb434ed94cf186832f833fc10c87d2f2 Author: Sergey Lem Date: Mon Jun 25 13:18:18 2018 +0100 Add custom wrapper for SHA1 and custom modulemap for framework including module maps for CommonCrypto and zlib commit 94f8d58d0b48a3916907498cb1097a1fa1eb6a57 Author: Sergey Lem Date: Thu Jun 14 18:52:14 2018 +0100 Move CommonCrypto and zlib dependencies mapping to private module map commit 7f12731d14d6f7dadabb44697a880647b938ecc4 Author: Sergey Lem Date: Mon Sep 10 09:45:21 2018 +0100 Add NSString+SHA1 to test target commit 8df9d1ebf9abce0db184708700e90b4b429a7f2b Author: Sergey Lem Date: Mon Sep 10 09:40:09 2018 +0100 Fix project inclusion and add missing linker flag commit bd0732e53b784d45cff9db3c5812034ae2c0b45e Merge: 138cfa7 70fd033 Author: Sergey Lem Date: Wed Jul 25 10:48:22 2018 +0100 Merge branch 'master' # Conflicts: # Starscream.xcodeproj/project.pbxproj commit 138cfa76a3e213a6b9ec4074d3f0f8d4db420ad5 Author: Sergey Lem Date: Wed Jul 25 10:47:16 2018 +0100 Pull master branch from daltoniam/Starscream commit ca783dbcae4b60fcaa62727b9c1eb52978e07648 Author: Sergey Lem Date: Thu Jun 28 11:30:51 2018 +0100 Fix return type for SHA1 digest and cast warning commit 8ca8df0edc39ea1f2e25a827d0bdd998530755c5 Author: Sergey Lem Date: Mon Jun 25 13:18:18 2018 +0100 Add custom wrapper for SHA1 and custom modulemap for framework including module maps for CommonCrypto and zlib commit 98e1d6207cb1ac6d7eea8f1b4d552369805c1c7f Author: Sergey Lem Date: Thu Jun 14 18:52:14 2018 +0100 Move CommonCrypto and zlib dependencies mapping to private module map --- Sources/Starscream/Compression.swift | 2 +- Sources/Starscream/WebSocket.swift | 7 +- .../modulemap/CommonCrypto/NSString+SHA1.h | 29 ++++++ .../modulemap/CommonCrypto/NSString+SHA1.m | 35 +++++++ Sources/modulemap/Starscream.modulemap | 16 +++ Sources/modulemap/zlib/include.h | 1 + Starscream.podspec | 9 +- Starscream.xcodeproj/project.pbxproj | 97 ++++++++++++------- zlib/include.h | 2 - zlib/module.modulemap | 9 -- 10 files changed, 152 insertions(+), 55 deletions(-) create mode 100644 Sources/modulemap/CommonCrypto/NSString+SHA1.h create mode 100644 Sources/modulemap/CommonCrypto/NSString+SHA1.m create mode 100644 Sources/modulemap/Starscream.modulemap create mode 100644 Sources/modulemap/zlib/include.h delete mode 100644 zlib/include.h delete mode 100644 zlib/module.modulemap diff --git a/Sources/Starscream/Compression.swift b/Sources/Starscream/Compression.swift index f20ff75a..b6bf45ac 100644 --- a/Sources/Starscream/Compression.swift +++ b/Sources/Starscream/Compression.swift @@ -27,7 +27,7 @@ ////////////////////////////////////////////////////////////////////////////////////////////////// import Foundation -import SSCZLib +import Starscream.SSCZLib class Decompressor { private var strm = z_stream() diff --git a/Sources/Starscream/WebSocket.swift b/Sources/Starscream/WebSocket.swift index 788a34b2..124b7784 100644 --- a/Sources/Starscream/WebSocket.swift +++ b/Sources/Starscream/WebSocket.swift @@ -21,7 +21,7 @@ import Foundation import CoreFoundation -import SSCommonCrypto +import Starscream.SSCommonCrypto public let WebsocketDidConnectNotification = "WebsocketDidConnectNotification" public let WebsocketDidDisconnectNotification = "WebsocketDidDisconnectNotification" @@ -1318,10 +1318,7 @@ open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelega private extension String { func sha1Base64() -> String { - let data = self.data(using: String.Encoding.utf8)! - var digest = [UInt8](repeating: 0, count:Int(CC_SHA1_DIGEST_LENGTH)) - data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) } - return Data(bytes: digest).base64EncodedString() + return (self as NSString).ss_SHA1Base64Digest() } } diff --git a/Sources/modulemap/CommonCrypto/NSString+SHA1.h b/Sources/modulemap/CommonCrypto/NSString+SHA1.h new file mode 100644 index 00000000..4a2206e3 --- /dev/null +++ b/Sources/modulemap/CommonCrypto/NSString+SHA1.h @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// NSString+SHA1.h +// Starscream +// +// Created by Sergey Lem on 6/25/18. +// Copyright (c) 2014-2016 Dalton Cherry. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +#import + +@interface NSString (SHA1) + +- (NSString *)ss_SHA1Base64Digest; + +@end diff --git a/Sources/modulemap/CommonCrypto/NSString+SHA1.m b/Sources/modulemap/CommonCrypto/NSString+SHA1.m new file mode 100644 index 00000000..b091ac01 --- /dev/null +++ b/Sources/modulemap/CommonCrypto/NSString+SHA1.m @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// NSString+SHA1.m +// Starscream +// +// Created by Sergey Lem on 6/25/18. +// Copyright (c) 2014-2016 Dalton Cherry. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +#import "NSString+SHA1.h" +#import + +@implementation NSString (SHA1) + +- (NSString *)ss_SHA1Base64Digest { + NSData *stringData = [self dataUsingEncoding:NSUTF8StringEncoding]; + NSMutableData *digest = [NSMutableData dataWithLength:CC_SHA1_DIGEST_LENGTH]; + CC_SHA1(stringData.bytes, (CC_LONG)stringData.length, digest.mutableBytes); + return [[NSString alloc] initWithData:[digest base64EncodedDataWithOptions:0] encoding:NSUTF8StringEncoding]; +} + +@end diff --git a/Sources/modulemap/Starscream.modulemap b/Sources/modulemap/Starscream.modulemap new file mode 100644 index 00000000..cbaddbfa --- /dev/null +++ b/Sources/modulemap/Starscream.modulemap @@ -0,0 +1,16 @@ +framework module Starscream { + umbrella header "Starscream.h" + + export * + + explicit module SSCZLib [system] { + header "include.h" + link "z" + export * + } + explicit module SSCommonCrypto [system] { + private header "NSString+SHA1.h" + link "CommonCrypto" + export * + } +} diff --git a/Sources/modulemap/zlib/include.h b/Sources/modulemap/zlib/include.h new file mode 100644 index 00000000..4470a1fd --- /dev/null +++ b/Sources/modulemap/zlib/include.h @@ -0,0 +1 @@ +#include diff --git a/Starscream.podspec b/Starscream.podspec index 3d81d07e..76b5e3fb 100644 --- a/Starscream.podspec +++ b/Starscream.podspec @@ -11,11 +11,10 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' - s.source_files = 'Sources/*.swift' - s.libraries = 'z' + s.source_files = 'Sources/**/*.{h,m,swift}' + s.module_map = 'Sources/modulemap/Starscream.modulemap' + s.private_header_files = 'Sources/modulemap/**/*.h' s.pod_target_xcconfig = { - 'SWIFT_VERSION' => '4.1', - 'SWIFT_INCLUDE_PATHS' => '$(PODS_ROOT)/Starscream/zlib' + 'SWIFT_VERSION' => '4.1' } - s.preserve_paths = 'zlib/*' end diff --git a/Starscream.xcodeproj/project.pbxproj b/Starscream.xcodeproj/project.pbxproj index 1f855573..d491350c 100644 --- a/Starscream.xcodeproj/project.pbxproj +++ b/Starscream.xcodeproj/project.pbxproj @@ -12,12 +12,18 @@ 335FA1FC1F5DF71D00F6D2EC /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAF811ED4DFD3004FE2C3 /* libz.tbd */; }; 33CCF08A1F5DDC030099B092 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAF811ED4DFD3004FE2C3 /* libz.tbd */; }; 33CCF08C1F5DDC030099B092 /* Starscream.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1360001C473BEF00AA3A01 /* Starscream.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 33CCF08D1F5DDC030099B092 /* include.h in Headers */ = {isa = PBXBuildFile; fileRef = D85927D71ED76F25003460CB /* include.h */; }; - 742D12982157CF56006026D7 /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33CCF0921F5DDC030099B092 /* Starscream.framework */; }; - DD52B623663980FECD3F6690 /* Compression.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B83305DE12CC7F8887D6 /* Compression.swift */; }; - DD52B7C033385CD7CF246CC5 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B820CB852287AC065D9C /* WebSocket.swift */; }; - DD52BC079AD583D2DA35D7E7 /* SSLClientCertificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B329FF434097A6C8F66E /* SSLClientCertificate.swift */; }; - DD52BED25D3DBBB3BC28471B /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B3F585852EF29B21F0DB /* SSLSecurity.swift */; }; + 33CCF08D1F5DDC030099B092 /* include.h in Headers */ = {isa = PBXBuildFile; fileRef = D85927D71ED76F25003460CB /* include.h */; settings = {ATTRIBUTES = (Private, ); }; }; + BB1018E821087F1900BA9E60 /* NSString+SHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */; settings = {ATTRIBUTES = (Private, ); }; }; + BB93FF0021466450005BCEF7 /* NSString+SHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */; }; + BB93FF012146664D005BCEF7 /* NSString+SHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */; }; + BBB5ABE5215E2217005B48B6 /* Compression.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE1215E2217005B48B6 /* Compression.swift */; }; + BBB5ABE6215E2217005B48B6 /* SSLClientCertificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */; }; + BBB5ABE7215E2217005B48B6 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */; }; + BBB5ABE8215E2217005B48B6 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE4215E2217005B48B6 /* WebSocket.swift */; }; + BBB5ABE9215E221D005B48B6 /* Compression.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE1215E2217005B48B6 /* Compression.swift */; }; + BBB5ABEA215E221D005B48B6 /* SSLClientCertificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */; }; + BBB5ABEB215E221D005B48B6 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */; }; + BBB5ABEC215E221D005B48B6 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE4215E2217005B48B6 /* WebSocket.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -25,19 +31,18 @@ 33CCF0921F5DDC030099B092 /* Starscream.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Starscream.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5C1360001C473BEF00AA3A01 /* Starscream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Starscream.h; path = Sources/Starscream.h; sourceTree = SOURCE_ROOT; }; 5C13600C1C473BFE00AA3A01 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Sources/Info.plist; sourceTree = SOURCE_ROOT; }; - 5CAAB5D01F7987D800F3C556 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS4.0.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; 6B3E7A0019D48C2F006071F7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 742419BB1DC6BDBA003ACE43 /* StarscreamTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StarscreamTests.swift; path = StarscreamTests/StarscreamTests.swift; sourceTree = ""; }; - D85927D61ED761A0003460CB /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; }; + BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+SHA1.h"; sourceTree = ""; }; + BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+SHA1.m"; sourceTree = ""; }; + BBB5ABE1215E2217005B48B6 /* Compression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Compression.swift; path = Starscream/Compression.swift; sourceTree = ""; }; + BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLClientCertificate.swift; path = Starscream/SSLClientCertificate.swift; sourceTree = ""; }; + BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Starscream/SSLSecurity.swift; sourceTree = ""; }; + BBB5ABE4215E2217005B48B6 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Starscream/WebSocket.swift; sourceTree = ""; }; + BBC59F4D20D2D71500713D9C /* Starscream.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Starscream.modulemap; sourceTree = ""; }; D85927D71ED76F25003460CB /* include.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = include.h; sourceTree = ""; }; D88EAF811ED4DFD3004FE2C3 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; D88EAF831ED4E7D8004FE2C3 /* CompressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompressionTests.swift; sourceTree = ""; }; - D88EAF8D1ED4E92E004FE2C3 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; - D88EAF901ED4E949004FE2C3 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.2.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; - DD52B329FF434097A6C8F66E /* SSLClientCertificate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLClientCertificate.swift; path = Starscream/SSLClientCertificate.swift; sourceTree = ""; }; - DD52B3F585852EF29B21F0DB /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Starscream/SSLSecurity.swift; sourceTree = ""; }; - DD52B820CB852287AC065D9C /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Starscream/WebSocket.swift; sourceTree = ""; }; - DD52B83305DE12CC7F8887D6 /* Compression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Compression.swift; path = Starscream/Compression.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -45,7 +50,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 742D12982157CF56006026D7 /* Starscream.framework in Frameworks */, 335FA1FC1F5DF71D00F6D2EC /* libz.tbd in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -64,7 +68,6 @@ 6B3E79DC19D48B7F006071F7 = { isa = PBXGroup; children = ( - D85927D51ED761A0003460CB /* zlib */, 6B3E79E819D48B7F006071F7 /* Sources */, 6B3E79FF19D48C2F006071F7 /* Tests */, 6B3E79E719D48B7F006071F7 /* Products */, @@ -84,12 +87,13 @@ 6B3E79E819D48B7F006071F7 /* Sources */ = { isa = PBXGroup; children = ( + BBB5ABE1215E2217005B48B6 /* Compression.swift */, + BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */, + BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */, + BBB5ABE4215E2217005B48B6 /* WebSocket.swift */, + BB8A648320E1123400527BA5 /* modulemap */, 5C1360001C473BEF00AA3A01 /* Starscream.h */, 6B3E79E919D48B7F006071F7 /* Supporting Files */, - DD52B820CB852287AC065D9C /* WebSocket.swift */, - DD52B329FF434097A6C8F66E /* SSLClientCertificate.swift */, - DD52B3F585852EF29B21F0DB /* SSLSecurity.swift */, - DD52B83305DE12CC7F8887D6 /* Compression.swift */, ); path = Sources; sourceTree = ""; @@ -112,21 +116,36 @@ path = Tests; sourceTree = ""; }; - D85927D51ED761A0003460CB /* zlib */ = { + BB8A647D20E1102900527BA5 /* CommonCrypto */ = { + isa = PBXGroup; + children = ( + BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */, + BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */, + ); + path = CommonCrypto; + sourceTree = ""; + }; + BB8A648220E111F200527BA5 /* zlib */ = { isa = PBXGroup; children = ( - D85927D61ED761A0003460CB /* module.modulemap */, D85927D71ED76F25003460CB /* include.h */, ); path = zlib; sourceTree = ""; }; + BB8A648320E1123400527BA5 /* modulemap */ = { + isa = PBXGroup; + children = ( + BBC59F4D20D2D71500713D9C /* Starscream.modulemap */, + BB8A647D20E1102900527BA5 /* CommonCrypto */, + BB8A648220E111F200527BA5 /* zlib */, + ); + path = modulemap; + sourceTree = ""; + }; D88EAF801ED4DFD3004FE2C3 /* Frameworks */ = { isa = PBXGroup; children = ( - 5CAAB5D01F7987D800F3C556 /* libz.tbd */, - D88EAF901ED4E949004FE2C3 /* libz.tbd */, - D88EAF8D1ED4E92E004FE2C3 /* libz.tbd */, D88EAF811ED4DFD3004FE2C3 /* libz.tbd */, ); name = Frameworks; @@ -140,6 +159,7 @@ buildActionMask = 2147483647; files = ( 33CCF08C1F5DDC030099B092 /* Starscream.h in Headers */, + BB1018E821087F1900BA9E60 /* NSString+SHA1.h in Headers */, 33CCF08D1F5DDC030099B092 /* include.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -196,6 +216,9 @@ 335FA1F41F5DF71D00F6D2EC = { LastSwiftMigration = 0900; }; + 33CCF0841F5DDC030099B092 = { + LastSwiftMigration = 0940; + }; }; }; buildConfigurationList = 6B3E79E019D48B7F006071F7 /* Build configuration list for PBXProject "Starscream" */; @@ -238,8 +261,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BBB5ABEB215E221D005B48B6 /* SSLSecurity.swift in Sources */, + BBB5ABEC215E221D005B48B6 /* WebSocket.swift in Sources */, + BBB5ABE9215E221D005B48B6 /* Compression.swift in Sources */, 335FA1F91F5DF71D00F6D2EC /* CompressionTests.swift in Sources */, + BB93FF012146664D005BCEF7 /* NSString+SHA1.m in Sources */, 335FA1FA1F5DF71D00F6D2EC /* StarscreamTests.swift in Sources */, + BBB5ABEA215E221D005B48B6 /* SSLClientCertificate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -247,10 +275,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - DD52B7C033385CD7CF246CC5 /* WebSocket.swift in Sources */, - DD52BC079AD583D2DA35D7E7 /* SSLClientCertificate.swift in Sources */, - DD52BED25D3DBBB3BC28471B /* SSLSecurity.swift in Sources */, - DD52B623663980FECD3F6690 /* Compression.swift in Sources */, + BBB5ABE5215E2217005B48B6 /* Compression.swift in Sources */, + BBB5ABE8215E2217005B48B6 /* WebSocket.swift in Sources */, + BBB5ABE7215E2217005B48B6 /* SSLSecurity.swift in Sources */, + BBB5ABE6215E2217005B48B6 /* SSLClientCertificate.swift in Sources */, + BB93FF0021466450005BCEF7 /* NSString+SHA1.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -278,6 +307,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator macosx"; + SWIFT_INSTALL_OBJC_HEADER = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; SWIFT_VERSION = 4.0; @@ -301,6 +331,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator macosx"; + SWIFT_INSTALL_OBJC_HEADER = NO; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; SWIFT_VERSION = 4.0; @@ -324,7 +355,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - OTHER_LDFLAGS = ""; + MODULEMAP_FILE = $SRCROOT/Sources/modulemap/Starscream.modulemap; + OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; @@ -357,7 +389,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - OTHER_LDFLAGS = ""; + MODULEMAP_FILE = $SRCROOT/Sources/modulemap/Starscream.modulemap; + OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; @@ -424,7 +457,6 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator watchsimulator watchos"; - SWIFT_INCLUDE_PATHS = $SRCROOT/zlib; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; @@ -477,7 +509,6 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator watchsimulator watchos"; - SWIFT_INCLUDE_PATHS = $SRCROOT/zlib; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; VALIDATE_PRODUCT = YES; diff --git a/zlib/include.h b/zlib/include.h deleted file mode 100644 index cb3747f2..00000000 --- a/zlib/include.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/zlib/module.modulemap b/zlib/module.modulemap deleted file mode 100644 index ed0676f3..00000000 --- a/zlib/module.modulemap +++ /dev/null @@ -1,9 +0,0 @@ -module SSCZLib [system] { - header "include.h" - link "z" - export * -} -module SSCommonCrypto [system] { - header "include.h" - export * -} From dceb95c4ea822829a44d6915a446e5205f1c62a0 Mon Sep 17 00:00:00 2001 From: Sergey Lem Date: Mon, 1 Oct 2018 11:44:36 +0100 Subject: [PATCH 2/4] Remove custom module maps for CC and zlib, use system-provided ones --- Sources/Starscream/Compression.swift | 2 +- Sources/Starscream/WebSocket.swift | 9 +++- .../modulemap/CommonCrypto/NSString+SHA1.h | 29 ------------- .../modulemap/CommonCrypto/NSString+SHA1.m | 35 ---------------- Sources/modulemap/Starscream.modulemap | 16 ------- Sources/modulemap/zlib/include.h | 1 - Starscream.xcodeproj/project.pbxproj | 42 ------------------- 7 files changed, 8 insertions(+), 126 deletions(-) delete mode 100644 Sources/modulemap/CommonCrypto/NSString+SHA1.h delete mode 100644 Sources/modulemap/CommonCrypto/NSString+SHA1.m delete mode 100644 Sources/modulemap/Starscream.modulemap delete mode 100644 Sources/modulemap/zlib/include.h diff --git a/Sources/Starscream/Compression.swift b/Sources/Starscream/Compression.swift index b6bf45ac..ab657902 100644 --- a/Sources/Starscream/Compression.swift +++ b/Sources/Starscream/Compression.swift @@ -27,7 +27,7 @@ ////////////////////////////////////////////////////////////////////////////////////////////////// import Foundation -import Starscream.SSCZLib +import zlib class Decompressor { private var strm = z_stream() diff --git a/Sources/Starscream/WebSocket.swift b/Sources/Starscream/WebSocket.swift index 124b7784..e3314ac1 100644 --- a/Sources/Starscream/WebSocket.swift +++ b/Sources/Starscream/WebSocket.swift @@ -21,7 +21,7 @@ import Foundation import CoreFoundation -import Starscream.SSCommonCrypto +import CommonCrypto public let WebsocketDidConnectNotification = "WebsocketDidConnectNotification" public let WebsocketDidDisconnectNotification = "WebsocketDidDisconnectNotification" @@ -1318,7 +1318,12 @@ open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelega private extension String { func sha1Base64() -> String { - return (self as NSString).ss_SHA1Base64Digest() + guard let data = self.data(using: .utf8) else { return "" } + var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH)) + _ = data.withUnsafeBytes { (ptr: UnsafePointer) in + CC_SHA1(ptr, CC_LONG(data.count), &digest) + } + return digest.reduce("", { $0 + String(format: "%02x", $1) }) } } diff --git a/Sources/modulemap/CommonCrypto/NSString+SHA1.h b/Sources/modulemap/CommonCrypto/NSString+SHA1.h deleted file mode 100644 index 4a2206e3..00000000 --- a/Sources/modulemap/CommonCrypto/NSString+SHA1.h +++ /dev/null @@ -1,29 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NSString+SHA1.h -// Starscream -// -// Created by Sergey Lem on 6/25/18. -// Copyright (c) 2014-2016 Dalton Cherry. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#import - -@interface NSString (SHA1) - -- (NSString *)ss_SHA1Base64Digest; - -@end diff --git a/Sources/modulemap/CommonCrypto/NSString+SHA1.m b/Sources/modulemap/CommonCrypto/NSString+SHA1.m deleted file mode 100644 index b091ac01..00000000 --- a/Sources/modulemap/CommonCrypto/NSString+SHA1.m +++ /dev/null @@ -1,35 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NSString+SHA1.m -// Starscream -// -// Created by Sergey Lem on 6/25/18. -// Copyright (c) 2014-2016 Dalton Cherry. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#import "NSString+SHA1.h" -#import - -@implementation NSString (SHA1) - -- (NSString *)ss_SHA1Base64Digest { - NSData *stringData = [self dataUsingEncoding:NSUTF8StringEncoding]; - NSMutableData *digest = [NSMutableData dataWithLength:CC_SHA1_DIGEST_LENGTH]; - CC_SHA1(stringData.bytes, (CC_LONG)stringData.length, digest.mutableBytes); - return [[NSString alloc] initWithData:[digest base64EncodedDataWithOptions:0] encoding:NSUTF8StringEncoding]; -} - -@end diff --git a/Sources/modulemap/Starscream.modulemap b/Sources/modulemap/Starscream.modulemap deleted file mode 100644 index cbaddbfa..00000000 --- a/Sources/modulemap/Starscream.modulemap +++ /dev/null @@ -1,16 +0,0 @@ -framework module Starscream { - umbrella header "Starscream.h" - - export * - - explicit module SSCZLib [system] { - header "include.h" - link "z" - export * - } - explicit module SSCommonCrypto [system] { - private header "NSString+SHA1.h" - link "CommonCrypto" - export * - } -} diff --git a/Sources/modulemap/zlib/include.h b/Sources/modulemap/zlib/include.h deleted file mode 100644 index 4470a1fd..00000000 --- a/Sources/modulemap/zlib/include.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/Starscream.xcodeproj/project.pbxproj b/Starscream.xcodeproj/project.pbxproj index d491350c..753e0cf0 100644 --- a/Starscream.xcodeproj/project.pbxproj +++ b/Starscream.xcodeproj/project.pbxproj @@ -12,10 +12,6 @@ 335FA1FC1F5DF71D00F6D2EC /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAF811ED4DFD3004FE2C3 /* libz.tbd */; }; 33CCF08A1F5DDC030099B092 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAF811ED4DFD3004FE2C3 /* libz.tbd */; }; 33CCF08C1F5DDC030099B092 /* Starscream.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1360001C473BEF00AA3A01 /* Starscream.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 33CCF08D1F5DDC030099B092 /* include.h in Headers */ = {isa = PBXBuildFile; fileRef = D85927D71ED76F25003460CB /* include.h */; settings = {ATTRIBUTES = (Private, ); }; }; - BB1018E821087F1900BA9E60 /* NSString+SHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */; settings = {ATTRIBUTES = (Private, ); }; }; - BB93FF0021466450005BCEF7 /* NSString+SHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */; }; - BB93FF012146664D005BCEF7 /* NSString+SHA1.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */; }; BBB5ABE5215E2217005B48B6 /* Compression.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE1215E2217005B48B6 /* Compression.swift */; }; BBB5ABE6215E2217005B48B6 /* SSLClientCertificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */; }; BBB5ABE7215E2217005B48B6 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */; }; @@ -33,14 +29,10 @@ 5C13600C1C473BFE00AA3A01 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Sources/Info.plist; sourceTree = SOURCE_ROOT; }; 6B3E7A0019D48C2F006071F7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 742419BB1DC6BDBA003ACE43 /* StarscreamTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StarscreamTests.swift; path = StarscreamTests/StarscreamTests.swift; sourceTree = ""; }; - BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+SHA1.h"; sourceTree = ""; }; - BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+SHA1.m"; sourceTree = ""; }; BBB5ABE1215E2217005B48B6 /* Compression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Compression.swift; path = Starscream/Compression.swift; sourceTree = ""; }; BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLClientCertificate.swift; path = Starscream/SSLClientCertificate.swift; sourceTree = ""; }; BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Starscream/SSLSecurity.swift; sourceTree = ""; }; BBB5ABE4215E2217005B48B6 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Starscream/WebSocket.swift; sourceTree = ""; }; - BBC59F4D20D2D71500713D9C /* Starscream.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Starscream.modulemap; sourceTree = ""; }; - D85927D71ED76F25003460CB /* include.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = include.h; sourceTree = ""; }; D88EAF811ED4DFD3004FE2C3 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; D88EAF831ED4E7D8004FE2C3 /* CompressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompressionTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -91,7 +83,6 @@ BBB5ABE2215E2217005B48B6 /* SSLClientCertificate.swift */, BBB5ABE3215E2217005B48B6 /* SSLSecurity.swift */, BBB5ABE4215E2217005B48B6 /* WebSocket.swift */, - BB8A648320E1123400527BA5 /* modulemap */, 5C1360001C473BEF00AA3A01 /* Starscream.h */, 6B3E79E919D48B7F006071F7 /* Supporting Files */, ); @@ -116,33 +107,6 @@ path = Tests; sourceTree = ""; }; - BB8A647D20E1102900527BA5 /* CommonCrypto */ = { - isa = PBXGroup; - children = ( - BB8A647E20E1105C00527BA5 /* NSString+SHA1.h */, - BB8A647F20E1105C00527BA5 /* NSString+SHA1.m */, - ); - path = CommonCrypto; - sourceTree = ""; - }; - BB8A648220E111F200527BA5 /* zlib */ = { - isa = PBXGroup; - children = ( - D85927D71ED76F25003460CB /* include.h */, - ); - path = zlib; - sourceTree = ""; - }; - BB8A648320E1123400527BA5 /* modulemap */ = { - isa = PBXGroup; - children = ( - BBC59F4D20D2D71500713D9C /* Starscream.modulemap */, - BB8A647D20E1102900527BA5 /* CommonCrypto */, - BB8A648220E111F200527BA5 /* zlib */, - ); - path = modulemap; - sourceTree = ""; - }; D88EAF801ED4DFD3004FE2C3 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -159,8 +123,6 @@ buildActionMask = 2147483647; files = ( 33CCF08C1F5DDC030099B092 /* Starscream.h in Headers */, - BB1018E821087F1900BA9E60 /* NSString+SHA1.h in Headers */, - 33CCF08D1F5DDC030099B092 /* include.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -265,7 +227,6 @@ BBB5ABEC215E221D005B48B6 /* WebSocket.swift in Sources */, BBB5ABE9215E221D005B48B6 /* Compression.swift in Sources */, 335FA1F91F5DF71D00F6D2EC /* CompressionTests.swift in Sources */, - BB93FF012146664D005BCEF7 /* NSString+SHA1.m in Sources */, 335FA1FA1F5DF71D00F6D2EC /* StarscreamTests.swift in Sources */, BBB5ABEA215E221D005B48B6 /* SSLClientCertificate.swift in Sources */, ); @@ -279,7 +240,6 @@ BBB5ABE8215E2217005B48B6 /* WebSocket.swift in Sources */, BBB5ABE7215E2217005B48B6 /* SSLSecurity.swift in Sources */, BBB5ABE6215E2217005B48B6 /* SSLClientCertificate.swift in Sources */, - BB93FF0021466450005BCEF7 /* NSString+SHA1.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -355,7 +315,6 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - MODULEMAP_FILE = $SRCROOT/Sources/modulemap/Starscream.modulemap; OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -389,7 +348,6 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - MODULEMAP_FILE = $SRCROOT/Sources/modulemap/Starscream.modulemap; OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; From e22724f5cf15564c3f9cac5bcbf024efa15a0371 Mon Sep 17 00:00:00 2001 From: Sergey Lem Date: Mon, 1 Oct 2018 11:52:33 +0100 Subject: [PATCH 3/4] Remove no longer needed dependencies from SPM config --- Package.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index d0d3198f..c36143a9 100644 --- a/Package.swift +++ b/Package.swift @@ -27,10 +27,7 @@ let package = Package( products: [ .library(name: "Starscream", targets: ["Starscream"]) ], - dependencies: [ - .package(url: "https://github.com/daltoniam/zlib-spm.git", from: "1.1.0"), - .package(url: "https://github.com/daltoniam/common-crypto-spm", from: "1.1.0") - ], + dependencies: [], targets: [ .target(name: "Starscream") ] From c6dfbf1ccb5d60df6f931c80710823657bdc49a0 Mon Sep 17 00:00:00 2001 From: Sergey Lem Date: Tue, 2 Oct 2018 11:26:31 +0100 Subject: [PATCH 4/4] Update podspec, return old code for sha1, update project settings --- Package.resolved | 25 ------------------------- Sources/Starscream/WebSocket.swift | 10 ++++------ Starscream.podspec | 4 +--- 3 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 3f19393e..00000000 --- a/Package.resolved +++ /dev/null @@ -1,25 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "SSCommonCrypto", - "repositoryURL": "https://github.com/daltoniam/common-crypto-spm", - "state": { - "branch": null, - "revision": "2eb3aff0fb57f92f5722fac5d6d20bf64669ca66", - "version": "1.1.0" - } - }, - { - "package": "SSCZLib", - "repositoryURL": "https://github.com/daltoniam/zlib-spm.git", - "state": { - "branch": null, - "revision": "83ac8d719a2f3aa775dbdf116a57f56fb2c49abb", - "version": "1.1.0" - } - } - ] - }, - "version": 1 -} diff --git a/Sources/Starscream/WebSocket.swift b/Sources/Starscream/WebSocket.swift index e3314ac1..a83ff2ec 100644 --- a/Sources/Starscream/WebSocket.swift +++ b/Sources/Starscream/WebSocket.swift @@ -1318,12 +1318,10 @@ open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelega private extension String { func sha1Base64() -> String { - guard let data = self.data(using: .utf8) else { return "" } - var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH)) - _ = data.withUnsafeBytes { (ptr: UnsafePointer) in - CC_SHA1(ptr, CC_LONG(data.count), &digest) - } - return digest.reduce("", { $0 + String(format: "%02x", $1) }) + let data = self.data(using: String.Encoding.utf8)! + var digest = [UInt8](repeating: 0, count:Int(CC_SHA1_DIGEST_LENGTH)) + data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) } + return Data(bytes: digest).base64EncodedString() } } diff --git a/Starscream.podspec b/Starscream.podspec index 76b5e3fb..7900437d 100644 --- a/Starscream.podspec +++ b/Starscream.podspec @@ -11,9 +11,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' - s.source_files = 'Sources/**/*.{h,m,swift}' - s.module_map = 'Sources/modulemap/Starscream.modulemap' - s.private_header_files = 'Sources/modulemap/**/*.h' + s.source_files = 'Sources/**/*.swift' s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.1' }