Эх сурвалжийг харах

Merge pull request #453 from facebook/nlutsenko.cleanup

Update configurations and unbreak compilation of a sample app.
Nikita Lutsenko 9 жил өмнө
parent
commit
cccbf71a7b

+ 19 - 0
Configurations/TestChat-iOS.xcconfig

@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2016-present, Facebook, Inc.
+// All rights reserved.
+//
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+//
+
+#include "Shared/Platform/iOS.xcconfig"
+#include "Shared/Product/Application.xcconfig"
+
+PRODUCT_NAME = TestChat
+PRODUCT_MODULE_NAME = TestChat
+PRODUCT_BUNDLE_IDENTIFIER = com.facebook.socketrocket.testchat
+
+IPHONEOS_DEPLOYMENT_TARGET = 8.0
+
+INFOPLIST_FILE = $(SRCROOT)/TestChat/TestChat-Info.plist

+ 53 - 26
SocketRocket.xcodeproj/project.pbxproj

@@ -75,6 +75,7 @@
 		81900A511D18C9CC0015A290 /* SRLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 81900A4B1D18C9CC0015A290 /* SRLog.m */; };
 		81900A521D18C9CC0015A290 /* SRLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 81900A4B1D18C9CC0015A290 /* SRLog.m */; };
 		81900A531D18C9CC0015A290 /* SRLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 81900A4B1D18C9CC0015A290 /* SRLog.m */; };
+		81AFCD661D4C431C00B3AFC9 /* libicucore.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 81AFCD651D4C431C00B3AFC9 /* libicucore.tbd */; };
 		81B22EC61CE42D7E0073C636 /* SRError.h in Headers */ = {isa = PBXBuildFile; fileRef = 81B22EC31CE42D7E0073C636 /* SRError.h */; };
 		81B22EC71CE42D7E0073C636 /* SRError.h in Headers */ = {isa = PBXBuildFile; fileRef = 81B22EC31CE42D7E0073C636 /* SRError.h */; };
 		81B22EC81CE42D7E0073C636 /* SRError.h in Headers */ = {isa = PBXBuildFile; fileRef = 81B22EC31CE42D7E0073C636 /* SRError.h */; };
@@ -181,6 +182,8 @@
 		81D647881D2CA78800690609 /* SRRunLoopThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 81B31C5D1CDC444900D86D43 /* SRRunLoopThread.h */; };
 		81D647B51D2CA8E200690609 /* SocketRocket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81D6478D1D2CA78800690609 /* SocketRocket.framework */; };
 		81DCD1241D2D9235002501A2 /* libicucore.A.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C68D0D1D2CBFA800A1D005 /* libicucore.A.tbd */; };
+		81E8A6A21D4C41E000916C7E /* SocketRocket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81D6478D1D2CA78800690609 /* SocketRocket.framework */; };
+		81E8A6A31D4C41E000916C7E /* SocketRocket.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 81D6478D1D2CA78800690609 /* SocketRocket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		F5391CBE1D2F4B4700606A81 /* SRSIMDHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = F5391CBC1D2F4B4700606A81 /* SRSIMDHelpers.h */; };
 		F5391CBF1D2F4B4700606A81 /* SRSIMDHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = F5391CBC1D2F4B4700606A81 /* SRSIMDHelpers.h */; };
 		F5391CC01D2F4B4700606A81 /* SRSIMDHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = F5391CBC1D2F4B4700606A81 /* SRSIMDHelpers.h */; };
@@ -215,8 +218,36 @@
 			remoteGlobalIDString = 81D6475F1D2CA78800690609;
 			remoteInfo = "SocketRocket-iOS";
 		};
+		81E8A6A01D4C41DA00916C7E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = F6B208241450F597009315AF /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 2D4227611BB4358C000C1A6C;
+			remoteInfo = "SocketRocket-iOS-Dynamic";
+		};
+		81E8A6A41D4C41E000916C7E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = F6B208241450F597009315AF /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 81D6475F1D2CA78800690609;
+			remoteInfo = "SocketRocket-iOS";
+		};
 /* End PBXContainerItemProxy section */
 
+/* Begin PBXCopyFilesBuildPhase section */
+		81E8A6A61D4C41E000916C7E /* Embed Frameworks */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "";
+			dstSubfolderSpec = 10;
+			files = (
+				81E8A6A31D4C41E000916C7E /* SocketRocket.framework in Embed Frameworks */,
+			);
+			name = "Embed Frameworks";
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
 		2D4227621BB4358C000C1A6C /* SocketRocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketRocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		3345DC901C52ACD70083CCB8 /* SocketRocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketRocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -247,6 +278,7 @@
 		8179967F1CE184F40084DA37 /* SRAutobahnUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRAutobahnUtilities.m; sourceTree = "<group>"; };
 		81900A4A1D18C9CC0015A290 /* SRLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRLog.h; sourceTree = "<group>"; };
 		81900A4B1D18C9CC0015A290 /* SRLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRLog.m; sourceTree = "<group>"; };
+		81AFCD651D4C431C00B3AFC9 /* libicucore.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/usr/lib/libicucore.tbd; sourceTree = DEVELOPER_DIR; };
 		81B22EC31CE42D7E0073C636 /* SRError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRError.h; sourceTree = "<group>"; };
 		81B22EC41CE42D7E0073C636 /* SRError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRError.m; sourceTree = "<group>"; };
 		81B22EE21CE43ECC0073C636 /* SRURLUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRURLUtilities.h; sourceTree = "<group>"; };
@@ -290,6 +322,7 @@
 		81D6475C1D2CA6A100690609 /* SocketRocket-tvOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "SocketRocket-tvOS.xcconfig"; sourceTree = "<group>"; };
 		81D6475D1D2CA6A100690609 /* SocketRocketTests-iOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "SocketRocketTests-iOS.xcconfig"; sourceTree = "<group>"; };
 		81D6478D1D2CA78800690609 /* SocketRocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketRocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		81E8A69A1D4C417A00916C7E /* TestChat-iOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "TestChat-iOS.xcconfig"; sourceTree = "<group>"; };
 		F5391CBC1D2F4B4700606A81 /* SRSIMDHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRSIMDHelpers.h; sourceTree = "<group>"; };
 		F5391CBD1D2F4B4700606A81 /* SRSIMDHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRSIMDHelpers.m; sourceTree = "<group>"; };
 		F61A0DC71625F44D00365EBD /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "en.lproj/Default-568h@2x.png"; sourceTree = "<group>"; };
@@ -350,10 +383,12 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				81AFCD661D4C431C00B3AFC9 /* libicucore.tbd in Frameworks */,
 				F62417E614D52F3C003CE997 /* UIKit.framework in Frameworks */,
 				F62417E714D52F3C003CE997 /* Foundation.framework in Frameworks */,
 				F624180314D53449003CE997 /* CFNetwork.framework in Frameworks */,
 				F624180414D53449003CE997 /* Security.framework in Frameworks */,
+				81E8A6A21D4C41E000916C7E /* SocketRocket.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -496,9 +531,9 @@
 				817491A71D1C8C33006E09DF /* SRMutex.m */,
 				81C22BF61D1256E1007BFDDF /* SRRandom.h */,
 				81C22BF71D1256E1007BFDDF /* SRRandom.m */,
-				81B22EE21CE43ECC0073C636 /* SRURLUtilities.h */,
 				815FE7241D497D720085FDA5 /* SRConstants.h */,
 				815FE7251D497D720085FDA5 /* SRConstants.m */,
+				81B22EE21CE43ECC0073C636 /* SRURLUtilities.h */,
 				81B22EE31CE43ECC0073C636 /* SRURLUtilities.m */,
 				F5391CBC1D2F4B4700606A81 /* SRSIMDHelpers.h */,
 				F5391CBD1D2F4B4700606A81 /* SRSIMDHelpers.m */,
@@ -554,6 +589,7 @@
 				81D6475B1D2CA6A100690609 /* SocketRocket-macOS.xcconfig */,
 				81D6475C1D2CA6A100690609 /* SocketRocket-tvOS.xcconfig */,
 				81D6475D1D2CA6A100690609 /* SocketRocketTests-iOS.xcconfig */,
+				81E8A69A1D4C417A00916C7E /* TestChat-iOS.xcconfig */,
 				81D647491D2CA6A100690609 /* Shared */,
 			);
 			path = Configurations;
@@ -658,6 +694,7 @@
 		F6B2082F1450F597009315AF /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				81AFCD651D4C431C00B3AFC9 /* libicucore.tbd */,
 				81C68CF41D2CBEBD00A1D005 /* macOS */,
 				81C68CFD1D2CBF1800A1D005 /* tvOS */,
 				81C68CFE1D2CBF2100A1D005 /* iOS */,
@@ -868,10 +905,13 @@
 				F62417DF14D52F3C003CE997 /* Sources */,
 				F62417E014D52F3C003CE997 /* Frameworks */,
 				F62417E114D52F3C003CE997 /* Resources */,
+				81E8A6A61D4C41E000916C7E /* Embed Frameworks */,
 			);
 			buildRules = (
 			);
 			dependencies = (
+				81E8A6A11D4C41DA00916C7E /* PBXTargetDependency */,
+				81E8A6A51D4C41E000916C7E /* PBXTargetDependency */,
 			);
 			name = TestChat;
 			productName = TestChat;
@@ -1129,6 +1169,16 @@
 			target = 81D6475F1D2CA78800690609 /* SocketRocket-iOS */;
 			targetProxy = 81D647B31D2CA8DD00690609 /* PBXContainerItemProxy */;
 		};
+		81E8A6A11D4C41DA00916C7E /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 2D4227611BB4358C000C1A6C /* SocketRocket-iOS-Dynamic */;
+			targetProxy = 81E8A6A01D4C41DA00916C7E /* PBXContainerItemProxy */;
+		};
+		81E8A6A51D4C41E000916C7E /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 81D6475F1D2CA78800690609 /* SocketRocket-iOS */;
+			targetProxy = 81E8A6A41D4C41E000916C7E /* PBXContainerItemProxy */;
+		};
 /* End PBXTargetDependency section */
 
 /* Begin PBXVariantGroup section */
@@ -1201,38 +1251,15 @@
 		};
 		F62417FD14D52F3C003CE997 /* Debug */ = {
 			isa = XCBuildConfiguration;
+			baseConfigurationReference = 81E8A69A1D4C417A00916C7E /* TestChat-iOS.xcconfig */;
 			buildSettings = {
-				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				FRAMEWORK_SEARCH_PATHS = (
-					"$(inherited)",
-					"\"$(DEVELOPER_FRAMEWORKS_DIR)\"",
-				);
-				INFOPLIST_FILE = "TestChat/TestChat-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
-				OTHER_LDFLAGS = "-ObjC";
-				PRODUCT_BUNDLE_IDENTIFIER = com.facebook.socketrocket.testchat;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				TARGETED_DEVICE_FAMILY = "1,2";
-				WRAPPER_EXTENSION = app;
 			};
 			name = Debug;
 		};
 		F62417FE14D52F3C003CE997 /* Release */ = {
 			isa = XCBuildConfiguration;
+			baseConfigurationReference = 81E8A69A1D4C417A00916C7E /* TestChat-iOS.xcconfig */;
 			buildSettings = {
-				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				FRAMEWORK_SEARCH_PATHS = (
-					"$(inherited)",
-					"\"$(DEVELOPER_FRAMEWORKS_DIR)\"",
-				);
-				INFOPLIST_FILE = "TestChat/TestChat-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
-				OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
-				OTHER_LDFLAGS = "-ObjC";
-				PRODUCT_BUNDLE_IDENTIFIER = com.facebook.socketrocket.testchat;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				TARGETED_DEVICE_FAMILY = "1,2";
-				WRAPPER_EXTENSION = app;
 			};
 			name = Release;
 		};

+ 3 - 1
SocketRocket/Internal/Proxy/SRProxyConnect.m

@@ -187,8 +187,9 @@
         [proxyType isEqualToString:(NSString *)kCFProxyTypeHTTPS]) {
         _httpProxyHost = settings[(NSString *)kCFProxyHostNameKey];
         NSNumber *portValue = settings[(NSString *)kCFProxyPortNumberKey];
-        if (portValue)
+        if (portValue) {
             _httpProxyPort = [portValue intValue];
+        }
     }
     if ([proxyType isEqualToString:(NSString *)kCFProxyTypeSOCKS]) {
         _socksProxyHost = settings[(NSString *)kCFProxyHostNameKey];
@@ -470,4 +471,5 @@ static NSTimeInterval const SRProxyConnectWriteTimeout = 5.0;
         [outStream write:bytes maxLength:data.length];
     });
 }
+
 @end

+ 3 - 0
SocketRocket/Internal/Utilities/SRURLUtilities.h

@@ -20,4 +20,7 @@ extern BOOL SRURLRequiresSSL(NSURL *url);
 // Extracts `user` and `password` from url (if available) into `Basic base64(user:password)`.
 extern NSString *_Nullable SRBasicAuthorizationHeaderFromURL(NSURL *url);
 
+// Returns a valid value for `NSStreamNetworkServiceType` or `nil`.
+extern NSString *_Nullable SRStreamNetworkServiceTypeFromURLRequest(NSURLRequest *request);
+
 NS_ASSUME_NONNULL_END

+ 29 - 9
SocketRocket/Internal/Utilities/SRURLUtilities.m

@@ -9,6 +9,8 @@
 
 #import "SRURLUtilities.h"
 
+#import "SRHash.h"
+
 NS_ASSUME_NONNULL_BEGIN
 
 NSString *SRURLOrigin(NSURL *url)
@@ -42,16 +44,34 @@ extern BOOL SRURLRequiresSSL(NSURL *url)
 extern NSString *_Nullable SRBasicAuthorizationHeaderFromURL(NSURL *url)
 {
     NSData *data = [[NSString stringWithFormat:@"%@:%@", url.user, url.password] dataUsingEncoding:NSUTF8StringEncoding];
-    NSString *userAndPasswordBase64Encoded;
-    if ([data respondsToSelector:@selector(base64EncodedStringWithOptions:)]) {
-        userAndPasswordBase64Encoded = [data base64EncodedStringWithOptions:0];
-    } else {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-        userAndPasswordBase64Encoded = [data base64Encoding];
-#pragma clang diagnostic pop
+    return [NSString stringWithFormat:@"Basic %@", SRBase64EncodedStringFromData(data)];
+}
+
+extern NSString *_Nullable SRStreamNetworkServiceTypeFromURLRequest(NSURLRequest *request)
+{
+    NSString *networkServiceType = nil;
+    switch (request.networkServiceType) {
+        case NSURLNetworkServiceTypeDefault:
+            break;
+        case NSURLNetworkServiceTypeVoIP:
+            networkServiceType = NSStreamNetworkServiceTypeVoIP;
+            break;
+        case NSURLNetworkServiceTypeVideo:
+            networkServiceType = NSStreamNetworkServiceTypeVideo;
+            break;
+        case NSURLNetworkServiceTypeBackground:
+            networkServiceType = NSStreamNetworkServiceTypeBackground;
+            break;
+        case NSURLNetworkServiceTypeVoice:
+            networkServiceType = NSStreamNetworkServiceTypeVoice;
+            break;
+#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 || __TV_OS_VERSION_MAX_ALLOWED >= 100000 || __WATCH_OS_VERSION_MAX_ALLOWED >= 30000)
+        case NSURLNetworkServiceTypeCallSignaling:
+            networkServiceType = NSStreamNetworkServiceTypeCallSignaling;
+            break;
+#endif
     }
-    return [NSString stringWithFormat:@"Basic %@", userAndPasswordBase64Encoded];
+    return networkServiceType;
 }
 
 NS_ASSUME_NONNULL_END

+ 1 - 40
SocketRocket/SRWebSocket.m

@@ -457,46 +457,7 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
         [_securityPolicy updateSecurityOptionsInStream:_outputStream];
     }
 
-    _inputStream.delegate = self;
-    _outputStream.delegate = self;
-
-    [self setupNetworkServiceType:_urlRequest.networkServiceType];
-}
-
-- (void)setupNetworkServiceType:(NSURLRequestNetworkServiceType)requestNetworkServiceType
-{
-    NSString *networkServiceType;
-    switch (requestNetworkServiceType) {
-        case NSURLNetworkServiceTypeDefault:
-            break;
-        case NSURLNetworkServiceTypeVoIP: {
-            networkServiceType = NSStreamNetworkServiceTypeVoIP;
-#if TARGET_OS_IPHONE && __IPHONE_9_0
-            if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_8_3) {
-                static dispatch_once_t predicate;
-                dispatch_once(&predicate, ^{
-                    NSLog(@"SocketRocket: %@ - this service type is deprecated in favor of using PushKit for VoIP control", networkServiceType);
-                });
-            }
-#endif
-            break;
-        }
-        case NSURLNetworkServiceTypeVideo:
-            networkServiceType = NSStreamNetworkServiceTypeVideo;
-            break;
-        case NSURLNetworkServiceTypeBackground:
-            networkServiceType = NSStreamNetworkServiceTypeBackground;
-            break;
-        case NSURLNetworkServiceTypeVoice:
-            networkServiceType = NSStreamNetworkServiceTypeVoice;
-            break;
-#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 || __TV_OS_VERSION_MAX_ALLOWED >= 100000 || __WATCH_OS_VERSION_MAX_ALLOWED >= 30000)
-        case NSURLNetworkServiceTypeCallSignaling:
-            networkServiceType = NSStreamNetworkServiceTypeCallSignaling;
-            break;
-#endif
-    }
-
+    NSString *networkServiceType = SRStreamNetworkServiceTypeFromURLRequest(_urlRequest);
     if (networkServiceType != nil) {
         [_inputStream setProperty:networkServiceType forKey:NSStreamNetworkServiceType];
         [_outputStream setProperty:networkServiceType forKey:NSStreamNetworkServiceType];

+ 1 - 1
Vendor/xctoolchain

@@ -1 +1 @@
-Subproject commit 7d6009a8e17d12803a5ff6bdc75a9f0ac67cd7f6
+Subproject commit af8d7f69bf7a5b8e8edd94a139f83fc465b7b64a