5

I've seen reports for errors 4 but not for 5. I get this as a console message when I'm trying to use an "openParentApplication:reply" request. There isn't enough information in the log to know if the problem is in the iOS code, the WK code or the Simulator. I've restarted the sim, and cleaned the project. Any ideas?

WK Code:

- (IBAction)sendRequest {

    NSDictionary *request = @{@"request":@"Request1"};

    [InterfaceController openParentApplication:request reply:^(NSDictionary *replyInfo, NSError *error) {

        if (error) {
            NSLog(@"%@", error);
        } else {

            [self.label1 setText:[replyInfo objectForKey:@"response1"]];
            [self.label2 setText:[replyInfo objectForKey:@"response2"]];
            [self.label3 setText:[replyInfo objectForKey:@"response3"]];
        }

    }];
}

iOS Code:

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply{

    NSLog(@"%s", __FUNCTION__);
    //([max intValue] - [min intValue]) + [min intValue]

    int randNum1 = arc4random_uniform(16);
    int randNum2 = arc4random_uniform(16);
    int randNum3 = arc4random_uniform(16);


    NSString *num1 = [NSString stringWithFormat:@"Test%d", randNum1]; 
    NSString *num2 = [NSString stringWithFormat:@"Test%d", randNum2];
    NSString *num3 = [NSString stringWithFormat:@"Test%d", randNum3]; 

    if ([[userInfo objectForKey:@"request"] isEqualToString:@"Request1"]) {

        NSLog(@"containing app received message from watch: Request1");


        NSDictionary *response = @{@"response1" : num1, @"response2" : num2, @"response3" : num3};
        reply(response);
    }

}

The only console log is:

WatchKit Extension[48954:9523373] Error Domain=FBSOpenApplicationErrorDomain Code=5 "The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 5.)
Community
  • 1
  • 1
ICL1901
  • 7,632
  • 14
  • 90
  • 138
  • 2
    OK. As promised, the answer is as follows: In the info.plist, I had "Application Does Not Run in Background" set to YES. This caused the problem. Changing that setting to NO fixed it. Thanks to Faber on AppleDev forums. – ICL1901 Mar 11 '15 at 03:12

4 Answers4

6

I also faced same issue today.

  • Deleted app from simulator
  • Reset simulator
  • Restarted XCode
  • Made changes in info.plist

But when I ran app in Production, it worked . App was running well in production mode with simulator.

enter image description here

Next, I deleted existing dev mode scheme and created another dev mode scheme and it worked . Then it reminded me that while implementing background fetch feature in the app, I checked option Launch due to a background fetch event option in that Dev scheme. Later i gave up Background Fetch but forgot to uncheck this option.

enter image description here

Vaibhav Saran
  • 12,848
  • 3
  • 65
  • 75
  • I think that you need to set up an entitlement to be able to use this. In any case, Xcode should report WHY it can not launch the app, instead or reporting "error 5". I just ran into this today with Xcode 7.3 because I had checked this scheme option. – Alex Zavatone Apr 13 '16 at 18:46
1

I would suggest you try to simplify. I have answered a very similar problem here that is in Swift. I would simplify the logic to the following:

WK Code

- (IBAction)sendRequest {
    [InterfaceController openParentApplication:request reply:^(NSDictionary *replyInfo, NSError *error) {
        NSLog(@"Reply Info: %@", replyInfo);
        NSLog(@"Error: %@", error);
    }];
}

iOS Code

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
    NSDictionary *response = @{@"replyKey" : @"replyValue"};
    reply(response);
}

Once you have this working, then start adding the additional parsing one step at a time. You can also attach the debugger to the iOS app to step through the call by following these instructions. You may not be calling the reply block on the iOS app and you don't even know it.

Community
  • 1
  • 1
cnoon
  • 16,575
  • 7
  • 58
  • 66
  • Thanks for answering. I've been moving in that direction. I believe I am getting to the reply block as I've logged the error. It occurs there. But I'll go through your ideas more carefully.. – ICL1901 Mar 08 '15 at 04:29
  • It's intriguing, the response from NSLog(@"Reply Info: %@", replyInfo); is null.. I'm wondering if I've missed something.. I do have the connection working in a small test project, and I cannot see any difference-- except- that the other app had WK installed from the outset, not bolted on. Do you think that has anything to do with this problem? – ICL1901 Mar 09 '15 at 00:49
  • I'm afraid I don't understand quite what you mean. I'd say if you have it working in a smaller project and not the larger one, then you have a project configuration problem with the larger one. If that's the case, then I'd suggest you open a different question altogether to close this one out as resolved. – cnoon Mar 09 '15 at 01:45
  • Done, but does that mean that my code looks ok to you? And I don't quite know how I could frame a configuration question. Once I figure out what is happening, I'll post an update to my question. – ICL1901 Mar 09 '15 at 03:55
1

In my case only quitting simulator resolved the issue.

zeeawan
  • 6,667
  • 2
  • 50
  • 56
0

Disabling AVX/AVX2 Solved this error for me. if you're running macOS on Virtual Box terminal in

C > Program Files > Oracle > VirtualBox

then write this

VBoxManage setextradata "$vm_name" VBoxInternal/CPUM/IsaExts/AVX 0
VBoxManage setextradata "$vm_name" VBoxInternal/CPUM/IsaExts/AVX2 0

instead of $vm_name write your Virtual Machine Name

Binary_Hits00
  • 570
  • 6
  • 7