Theos for armv7 and arm64 - objective-c

I'm trying to get theos working on OSX Mavericks. I recently purchased an iPhone 5s and have since then jailbroken it. Now I am trying to get Theos working so I can start working on some tweaks again. I had it working on OSX Lion and for IOS 5 and 6. I have a very simple program which should display a UIAlert when an application launches. The problem is, when i run the make command in an attempt to compile my code i get this error:
Making all for tweak test...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak test...
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_UIAlertView", referenced from:
objc-class-ref in Tweak.xm.b0410391.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/test.dylib.1cc22e7c.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [test.all.tweak.variables] Error 2
Williams-MacBook-Pro-2:test williamfsmillie$
Here is my code for Tweak.xm:
%hook SBApplicationIcon
-(void)launch{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"TEST" message:#"message...." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
%orig;
}
%end
And my makefile:
export SDKVERSION=7.0
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm
ARCHS = armv7 arm64
test_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
Thanks!

It's an old question, but still I figured I should answer it for people who have the same question. You need to call objc_getClass for it to work, like this:
UIAlertView *alert = [[objc_getClass("UIAlertView") alloc] initWithTitle:#"TEST" message:#"message...." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
Note that this is not required on the left hand side of the assignment.

Edit your makefile and insert the following at the top:
export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:7.0:7.0
Also, link the Foundation framework with your tweak.

To fix the alert issue, you must include UIKit/UIKit.h (Sorry, I can't comment)

You need to include the UIKit framework in your Makefile by adding XXX_FRAMEWORKS = UIKit where XXX is your project name

If you're using iOS 7, you have to hook the correct method: try -(void)launchFromLocation:(int)location.
Because it uses a parameter, your code should look like this:
-(void)launchFromLocation:(int)location {
// your stuff
%orig(location);
}

I would say update your Headers.
Download new set from
rpetrich

Related

Why did the HelloWorld codes using cocoa's library fail to build?

The codes are like this:
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[])
{
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
}
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:#"Hi there."];
[alert runModal];
return 0;
}
What I want is: when called from command line, this program pops up an alert box, when I close the alertbox. The program exits.
But when building, it complains like this:
Ld /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug/KeyCatcher normal x86_64
cd /Users/hanfei/Desktop/KeyCatcher
setenv MACOSX_DEPLOYMENT_TARGET 10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug -F/Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug -filelist /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Intermediates/KeyCatcher.build/Debug/KeyCatcher.build/Objects-normal/x86_64/KeyCatcher.LinkFileList -mmacosx-version-min=10.9 -fobjc-arc -fobjc-link-runtime -framework Foundation -Xlinker -dependency_info -Xlinker /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Intermediates/KeyCatcher.build/Debug/KeyCatcher.build/Objects-normal/x86_64/KeyCatcher_dependency_info.dat -o /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug/KeyCatcher
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_NSAlert", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I choose the template for new project, I select command line tool instead of CoCoa Application as I just need CoCoa to display an alertbox. Does anyone have ideas about this..
That's because NSAlert is not #imported.
AppKit.h is not included by default when you create a command line tool , as you can see in the link, AppKit imports NSAlert.h.
EDIT:
First, to compile you need to add the Cocoa framework in your project.
Second, all the code should be enclosed in the #autoreleasepool section
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:#"Hi there."];
[alert runModal];
}
Your code will compile and run, but I think you'll have some other runtime errors.
I got the same error in C++ project that was using a NSAlert, this worked for me:
1) Adding
#include <Cocoa/Cocoa.h>
2) Adding Cocoa Framework in project->Buld Phases->Link Binary With Libraries.
3) Setting "Type" of all my .cpp files to "Objective-C++ Source" in the most right column in xCode.
you need to add this before main function
#import <AppKit/AppKit.h>
You need to import AppKit as mentioned by others and – as important as the framework – you need a run loop. So insert before the runModal line
[NSApplication sharedApplication];
to launch the "application" and the run loop

IBAction makes errors on theos compiling

I'm new to Objective-C programming and I want to make a simple tweak about VLC for iOS.app but I can't compile.
Here's my code :
#import <UIKit/UIKit.h>
%hook VLCMovieViewController
-(IBAction)playPause
{
if([_mediaPlayer isPlaying]) {
UIAlertView *pause = [[UIAlertView alloc] initWithTitle:#"PAUSED" message:#"Your movie is paused" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK !", nil];
[_listPlayer pause];
[pause show];
[pause release];
}
else
{
UIAlertView *play = [[UIAlertView alloc] initWithTitle:#"PLAYING" message:#"Your movie is playing" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK !", nil];
[_listPlayer play];
[play show];
[play release];
}
}
%end
I don't find any mistakes in my codes but when I try to compile, theos returns me an error :
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Tweak.xm:6:8: error: expected unqualified-id
static IBAction (*_logos_orig$_ungrouped$VLCMovieViewController$playPause)(VLCMovieViewController*, SEL); s...
^
<built-in :24:22: note: expanded from here
#define IBAction void)__attribute__((ibaction)
^
1 error generated.
make[2]: *** [obj/Tweak.xm.708dff35.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [VLCTweak.all.tweak.variables] Error 2
Have you any clue to make it working ?
Many thanks in advance
You don't need to use IBAction with Theos, as you don't use Interface Builder.
IBAction is only a way to tell Xcode and Interface Builder to link UI elements to your code.
Replacing -(IBAction)playPause by -(void)playPause should work

Developing jailbreak tweak

I have searched everywhere for a solution to this but cannot find one.
My tweak, developed in Theos is very simple, I want to disable the mute button in the phone app. I have found the private framework I think I need and the code that is called.
I have added a message so i can see if this routine is called, but is not.
Although my code compiles and installs on the phone, it never runs.
I have tried a basic springboard tweak and that is fine, so I must be doing something wrong with the framework or subroutine called?
(I have also added com.apple.mobilephone to my plist as suggested somewhere)
Here is my MAKEFILE
include theos/makefiles/common.mk
TARGET_IPHONEOS_DEPLOYMENT_VERSION=7.0
TWEAK_NAME = Disablemute
TARGET = iphone:7.0:7.0
ARCHS = armv7
Disablemute_FILES = Tweak.xm
Disablemute_FRAMEWORKS = UIKit
Disablemute_PRIVATE_FRAMEWORKS = TelephonyUtilities CoreTelephony
include $(THEOS_MAKE_PATH)/tweak.mk
Here is the tweak.mk code
#import <PrivateFrameworks/TelephonyUtilities/TUCall.h>
#import <UIKit/UIKit.h>
%hook TUCall
- (void)setMuted:(BOOL)arg1 {
//%orig;
%log;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Welcome"
message:#"Welcome to your iPhone Burt!"
delegate:nil
cancelButtonTitle:#"Thanks"
otherButtonTitles:nil];
[alert show];
[alert release];
}
%end
So the private framework is TelephonyUtilities and the header file is TUCall.h, the function is -void SetMuted:(BOOL)arg1;
Can anyone help please.

Hpple Error - "_OBJC_CLASS_$_TFHpple"

My app uses Hpple. I've included, TFHpple.h, TFHpple.m, TFHppleElement.h, TFHppleElement.m, XPathQuery.h & XPathQuery.m. Also included ${SDKROOT}/usr/include/libxml2 and -lxml2.
I have this tiny bit of code:
NSData *data = [[NSData alloc] initWithContentsOfFile:#"example.html"];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:data];
When I try to run it, I receive this error:
"_OBJC_CLASS_$_TFHpple", referenced from:
objc-class-ref in test.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't know how to solve this. Any ideas?
What exactly do you mean by "I've included" those files? The error indicates that you didn't add TFHpple.m to your target's "Compile Sources" build phase.

Weird Error With Apple Script Bridge - iTunes

I'm trying to create an ObjC application that will control iTunes. I need a method that will return an array of all the playlists in iTunes.
I'm getting the most bizarre, unhelpful error message ever... First the code:
#import "MusicControl.h"
#import "iTunes.h"
#implementation MusicControl
- (SBElementArray *) playlists {
// Create iTunes Object
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:#"com.apple.iTunes"];
NSArray *sources = [iTunes sources];
iTunesSource *librarySource = nil;
for (iTunesSource *source in sources) {
if ([source kind] == iTunesESrcLibrary) {
librarySource = source;
break;
}
}
return [librarySource userPlaylists];
}
#end
I have no idea whether the array return is working or not because, after doing some debugging, I found that where this is bombing out is the very first line where I create the iTunes object, which was copied and pasted from Apple's website...
The error I'm getting is:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_SBApplication", referenced from:
objc-class-ref in MusicControl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestion as the what the heck is going on?
This message (and similar ones) means that the linker is looking for some specific symbol, but can't find it. In your case it is SBApplication.
If you have not already done so, you should make sure that you have linked to the ScriptingBridge framework.
To add a framework, click on the project's icon at the top of the left hand bar in Xcode, then select Build Phases. If Link With Binary Libraries is not already expanded, do that and add the framework.
The same procedure can be used for plain libraries (a framework is really just a wrapper around a library, at least for the purpose of this discussion).