博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ShareKit 中SHK.m中的编译错…
阅读量:4071 次
发布时间:2019-05-25

本文共 2348 字,大约阅读时间需要 7 分钟。

ShareKit

转自:

 
ShareKit has recently become one of my favorite iPhone open source projects. Just add a few lines of code to your app and you can instantly 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 save you a couple of hours of debugging.
Error when building for device

This seems to be a known issue, that may depend on your Xcode install.

If you get 12 compiler errors when building for a device, starting with:
ShareKit/Core/SHK.m:35:28: error: objc/objc-class.h: No such file or directory
Then the solution is to change this import statement in SHK.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 project directories seems like bad idea. So I went with the second solution.
Conflicting Localizable.strings

The ShareKit project contains its own Localizable.strings files in the ShareKit / Localization directory. If your project is also localized there will be a conflict over which Localizable.strings file 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 the quickest solution, but you will lose the localizations provided in ShareKit (currently only German).
Copy the contents of the Localizable.strings files from ShareKit to your Localizable.strings files. And then remove the ShareKit files from your build target. This works well when you have corresponding localizations.
Rename the ShareKit files to ShareKitLocalizable.strings and then replace the NSLocalizedString macros in the ShareKit code with NSLocalizedStringFromTable where you can specify the ShareKitLocalizable.strings filename as the tableName.
 
From: 

 

 

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

 

Method origMethod = class_getInstanceMethod(c, orig);

    Method newMethod = 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);

转载地址:http://xneji.baihongyu.com/

你可能感兴趣的文章
大数据学习:Spark SQL入门简介
查看>>
大数据学习:Spark RDD操作入门
查看>>
大数据框架:Spark 生态实时流计算
查看>>
大数据入门:Hive和Hbase区别对比
查看>>
大数据入门:ZooKeeper工作原理
查看>>
大数据入门:Zookeeper结构体系
查看>>
大数据入门:Spark RDD基础概念
查看>>
大数据入门:SparkCore开发调优原则
查看>>
大数据入门:Java和Scala编程对比
查看>>
大数据入门:Scala函数式编程
查看>>
【数据结构周周练】002顺序表与链表
查看>>
C++报错:C4700:使用了非初始化的局部变量
查看>>
【数据结构周周练】003顺序栈与链栈
查看>>
C++类、结构体、函数、变量等命名规则详解
查看>>
C++ goto语句详解
查看>>
【数据结构周周练】008 二叉树的链式创建及测试
查看>>
《软件体系结构》 第九章 软件体系结构评估
查看>>
《软件体系结构》 第十章 软件产品线体系结构
查看>>
《软件过程管理》 第六章 软件过程的项目管理
查看>>
《软件过程管理》 第九章 软件过程的评估和改进
查看>>