SocketRocket icon indicating copy to clipboard operation
SocketRocket copied to clipboard

Carthage build broken

Open al-little opened this issue 6 years ago • 4 comments

Just upgraded to XCode 10.

Cartfile contents: github "facebook/SocketRocket" Running: "carthage update" produces the following errors.

/Users/alittle/Documents/Xcode/IntegrationTest/Carthage/Checkouts/SocketRocket/SocketRocket/SRWebSocket.m:509:5: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result] SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes); ^~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/alittle/Documents/Xcode/IntegrationTest/Carthage/Checkouts/SocketRocket/SocketRocket/SRWebSocket.m:629:13: error: enumeration values 'NSURLNetworkServiceTypeResponsiveData' and 'NSURLNetworkServiceTypeCallSignaling' not handled in switch [-Werror,-Wswitch] switch (requestNetworkServiceType) { ^ /Users/alittle/Documents/Xcode/IntegrationTest/Carthage/Checkouts/SocketRocket/SocketRocket/SRWebSocket.m:629:13: note: add missing switch cases switch (requestNetworkServiceType) { ^ /Users/alittle/Documents/Xcode/IntegrationTest/Carthage/Checkouts/SocketRocket/SocketRocket/SRWebSocket.m:1485:9: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]

    SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
    ^~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3 errors generated.

al-little avatar Sep 25 '18 08:09 al-little

@al-little Can you got any solution for Carthage build faild ?

screenshot 2018-10-18 at 10 03 44 pm

jabransiddiqui avatar Oct 19 '18 15:10 jabransiddiqui

Hi Jibran,

I didn’t get a solution, nobody replied. I used Apples build in classes instead.

Regards,

Al

On 19 Oct 2018, at 16:14, Jibran Ahmed SiddiQui [email protected] wrote:

@al-little https://github.com/al-little Can you got any solution for Carthage build faild ?

https://user-images.githubusercontent.com/23705554/47226951-26612780-d3db-11e8-8caa-3c06f0a70be3.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/SocketRocket/issues/595#issuecomment-431396555, or mute the thread https://github.com/notifications/unsubscribe-auth/ABb_9tMmxrO73UhY4fVDZHP_ZbUUI9gwks5umexBgaJpZM4W4Hhe.

al-little avatar Oct 19 '18 15:10 al-little

can you please guide me ?

jabransiddiqui avatar Oct 19 '18 17:10 jabransiddiqui

Hi there,

Since this still doesn't seem to have been fixed nearly four months after the issue has been raised and I had to get it going, I thought I'll contribute my workaround. But it is just that, a workaround and I am not sure if it may actually create problems in the long run. So use it with caution!

The reasoning behind my fixes is that these errors are actually warnings treated as errors. And of course, in an ideal world, the code should not even cause the compiler to emit warnings. But at the same time, the build for Cocoa Pods is likely just ignoring them as that would be broken otherwise as well. So I assume the code is basically doing the right thing and I just need to get the compiler to stop throwing the error. Still, instead of simply removing the compiler flags -Werror, -Wswitch and -Wunused-result, I decided to add those missed cases and at least print a warning to the console.

image

Similarly, I checked the return value of SecRandomCopyBytes and print an error message if it should return a value other than 0.

image

and

image

Here is the complete SRWebSocket.m file:

SRWebSocket.m.zip

I hope it helps. Of course, I still hope that one of the authors may find the time to check the code and fix it properly.

Best regards, Jochen

jehnes avatar Feb 11 '19 17:02 jehnes