Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto synthesis error in AFURLRequestSerialization with Xcode 6

How do I fix the warning "auto property synthesis will not synthesize because it is readwrite but it will be synthesized readonly via another property" for the properties streamStatus and streamError that I'm getting with the latest AFNetworking on the Xcode 6 beta?

https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLRequestSerialization.m#L733

Here's the relavent line in AFURLRequestSerialization.m line 733 and 734:

@interface AFMultipartBodyStream () <NSCopying>
@property (readwrite, nonatomic, assign) NSStreamStatus streamStatus;
@property (readwrite, nonatomic, strong) NSError *streamError;
like image 875
MonkeyBonkey Avatar asked Jun 06 '14 13:06

MonkeyBonkey


2 Answers

It seems like the version of clang that ships with xcode 6 beta doesn't authorize to rewrite properties in an extension that is not a direct extension of the original class holding those properties.

removing:

@property (readwrite, nonatomic, assign) NSStreamStatus streamStatus;
@property (readwrite, nonatomic, strong) NSError *streamError;

and replacing it with :

@interface NSStream ()
@property (readwrite) NSStreamStatus streamStatus;
@property (readwrite, copy) NSError *streamError;
@end

solves the issue.

I've opened a pull request in the AFNetworking repo to solve this.

Hope this helps.

like image 172
apouche Avatar answered Oct 21 '22 13:10

apouche


I JUST set up my Xcode 6 to work with developing iOS 7 apps, and it fixed an autosynthesis issue I was having with AFNetworking. I changed my build tools to 5.1 and moved the 7.1 SDK into the Developer/SDKs dir in Xcode 6. The issue (obviously) is that I need to change the build tools when working on iOS 8 explicitly, but it's much better than switching back and forth between 5 and 6.

Changing Build Tools

  1. Open Xcode Preferences (cmd+,)
  2. Navigate to the 'Locations' tab
  3. Change 'Command Line Tools' from Xcode 6.0 to Xcode 5.1.1

Getting iOS 7 SDK

  1. Open Terminal
  2. Run cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk /Applications/Xcode6-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk

  3. Restart Xcode

You should now be able to set iOS 7.1 as your base SDK

This should solve your issue in the short term until all of these libraries are updated for iOS 8.0 and the new build tools.

like image 28
HighFlyingFantasy Avatar answered Oct 21 '22 13:10

HighFlyingFantasy