ShareKit 中SHK.m中的编译错…

来源:互联网 发布:批处理图片的软件 编辑:程序博客网 时间:2024/06/06 10:02

ShareKit

转自:http://blog.csdn.net/wave_1102/article/details/6081253
 
ShareKit has recently become one of my favorite iPhone open sourceprojects. Just add a few lines of code to your app and you caninstantly share text, URLs and other data via Email, Twitter,Facebook and a whole slew of other services.
I’ve found a couple of minor issues with the current release(version 0.2.1) of ShareKit, and I thought I’d share them to saveyou a couple of hours of debugging.
Error when building for device

This seems to be a known issue, that may depend on your Xcodeinstall.
If you get 12 compiler errors when building for a device, startingwith:
ShareKit/Core/SHK.m:35:28: error: objc/objc-class.h: No such fileor directory
Then the solution is to change this import statement inSHK.m:
#import <objc/objc-class.h>
to:
#import</usr/include/objc/objc-class.h>
or:
#import<objc/runtime.h>(这个是解决方案)
Hardcoding the path to something outside of Xcode or your projectdirectories seems like bad idea. So I went with the secondsolution.
Conflicting Localizable.strings

The ShareKit project contains its own Localizable.strings filesin the ShareKit / Localization directory. If your project is alsolocalized there will be a conflict over which Localizable.stringsfile will be used at runtime.
There are a couple of ways to resolve this conflict:
Remove the ShareKit files from your build target. This is thequickest solution, but you will lose the localizations provided inShareKit (currently only German).
Copy the contents of the Localizable.strings files from ShareKit toyour Localizable.strings files. And then remove the ShareKit filesfrom your build target. This works well when you have correspondinglocalizations.
Rename the ShareKit files to ShareKitLocalizable.strings and thenreplace the NSLocalizedString macros in the ShareKit code withNSLocalizedStringFromTable where you can specify theShareKitLocalizable.strings filename as the tableName.
 
From:  http://iphoneincubator.com/blog/open-source/sharekit

 

 

这个#import<objc/runtime.h> 主要是关于ObjC里面底层的用法,类似这些:

 

Method origMethod = class_getInstanceMethod(c, orig);
    MethodnewMethod = class_getInstanceMethod(c, newClassName);
   if(class_addMethod(c, orig, method_getImplementation(newMethod),method_getTypeEncoding(newMethod)))
       class_replaceMethod(c, newClassName,method_getImplementation(origMethod),method_getTypeEncoding(origMethod));
    else
       method_exchangeImplementations(origMethod, newMethod);

0 0
原创粉丝点击