these开发第一个tweak问题总汇

由于最近在换工作,好久没空来学习了,今天大号环境,写一个helloworld 来测试一下,没想到问题还挺多的。
首先按照iOS应用逆向工程 中的helloworld 示例写好后,编译:
$ make package install

Making all for tweak iOSREGreetings…
==> Preprocessing Tweak.xm…
Tweak.xm:5: error: %orig does not make sense outside a function
make[3]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/Tweak.xm.51c367f0.o] Error 22
make[2]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/iOSREGreetings.dylib] Error 2
make[1]: *** [internal-library-all_] Error 2
make: *** [iOSREGreetings.all.tweak.variables] Error 2
uusafedeiMac:iosregreetings uusafe$ vim Tweak.xm

由于我使用vi编辑器的写的,所以,我就返回去仔细查看了Tweak.xm
$ vim Tweak.xm
(⊙o⊙)…
发现由于我的大意,忘了%hook SpringBoard
写好后,再编译
$ make package install

Making all for tweak iOSREGreetings…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
In file included from :363:
In file included from :5:
/opt/theos/Prefix.pch:6:10: fatal error: ‘_Prefix/NullabilityCompat.h’ file not found
#import <Prefix/NullabilityCompat.h>
^
1 error generated.
make[3]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/Tweak.xm.51c367f0.o] Error 1
make[2]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/iOSREGreetings.dylib] Error 2
make[1]: *** [internal-library-all
] Error 2
make: *** [iOSREGreetings.all.tweak.variables] Error 2

很明确,找不到NullabilityCompat.h
还好,有我们的Google 大神

将这个头文件的下载下来
将里面的文件copy到/opt/theos/include 中
$ sudo cp -R /Users/uusafe/Downloads/headers-master/* /opt/theos/include/
再编译,
$ make package install

Making all for tweak iOSREGreetings…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
Tweak.xm:5:92: error: expected ‘;’ after expression
_logos_orig$_ungrouped$SpringBoard$applicationDidFinishLaunching$(self, cmd, application) UIAl…
^
;
Tweak.xm:5:138: error: instance method ‘-initWithTitle:message:cancelButtonTitle:otherButtonTitles:’
not found (return type defaults to ‘id’) [-Werror,-Wobjc-method-access]
…initWithTitle:@“Come to http://bbs.iosre.com for more fun” message:nil cancelButtonTitle:@“OK” otherButtonTitles…
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAlertView.h:26:12: note:
receiver is instance of class declared here
@interface UIAlertView : UIView
^
2 errors generated.
make[3]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/Tweak.xm.51c367f0.o] Error 1
make[2]: *** [/Users/uusafe/iosre/iosregreetings/.theos/obj/debug/armv7/iOSREGreetings.dylib] Error 2
make[1]: *** [internal-library-all
] Error 2
make: *** [iOSREGreetings.all.tweak.variables] Error 2
(⊙o⊙)…还报错
方法写错了
$ vim Tweak.xm
$ make package install
Making all for tweak iOSREGreetings…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
==> Linking tweak iOSREGreetings (armv7)…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (arm64)…
==> Linking tweak iOSREGreetings (arm64)…
==> Merging tweak iOSREGreetings…
==> Signing iOSREGreetings…
Making stage for tweak iOSREGreetings…
dm.pl: building package com.iosre.iosregreetings:iphoneos-arm' in ./debs/com.iosre.iosregreetings_0.0.1-1+debug_iphoneos-arm.deb’
==> Installing…
The authenticity of host ‘192.168.213.12 (192.168.213.12)’ can’t be established.
RSA key fingerprint is SHA256:X3JixDm9duU05OtpeSNLqMDsrDYSSh7d0zM0gl28WB8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.213.12’ (RSA) to the list of known hosts.
root@192.168.213.12’s password:
Selecting previously deselected package com.iosre.iosregreetings.
(Reading database … 1582 files and directories currently installed.)
Unpacking com.iosre.iosregreetings (from /tmp/_theos_install.deb) …
Setting up com.iosre.iosregreetings (0.0.1-1+debug) …
install.exec “killall -9 SpringBoard”
root@192.168.213.12’s password:

终于成功了
总结:
细心!细心!细心!!!重要的事情说3遍

2 个赞

加油哈。换工作好啊。 :grinning:

those