how to create a warning/action board on Objective-C and create 1 theos project

46 Views Asked by At

I have 1 snippet of this warning code but I don't know how to create 1 theos Makefile project please help me

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"My Alert"
            message:@"This is an action sheet." 
            preferredStyle:UIAlertControllerStyleAlert]; // 1
    UIAlertAction *firstAction = [UIAlertAction actionWithTitle:@"one"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button one");
            }]; // 2
    UIAlertAction *secondAction = [UIAlertAction actionWithTitle:@"two"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button two");
            }]; // 3

    [alert addAction:firstAction]; // 4
    [alert addAction:secondAction]; // 5

    [self presentViewController:alert animated:YES completion: nil]; // 6

I created 2 makefile files and Tweak.xm

-makefile
`ARCHS = armv7 arm64
TARGET = iphone:latest:13.0

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = YourTweak
YourTweak_FILES = Tweak.xm

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
    install.exec "killall -9 SpringBoard"

Tweak.xm

#import <UIKit/UIKit.h>

%hook SpringBoard

- (void)applicationDidBecomeActive:(id)application {
    %orig;

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title"
                                                                   message:@"This is a warning"
                                                            preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK"
                                                       style:UIAlertActionStyleDefault
                                                     handler:^(UIAlertAction *action) {
                                                         // Handle OK button action
                                                     }];

    [alert addAction:okAction];
    [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion: nil];
}

%end

seems to have been faulty please help me

0

There are 0 best solutions below