Showing posts with label objective-c. Show all posts
Showing posts with label objective-c. Show all posts

Friday, September 6, 2019

The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C

After adding Core Data to our Objective-C project and adding an Entity, the build started failing with the error:

The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C

It turns out that the default Code Generation language of Core Data is swift, even if the entire project is written in Objective-C.

To resolve the error, click on the added Entity and look at File Inspector.  There is a Code Generation section which you'll need to switch to Objective-C.  Alternatively you can add the SWIFT_VERSION in your build settings, but I could not find that in our project. (https://stackoverflow.com/questions/52950514/value-for-swift-version-cannot-be-empty)

Solution found on stack overflow: https://stackoverflow.com/questions/47743271/the-swift-language-version-swift-version-build-setting-error-with-project-in

Saturday, May 17, 2014

Using an Object as a NSDictionary key triggers NSCopying warning

Getting the warning:  Sending 'SomeClass *__strong' to parameter of incompatible type 'id'

Usually the NSDictionary key is a string, but it can also be an object as long as it conforms to the NSCopying protocol.  The class just needs to be able to respond to the copy and copyWithZone methods so it's safe to cast it according to this SO answer:

http://stackoverflow.com/questions/12525324/unable-to-use-class-as-a-key-in-nsdictionary/12525479#12525479

Saturday, February 9, 2013

How to Deprecate a Method in Objective-C

To deprecate a method in objective C you can use __attribute__((deprecated)) like so:


- (id)initWithPermissions:(NSArray *)permissions __attribute__((deprecated));

source:
http://stackoverflow.com/questions/3908715/how-do-i-flag-a-method-as-deprecated-in-objective-c-2-0

keywords:
objc deprecate method