Skip to content

Commit

Permalink
1.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
yandevelop committed May 29, 2024
1 parent 8328129 commit def8a47
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $(TWEAK_NAME)_CFLAGS = -fobjc-arc -Wno-module-import-in-extern-c
$(TWEAK_NAME)_FRAMEWORKS = UIKit MapKit

ifeq ($(JAILED), 1)
$(TWEAK_NAME)_FILES += fishhook/fishhook.c
$(TWEAK_NAME)_FILES += fishhook/fishhook.c SideloadFix/SideloadFix.xm
$(TWEAK_NAME)_CFLAGS += -D JAILED=1
endif

Expand Down
5 changes: 5 additions & 0 deletions SideloadFix/SideloadedFixes.h → SideloadFix/SideloadFix.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#import <Foundation/Foundation.h>
#import <mach-o/dyld.h>
#import "fishhook/fishhook.h"
#import <objc/runtime.h>
#import <dlfcn.h>

#define BR_BUNDLE_ID @"AlexisBarreyat.BeReal"
#define BR_NAME @"BeReal."

@interface NSFileManager (SideloadedFixes)
- (NSURL*)swizzled_containerURLForSecurityApplicationGroupIdentifier:(NSString*)groupIdentifier;
Expand Down
30 changes: 29 additions & 1 deletion SideloadFix/SideloadedFixes.mm → SideloadFix/SideloadFix.xm
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
#import "SideloadedFixes.h"
#import "SideloadFix.h"

// All credits go to https://github.com/level3tjg/RedditSideloadFix and https://github.com/opa334/IGSideloadFix

%hook NSBundle

- (NSString *)bundleIdentifier {
NSArray *address = [NSThread callStackReturnAddresses];
Dl_info info;
if (dladdr((void *)[address[2] longLongValue], &info) == 0) return %orig;
NSString *path = [NSString stringWithUTF8String:info.dli_fname];
if ([path hasPrefix:NSBundle.mainBundle.bundlePath]) return BR_BUNDLE_ID;
return %orig;
}

- (id)objectForInfoDictionaryKey:(NSString *)key {
if ([key isEqualToString:@"CFBundleIdentifier"]) return BR_BUNDLE_ID;
if ([key isEqualToString:@"CFBundleDisplayName"] || [key isEqualToString:@"CFBundleName"]) return BR_NAME;
return %orig;
}

%end


NSString* keychainAccessGroup;
NSURL* fakeGroupContainerURL;

Expand All @@ -25,6 +45,9 @@ - (NSURL*)swizzled_containerURLForSecurityApplicationGroupIdentifier:(NSString*)

@end

// Thanks to level3tjg! https://github.com/level3tjg/TwitchAdBlock/blob/master/Sideloaded.x


static void loadKeychainAccessGroup() {
NSDictionary* dummyItem = @{
(__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,
Expand Down Expand Up @@ -101,4 +124,9 @@ static void initSideloadedFixes() {
Method originalMethod = class_getInstanceMethod([NSFileManager class], @selector(containerURLForSecurityApplicationGroupIdentifier:));
Method swizzledMethod = class_getInstanceMethod([NSFileManager class], @selector(swizzled_containerURLForSecurityApplicationGroupIdentifier:));
method_exchangeImplementations(originalMethod, swizzledMethod);
}

%ctor {
%init;
initSideloadedFixes();
}
7 changes: 2 additions & 5 deletions Tweak/Bea.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NSDictionary *headers;
@interface HomeViewController : UIViewController
@property (nonatomic, retain) UIImageView *ibNavBarLogoImageView;
- (void)openDebugMenu;
- (void)showVersionAlert;
@end

@interface SettingsViewController : UIViewController
Expand All @@ -28,8 +29,4 @@ NSDictionary *headers;

@interface RealPeoplePreviewDoublePhotoView : UIView
@property (nonatomic, assign) BOOL didUnblur;
@end

#ifdef JAILED
#import "SideloadFix/SideloadedFixes.mm"
#endif
@end
24 changes: 19 additions & 5 deletions Tweak/Bea.x
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static NSString *corporateContentVC = @"_TtGC7SwiftUI19UIHostingControllerV26Acc
[self setDownloadButton:downloadButton];
[self addSubview:downloadButton];


[NSLayoutConstraint activateConstraints:@[
[[[self downloadButton] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor] constant:-11.6],
[[[self downloadButton] bottomAnchor] constraintEqualToAnchor:[self topAnchor] constant:47.333]
Expand Down Expand Up @@ -110,6 +109,25 @@ static NSString *corporateContentVC = @"_TtGC7SwiftUI19UIHostingControllerV26Acc
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[stackView addGestureRecognizer:tapGestureRecognizer];
[stackView setUserInteractionEnabled:YES];

[self showVersionAlert];
}

%new
- (void)showVersionAlert {
// get current version
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];

// check if version is greater or equal to 2.15.0

if ([version compare:@"2.15.0" options:NSNumericSearch] != NSOrderedAscending) {
// create a alert controller
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Unsupported" message:@"You are using a version of BeReal that is not yet supported by Bea. It is recommended to use BeReal versions 2.14.2 or smaller for Bea to work properly." preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
}

%new
Expand Down Expand Up @@ -233,8 +251,4 @@ static NSString *corporateContentVC = @"_TtGC7SwiftUI19UIHostingControllerV26Acc
SettingsViewController = objc_getClass("BeReal.SettingsViewController"),
HomeViewController = objc_getClass("BeReal.HomeViewController"),
RealPeoplePreviewDoublePhotoView = objc_getClass("_TtCV14RealComponents22DoubleMediaViewSwiftUI23PrimaryImageGestureView"));

#ifdef JAILED
initSideloadedFixes();
#endif
}
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: com.yan.bea
Name: Bea
Version: 1.3.7
Version: 1.3.8
Architecture: iphoneos-arm
Description: Lightweight BeReal. enhancement tweak.
Maintainer: yan
Expand Down

0 comments on commit def8a47

Please sign in to comment.