Crash with cocoa pods version of 1Password Extension [Moved to GitHub repo issue tracker]

tapzapp
tapzapp
Community Member
edited October 2014 in iOS

Hi,

When I tap on the 1Password extension in my app, I'm getting a crash:

*** Terminating app due to uncaught exception 'Invalid argument: web view must be an instance of WKWebView or UIWebView.', reason: ''

The problematic code is here:

- (void)fillLoginIntoWebView:(id)webView forViewController:(UIViewController *)viewController sender:(id)sender completion:(void (^)(BOOL success, NSError *error))completion
{
NSAssert(webView != nil, @"webView must not be nil");
NSAssert(viewController != nil, @"viewController must not be nil");

#ifdef __IPHONE_8_0
if ([webView isKindOfClass:[UIWebView class]]) {
    [self fillLoginIntoUIWebView:webView webViewController:viewController sender:(id)sender completion:^(BOOL success, NSError *error) {
        if (completion) {
            completion(success, error);
        }
    }];
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
else if ([webView isKindOfClass:[WKWebView class]]) {
    [self fillLoginIntoWKWebView:webView forViewController:viewController sender:(id)sender completion:^(BOOL success, NSError *error) {
        if (completion) {
            completion(success, error);
        }
    }];
}
#endif
else {
    [NSException raise:@"Invalid argument: web view must be an instance of WKWebView or UIWebView." format:@""];
}
#endif
}

It falls right through to the final else statement saying that I must use an instance of WKWebView or UIWebView. I'm using WKWebView with iOS 8.0.2.

Comments

  • tapzapp
    tapzapp
    Community Member

    Not sure what I'm doing wrong. The ACME Browser demo works fine.

    self.wkWebView: <WKWebView: 0x1265a36b0; frame = (0 0; 375 559); layer = <CALayer: 0x170626180>>
    2014-10-05 17:42:40.306 Tap Forms[654:246328] *** Terminating app due to uncaught exception 'Invalid argument: web view must be an instance of WKWebView or UIWebView.', reason: ''
    

    I print out my WKWebView just before I call the 1Password code. So it's definitely a WKWebView object.

    My code is almost the same as your sample code:

    - (IBAction)fillUsing1Password:(id)sender {
    
    self.didUseExtension = YES;
    
    __weak WebsiteViewController *weakSelf = self;
    
    TFFLog(@"self.wkWebView: %@", self.wkWebView)
    
    [[OnePasswordExtension sharedExtension] fillLoginIntoWebView:self.wkWebView forViewController:self sender:sender completion:^(BOOL success, NSError *error) {
        if (!success) {
            NSLog(@"Failed to fill login in webview: <%@>", error);
        }
    
        weakSelf.didUseExtension = NO;
    
    }];
    }
    

    Am I doing anything wrong there? Not that I can see. Just logging the object for testing and setting a flag and that's it.

  • tapzapp
    tapzapp
    Community Member

    I'm building with Xcode 6.0.1 if that makes a difference.

  • tapzapp
    tapzapp
    Community Member

    There must be something with using the extension from cocoa pods because when I simply embedded the source into my app, it worked fine.

  • MikeT
    edited October 2014

    Hi @tapzapp,

    I'm glad you got it working, I know there were a few issues with the CocoaPods and the team is trying to resolve it.

    In the meantime, please file your issues at our GitHub repo that's hosting the extension, you'll get direct support from our extension team that will know better than our team here.

This discussion has been closed.