首先-我知道私有框架/API不会吸引我进入AppStore,这仅用于私有用途/研究.
First - I know private frameworks/APIs won't get me to the AppStore, this is for private use/research only.
我无法使用 ChatKit.framework 编译我的项目.
I can't get my project to compile with ChatKit.framework.
基本上,我需要以某种方式初始化 CKDBMessage 对象并从中获取内容.
Basically I need to somehow init a CKDBMessage object and get stuff from it.
我尝试的 第一 方法是可以这样称呼的:
The first approach I tried is to be able to call this:
CKDBMessage* msg = [[CKDBMessage alloc] initWithRecordID:lastID]; NSLog(@"GOT SMS: %@", msg.text);我无法使用这些解决方案的任何组合进行编译:
I couldn't get it to compile with any combination of these solutions:
- 只需将 CKDBMessage.h 添加到我的项目中
- 添加 ChatKit.framework 的所有标头
- 还添加 ChatKit.framework 文件本身
- Simply add only CKDBMessage.h to my project
- Add all the headers of ChatKit.framework
- Add also ChatKit.framework file itself
我在 Headers 文件夹中有标头和框架文件,我尝试在递归/非递归上添加任何/所有这些构建设置:
I have the headers and the framework file in Headers folder and I tried adding any/all of these build settings, both on recursive/non-recursive:
- 框架搜索路径-> $(PROJECT_DIR)/Headers
- 标题搜索路径->
- $(SRCROOT)/Headers/ChatKit.framework/Headers
- $(SRCROOT)/Headers
- $(SRCROOT)/Headers
- $(SRCROOT)/Headers/ChatKit.framework/Headers
始终搜索用户路径"始终为是"
Always Search User Paths is always on YES
我尝试的 第二 事情是在运行时做的所有事情,这就是我拥有的:
The second thing I tried was to do everything at runtime, this is what I have:
Class CKDBMessage = NSClassFromString(@"CKDBMessage");// objc_getClass("CKDBMessage"); SEL sel = @selector(initWithRecordID:); NSMethodSignature *signature = [CKDBMessage methodSignatureForSelector:sel]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; invocation.selector = sel; [invocation setArgument:&lastID atIndex:2]; [invocation invoke]; NSObject * msgWeak = [CKDBMessage alloc]; [invocation getReturnValue:&msgWeak]; NSObject *msg = msgWeak; NSString *text = [msg performSelector:@selector(text)]; NSLog(@"text: %@", text);在这里,我在 invocationWithMethodSignature:处崩溃,因为NSClassFromString返回nil而不是类...
Here I crash at invocationWithMethodSignature: because NSClassFromString returns nil instead of the class...
对这两种方法有何想法?
Any ideas on any of the two approaches?
这是针对使用Xcode6的非越狱iOS8(.2)
This is for nonjailbroken, iOS8(.2), using Xcode6
推荐答案没有多少人看过这个,但是为了我们的Wiki社区,我设法通过添加 CKDBMessage.h 将文件添加到我的项目中(实际上我添加了 ChatKit 的所有标头,但我认为没有必要),而不是像这样用 dlopen 动态加载框架:/p>
Well not many people viewed this, but for the sake of our wiki community, I managed to solve this by adding the CKDBMessage.h file to my project (actually I added all the headers of ChatKit but I don't think it's necessary), than I loaded the framework dynamically with dlopen like so:
dlopen("/System/Library/PrivateFrameworks/ChatKit.framework/ChatKit", RTLD_LAZY)所以我的完整解决方案是:
So my full solution is:
dlopen("/System/Library/PrivateFrameworks/ChatKit.framework/ChatKit", RTLD_LAZY); Class CKDBMessageClass = NSClassFromString(@"CKDBMessage"); CKDBMessage *msg = [[CKDBMessageClass alloc] initWithRecordID:lastID]; NSString *text = msg.text; NSLog(@"text: %@", text);获取最后一条消息的ID涉及另一个框架: IMDPersistence :
Getting the ID of the last message involves another framework: IMDPersistence:
//SomeFile.h // ... //declare the function: static int (*IMDMessageRecordGetMessagesSequenceNumber)(); // SomeFile.m // ... //open IMDPersistence framework void *libHandleIMD = dlopen("/System/Library/PrivateFrameworks/IMDPersistence.framework/IMDPersistence", RTLD_LAZY); //make/get symbol from framework + name IMDMessageRecordGetMessagesSequenceNumber = (int (*)())dlsym(libHandleIMD, "IMDMessageRecordGetMessagesSequenceNumber"); // get id of last SMS from symbol int lastID = IMDMessageRecordGetMessagesSequenceNumber();现在您可以使用 lastID 来获取消息内容...
Now you can use lastID to get the message contents...
更多推荐
导入ChatKit(即私有框架)或以某种方式使用CKDBMessage
发布评论