• 微信iOS消息拦截插件教程-第一个tweak编译过程


    -安装好theos框架之后,下面用一个简单的例子进行说明编译过程
    -新建一个代码目录

    -进入terminal,cd到刚才的目录中

    1、进入目录
    2、执行/opt/theos/bin/nic.pl
    3、选择模板11
    4、输入你的插件名字 wechat_hook
    5、输入你公司的名字 com.tencent.xin,名字随意
    6、输入作者的名字,author 随意
    7、输入你的插件需要Hook的目标App Bundle ID ,微信的是 com.tencent.xin
    8、输入安装时需要结束进程的App Bundle ID,这里直接Enter跳过
    执行完毕之后你将看到目录:

    -进入terminal,cd 到 wechat_hook中

    1、执行make指令之后你很可能看到错误
    '''
    Makefile:1: /makefiles/common.mk: No such file or directory
    Makefile:6: /tweak.mk: No such file or directory
    make: *** No rule to make target `/tweak.mk'. Stop.
    '''
    这个是因为路径不对,需要在终端中添加默认环境变量
    -解决编译错误,在终端中输入,export THEOS=/opt/theos
    -将Tweak.xm修改为下面的代码
    '''
    %hook ClassName

    // Hooking a class method

    • (id)sharedInstance {
      return %orig;
      }

    // Hooking an instance method with an argument.

    • (void)messageName:(int)argument {
      %log; // Write a message about this call, including its class, name and arguments, to the system log.

      %orig; // Call through to the original function with its original arguments.
      %orig(nil); // Call through to the original function with a custom argument.

      // If you use %orig(), you MUST supply all arguments (except for self and _cmd, the automatically generated ones.)
      }

    // Hooking an instance method with no arguments.

    • (id)noArguments {
      %log;
      id awesome = %orig;
      //[awesome doSomethingElse];
      [awesome performSelector:@selector(doSomethingElse)];

      return awesome;
      }

    // Always make sure you clean up after yourself; Not doing so could have grave consequences!
    %end
    '''
    -然后make

    如果看到下面的结果表明编译成功了


    如果你觉的有帮助,请赞赏一点点(1元,2元,5元),多了不要,买瓶水喝。

    代码地址:https://github.com/liqiushui/WeChatTweak

  • 相关阅读:
    怎样克服效率低
    开通博客
    一位父亲和一位母亲讲述孩子的成长故事--《粗养的智慧:李聃的普林斯顿之路》和《我的儿子马友友》阅读摘录
    读吴军博士新浪微博(2012.09-2014.12)信息整理
    读_浪潮之巅_新浪微博信息整理
    《现代软件工程-构建之法》读后感11-12章
    《现代软件工程-构建之法》读后感8-10章
    5.2 5.1的完善2.0
    四则运算程序的测试与封装
    《现代软件工程-构建之法》读后感6-7章
  • 原文地址:https://www.cnblogs.com/doudouyoutang/p/7146286.html
Copyright © 2020-2023  润新知