7

I get warning when I run my app in iOS7 "'isa' is deprecated", I don't have any idea how to fix this warning message. Please any one help on this.

array->isa      = _JKArrayClass;
jingtao
  • 513
  • 2
  • 7
Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45
  • 1
    I'd recommend getting rid of JSONKit from your project. It's, for one, not compatible with 64-bit architecture, because of the language hacks used. – macbirdie Jun 06 '14 at 15:36

2 Answers2

17

Include <objc/runtime.h>.

Replace everything like array->isa = _JKArrayClass; with object_setClass(array, _JKArrayClass)

And everything like class = array.isa with class = object_getClass(array)

Sviatoslav Yakymiv
  • 7,887
  • 2
  • 23
  • 43
  • And, also, please share your fork on GitHub? – Ali Nov 14 '13 at 20:49
  • I had this error twice, in one build. your fix works for one of them, but the other appears to be in a library, I can't edit or save that. How would I fix that one please ? not sure where the lib came from. – CthulhuJon Mar 05 '15 at 22:29
15

I figured I would share my solution for you Cocoapods users out there. (Please let me know in the comments if you have found a better solution)

I am using Cocoapods and for this reason I do not want to modify the source code of the libraries I am pulling in. The problem is caused by Cocoapods setting the "Direct usage of 'isa'" value to "Yes (treat as error)", thus causing all automated builds to fail.

I have fixed the problem by adding this to my Podfile:

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CLANG_WARN_DIRECT_OBJC_ISA_USAGE'] = 'YES'
        end
    end
end

This way the direct usage of 'isa' will show up as warning but will not cause automated builds to fail.

But in arm64 iOS Device build(with Xcode 5.1.0) strangely CLANG_WARN_DIRECT_OBJC_ISA_USAGE = 'YES' option will not properly applied(treat as error). If you need to build, including arm64 just CLANG_WARN_DIRECT_OBJC_ISA_USAGE = 'NO' option can be used.

Dongjin Suh
  • 448
  • 4
  • 12
bsarrazin
  • 3,990
  • 2
  • 18
  • 31
  • 1
    thanks, this works. tested in xcode Version 5.0.2 (5A3005) and mavericks 19.9.1 – keithics Jan 17 '14 at 07:21
  • Unfortunately, my pod update fails applying this patch. There is no detail about the error: `LoadError - no such file to load...` I'm working with Xcode 5.1 and i0S 7.1. Do you have any idea about this ? Thanks – Lisarien Mar 24 '14 at 16:18
  • That error doesn't tell me much. If I remember correctly, the error was caused by JSONKit. If this error is caused by a pod, then this fix (I haven't tested it) should work. Otherwise, you should be able to fix it in your code. Have you been able to fix it? – bsarrazin Apr 03 '14 at 19:59