-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS crashes on launch (expo) #43
Comments
I am also having this problem, will this be addressed soon? |
Also having this problem. I tried typecasting the the rootViewController like this:
and this:
but they both got the same error. Bear in mind, I don't know the first thing about Objective-C, or Swift, or managing a bare react-native workflow, so I don't know if I typecasted correctly, or if it even makes sense to typecast in this context. I'm using an expo managed project that has been ejected with expokit. |
Well the package is working as intended now, and the reason is that I replaced
with
and it worked. I didn't try it before since @ideopunk said they did the same and ran into a problem. I checked the issues before ever trying it myself and just assumed I would run into the same problem. That said, I'm not sure why it worked for me and not them. Still, I think the installation guide should address this case for people using expo projects. |
Casting will not work because we need to create the rootView from the HomeIndicatorViewController class. This is mandatory for the functionality of the library. Thats also why the error explicitly gets thrown when the I'm unsure if replacing the init of the I don't have any experience with expo so I don't have a feeling for the downsides of this approach. Does it still work for you @jakeorbtl ? |
@ideopunk Did you have any luck ever getting this to work? |
Also wondering :-) |
Here's a working config plugin for anyone who needs it. Note: This simply turns it off entirely. It does not provide the option to set it manually. const { withAppDelegate } = require('@expo/config-plugins')
function withHiddenHomeIndicator(expoConfig) {
return withAppDelegate(expoConfig, (config) => {
const { modResults } = config
const { contents } = modResults
const lines = contents.split('\n')
const importIndex = lines.findIndex((line) => /^#import "AppDelegate.h"/.test(line))
modResults.contents = [
'#import <objc/runtime.h>',
...lines.slice(0, importIndex + 1),
...lines.slice(importIndex + 1),
'@implementation UIViewController (Swizzling)',
'+ (void)load',
'{',
' static dispatch_once_t onceToken;',
' dispatch_once(&onceToken, ^{',
' Class classVC = [self class];',
' SEL originalSelector = @selector(prefersHomeIndicatorAutoHidden);',
' SEL swizzledSelector = @selector(swizzledPrefersHomeIndicatorAutoHidden);',
' Method originalMethod = class_getInstanceMethod(classVC, originalSelector);',
' Method swizzledMethod = class_getInstanceMethod(classVC, swizzledSelector);',
' const BOOL didAdd = class_addMethod(classVC, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));',
' if (didAdd)',
' class_replaceMethod(classVC, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));',
' else',
' method_exchangeImplementations(originalMethod, swizzledMethod);',
' });',
'}',
'- (BOOL)prefersHomeIndicatorAutoHidden {',
' return YES;',
'}',
'- (BOOL)swizzledPrefersHomeIndicatorAutoHidden {',
' return YES;',
'}',
'@end',
].join('\n')
return config
})
}
module.exports = withHiddenHomeIndicator |
Wow, I'm impressed and terrified that it's possible to alter AppDelegate.h so drastically without even (re)building a native app. I knew objective c was quite dynamic but I didn't realise it was that dynamic. Thanks for your contribution! |
I want to ask if it is possible to do with this preferredScreenEdgesDeferringSystemGestures method
but i got error... I am trying to modify the iOS behavior where the home indicator dims, then requires two swipes to activate: the first swipe to brighten the indicator and the second swipe to invoke the home action. This is to mimic the behavior of preferredScreenEdgesDeferringSystemGestures in a native iOS app |
@syropian Are you using this in any of your repos? How does one instantiate your plugin? I've tried importing it and adding a |
@Ever-It-Lazy It's a pretty quick-n-dirty solution so keep in mind it will apply globally to your app. All you need to do is add the code I wrote to a file called something like
|
@syropian Global is fine. An ever-present Home Indicator kind of ruins the app I'm trying to build. I've attempted what you said in a bare bones Expo app. It no longer errs, but the Home Indicator is just as visible as ever, at the screen's bottom. |
I guess I'd also be cool with the workaround devised by @jakeorbtl...if I could understand how to apply and deploy it? It seems like the file being changed is
|
@Ever-It-Lazy FYI this will only work in the context of a development build using |
@syropian It took me a while to learn expo-dev-client. My discoveries:
I had to eventually learn deployment, anyway, so I welcome the experiment. But I did include a repo above, to make this trial-and-error a bit more tangible. So please, do let me know if you ever post a simple, functional example of your plugin (or get my example working). *correction: your plugin has roughly the same effect as the |
I'm attempting to create a config plugin so that this library will work with Expo. However, on app launch I get this error:
DevLauncher tries to handle uncaught exception: rootViewController is not of type HomeIndicatorViewController as expected.
My
AppDelegate.m
didn't haveUIViewController *rootViewController = [UIViewController new];
as a line to replace, it hadUIViewController *rootViewController = [self.reactDelegate createRootViewController];
instead, so I replaced it. I suspect this has something to do with the problem.The text was updated successfully, but these errors were encountered: