水曜日, 2月 23, 2011

“Unknown class in Interface Builder file” error at runtime

“Unknown class in Interface Builder file” error at runtime

  1. Just call a method it inherits from NSObject, like +class.
  2. Set the -ObjC linker flag. In Xcode go to Project -> Edit Project Settings, find the "Other Linker Flags" entry and add the following (capitalization important) "-ObjC" without the quotes.
    Related linker option:
    -all_load: This one seems a bit overkill, as all of my unused classes will be kept in the final binary, potentially bloating it.
    -ObjC : This seems to be a compiler flag, and overrides the file extension rules.
    -lobjc : Need this special case of the -l option in order to link an Objective-C or Objective-C++ program.
  3. Fixed this by copying the text from my class.h and .m, deleting those class files from the project, and creating new class.h and .m files with the same name using "Add File".Then paste the code back into the new files, and everything work great.

0 件のコメント: