0

I've just begun using CocoaPods today... First up I added AFNetworking, which worked fine... Then I needed SocketRocket...

However, SRWebSocket.m throws 9 warnings and 6 errors after being added with CocoaPods... The errors are in regards to retain/release not being available and ARC restrictions... The warnings are all:

'dispatch_get_current_queue' is deprecated: first deprecated in iOS 6.0

So I'm guessing I might be missing a step in setting this up somehow?

Any help would be appreciated...

user969043
  • 756
  • 2
  • 13
  • 34

1 Answers1

2

So a couple things

  1. You should likely submit a pull request to SocketRocket to remove the usage of dispatch_get_current_queue and change it to whatever it was replaced with, but it is a warning so it's not a huge concern for now.

  2. Since the SocketRocket project does not support/utilize ARC (presumably since it is has retain/release calls in it) you will need to go into Build Phases > Compile Sources and locate all SocketRocket classes and add the -fno-objc-arc compiler flag. This will let you compile, ideally though the SkyRocket Podspec should be updated to specify that ARC should be turned off. The compiler_flags property in the Podspec should include -fno-objc-arc, you should submit a pull request to have that updated.

EDIT

Interestingly SocketRocket touts that it uses ARC and I do not see any calls to retain/release (outside of CFRetain/CFRelease, which is fine/necessary in ARC).

I took a peak at the source code for SRWebSocket.m for both versions that are listed in the podspec repo (0.1.0 and 0.2.0) neither have retain/release calls.

0.2.0: https://github.com/square/SocketRocket/blob/v0.2.0/SocketRocket/SRWebSocket.m

0.1.0: https://github.com/square/SocketRocket/blob/82c9f8938f8b9b7aa578866cb7ce56bc11e52ced/SocketRocket/SRWebSocket.m

Strange?? Are you sure you are getting errors about SRWebSocket.m?

EDIT 2

After further digging and as mentioned in the comments. dispatch_release and dispatch_retain are not allowed when targeting iOS 6.0+ or OS X 10.8+ so you will need to remove those calls or do something that was suggested in pull request 55 for the project

Chris Wagner
  • 20,773
  • 8
  • 74
  • 95
  • Hi, Chris, thanks for your thourough response.... Yes, I get 6 errors from SRWebSocket.m - they all seem to appear on dispatch_retain or dispatch_release (I specified SocketRocket 0.2.0 in my podfile) - e.g. look at line 332 and 333 from the 0.2.0 SRWebSocket.m from GitHub – user969043 Jan 08 '13 at 00:37
  • Ok, here is your answer. http://stackoverflow.com/questions/8618632/does-arc-support-dispatch-queues I was not aware you could no longer use dispatch_retain/release in iOS 6 or OSX 10.8. So you will need to remove those, they are not necessary anymore. This kind of sucks as you don't really want to modify your dependency code like this. Check out this pull request that is open on the project https://github.com/square/SocketRocket/pull/55 – Chris Wagner Jan 08 '13 at 00:39
  • Ah, great... I'm quite new with using GitHub, so I just took that code and replaced it with the code I had, which resolved the errors, great! Not sure if there was a better way to replace the code than just C&P'ing it over? – user969043 Jan 08 '13 at 00:46
  • Ideally the author would accept the pull request (they may have reason not to though), include it in a new version, then create a new Podspec for said version. Then you could grab that version. This way you wouldn't be modifying this dependency that you don't intend to maintain, it's always nicer to not have your own mods but sometimes it is impossible not to. I think this is a valid case to do what you did. I'd just keep an eye on the project and see if they end up fixing this issue and potentially others, and then update. – Chris Wagner Jan 08 '13 at 00:49
  • Brilliant answers... So I've managed to resolve errors and I've replaced the deprecated functions that gave warnings... thanks! – user969043 Jan 08 '13 at 01:04