如何在Cydia Tweak中正确使用SharedInstance?

时间:2016-08-27 22:28:19

标签: ios objective-c cydia-substrate

我正在开发一个调整,我想在聊天功能中添加一些,例如将打开一个用户配置文件/使用命令踢一个用户/等(类似于Skype)我找到了在其中发送消息的方法聊天,但我似乎无法弄清楚如何让它触发任何东西。

这是我到目前为止所写的内容。

#import <kik/Pod/Classes/KikClient.h>

%hook CoreDataConversationManager

- (void)sendTextMessage:(id)arg1 withRenderInstructionSet:(id)arg2 toConversation:(id)arg3 isSuggestedResponse:(BOOL)arg4
{

    if ([[arg1 lowercaseString] hasPrefix:@"!u "] && [arg1 length]>3) {
        arg1 = [arg1 substringFromIndex:3];
          // Should open the users profile
        [[KikClient sharedInstance] openProfileForKikUsername:arg1];

        arg1 = @"";

    } else {
        %orig;
    }

}

%end

我在编译时遇到此错误。

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_KikClient", referenced from:
      objc-class-ref in Tweak.xm.0931a6c6.o
ld: symbol(s) not found for architecture armv7
clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation)

我在某处阅读/看到我可以使用[%c(Classname) method];从其他类调用方法 这就是我试过的事情

[[%c(KikClient) sharedInstance] openProfileForKikUsername:arg1];

这编译很好,但是当我发送诸如“!u niro”之类的消息时,没有任何反应,应该打开个人资料页面。

KikClient.h

另外,我应该注意到KikClient.h不是Kik中的现有类(通过ClassDump)

我还在转储的标题中搜索了“SharedInstance”并找到了这些。

C:\Users\niro\Desktop\ObjC\Headers\DDASLLogger.h:
   17  }
   18  
   19: + (id)sharedInstance;
   20  @property(readonly, nonatomic) NSString *loggerName;
   21  - (void)logMessage:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\DDLog.h:
   33  + (struct dispatch_queue_s *)loggingQueue;
   34  + (void)initialize;
   35: + (id)sharedInstance;
   36  @property(retain, nonatomic) NSMutableArray *_loggers; // @synthesize _loggers=__loggers;
   37  - (void).cxx_destruct;

C:\Users\niro\Desktop\ObjC\Headers\DDTTYLogger.h:
   27  }
   28  
   29: + (id)sharedInstance;
   30  + (unsigned long long)codeIndexForColor:(struct UIColor *)argSearching 2420 files for "sharedInstance"

C:\Users\niro\Desktop\ObjC\Headers\CameraHelper.h:
   23  }
   24  
   25: + (id)sharedInstance;
   26  @property _Bool testCompressOnSendPicture; // @synthesize testCompressOnSendPicture=_testCompressOnSendPicture;
   27  @property(retain, nonatomic) UIViewController<KikCameraHelperDelegate> *parentController; // @synthesize parentController=_controller;

C:\Users\niro\Desktop\ObjC\Headers\CLSAnalyticsViewControllerTrackingController.h:
   18  
   19  + (_Bool)replaceMethodImplementationForClass:(Class)arg1 selector:(SEL)arg2 withImplementation:(CDUnknownFunctionPointerType)arg3 storingOldImplementation:(CDUnknownFunctionPointerType *)arg4;
   20: + (id)sharedInstance;
   21  @property(nonatomic) __weak id <CLSAnalyticsViewControllerTrackingDelegate> delegate; // @synthesize delegate=_delegate;
   22  - (void)cleanUpUIViewControllerSwizzle;
   ..
   27  - (void)addBlackListViewControllerClass:(Class)arg1;
   28  - (void)startTracking;
   29: - (void)disposeSharedInstance;
   30  - (id)init;
   31  - (void)dealloc;

C:\Users\niro\Desktop\ObjC\Headers\Crashlytics.h:
   43  + (id)kitDisplayVersion;
   44  + (id)bundleIdentifier;
   45: + (id)sharedInstance;
   46  @property(readonly, nonatomic) CLSBe1;
   31  + (void)getRed:(double *)arg1 green:(double *)arg2 blue:(double *)arg3 fromColor:(struct UIColor *)arg4;

C:\Users\niro\Desktop\ObjC\Headers\FXBlurScheduler.h:
   18  }
   19  
   20: + (id)sharedInstance;
   21  @property(nonatomic) _Bool updating; // @synthesize updating=_updating;
   22  @property(nonatomic) _Bool blurEnabled; // @synthesize blurEnabled=_blurEnabled;

C:\Users\niro\Desktop\ObjC\Headers\KikSmiley.h:
   24  }
   25  
   26: + (id)sharedInstance;
   27  @property(retain, nonatomic) NSDictionary *defaultSmileyDictionary; // @synthesize defaultSmileyDictionary=_defaultSmileyDictionary;
   28  @property(nonatomic) _Bool ready; // @synthesize ready=_ready;

C:\Users\niro\Desktop\ObjC\Headers\KMDebugPerfManager.h:
   17  }
   18  
   19: + (id)sharedInstance;
   20  + (id)savePath;
   21  @property(retain, nonatomic) KMDebugPerfOverlayView *overlayView; // @synthesize overlayView=_overlayView;

C:\Users\niro\Desktop\ObjC\Headers\MessageListScreenController.h:
  101  }
  102  
  103: + (id)sharedInstance;
  104  + (void)setCore:(id)arg1;
  105  @property(readonly, nonatomic) Core *core; // @synthesize core=_core;

C:\Users\niro\Desktop\ObjC\Headers\Mixpanel.h:
   60  + (_Bool)inBackground;
   61  + (void)assertPropertyTypes:(id)arg1;
   62: + (id)sharedInstance;
   63: + (id)sharedInstanceWithToken:(id)arg1;
   64: + (id)sharedInstanceWithToken:(id)arg1 launchOptions:(id)arg2;
   65  @property(copy) NSString *switchboardURL; // @synthesize switchboardURL=_switchboardURL;
   66  @property(copy) NSString *decideURL; // @synthesize decideURL=_decideURL;

C:\Users\niro\Desktop\ObjC\Headers\MixpanelMetrics.h:
   27  
   28  + (id)botListForUsers:(id)arg1;
   29: + (id)sharedInstance;
   30  + (void)setCore:(id)arg1;
   31  @property(readonly, nonatomic) NSDictionary *superProperties; // @synthesize superProperties=_superProperties;

C:\Users\niro\Desktop\ObjC\Headers\MPTweakStore.h:
   15  }
   16  
   17: + (id)sharedInstance;
   18  - (void).cxx_destruct;
   19  - (void)reset;

C:\Users\niro\Desktop\ObjC\Headers\NBPhoneNumberUtil.h:
   24  }
   25  
   26: + (id)sharedInstance;
   27  @property(retain, nonatomic) NSRegularExpression *VALID_ALPHA_PHONE_PATTERN; // @synthesize VALID_ALPHA_PHONE_PATTERN=_VALID_ALPHA_PHONE_PATTERN;
   28  @property(retain, nonatomic) NSRegularExpression *CAPTURING_DIGIT_PATTERN; // @synthesize CAPTURING_DIGIT_PATTERN=_CAPTURING_DIGIT_PATTERN;

C:\Users\niro\Desktop\ObjC\Headers\OpenInChromeController.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (_Bool)openInChrome:(id)arg1 withCallbackURL:(id)arg2 createNewTab:(_Bool)arg3;
   15  - (_Bool)openInChrome:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\PBJVision.h:
   72  }
   73  
   74: + (id)sharedInstance;
   75  @property(nonatomic) _Bool audioEnabled; // @synthesize audioEnabled=_audioEnabled;
   76  @property(retain, nonatomic) NSString *captureSessionPreset; // @synthesize captureSessionPreset=_captureSessionPreset;

C:\Users\niro\Desktop\ObjC\Headers\Perf.h:
   19  }
   20  
   21: + (id)sharedInstance;
   22  @property(nonatomic) double currentTime; // @synthesize currentTime=_currentTime;
   23  @property(nonatomic) __weak id <PerfDelegate> delegate; // @synthesize delegate=_delegate;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserState.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (id)name;
   15  - (_Bool)needKey;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateArrayGotValue.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateArrayNeedValue.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateArrayStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateComplete.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (int)parserShouldReturn:(id)arg1;
   15  - (id)name;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateError.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (int)parserShouldReturn:(id)arg1;
   15  - (id)name;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateObjectGotKey.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateObjectGotValue.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateObjectNeedKey.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (_Bool)needKey;
   15  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateObjectSeparator.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;
   15  - (_Bool)parser:(id)arg1 shouldAcceptToken:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateObjectStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (_Bool)needKey;
   15  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamParserStateStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (id)name;
   15  - (void)parser:(id)arg1 shouldTransitionTo:(int)arg2;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterState.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)appendWhitespace:(id)arg1;
   15  - (void)transitionState:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateArrayStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)transitionState:(id)arg1;
   15  

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateArrayValue.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)appendSeparator:(id)arg1;
   15  

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateComplete.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (_Bool)isInvalidState:(id)arg1;
   15  

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateError.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  
   15  @end

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateObjectKey.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)appendSeparator:(id)arg1;
   15  

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateObjectStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (_Bool)expectingKey:(id)arg1;
   15  - (void)transitionState:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateObjectValue.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)appendWhitespace:(id)arg1;
   15  - (void)transitionState:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\SBJsonStreamWriterStateStart.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  - (void)appendSeparator:(id)arg1;
   15  - (void)transitionState:(id)arg1;

C:\Users\niro\Desktop\ObjC\Headers\ScreenshotMonitor.h:
   11  }
   12  
   13: + (id)sharedInstance;
   14  + (void)load;
   15  - (void)userDidTakeScreenshot:(id)arg1;

42 matches across 39 files

感谢您抽出宝贵时间阅读本文!如果有人可以帮我解决一些示例代码,或者甚至指出我需要阅读的内容,那就太棒了。

0 个答案:

没有答案