Rahul Rahul - 2 months ago 53
iOS Question

Error: Protocol not available, dumping backtrace

2016-09-17 15:16:04.386085 appDemo[2371:94976] [] __nwlog_err_simulate_crash simulate crash already simulated **"nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"**
2016-09-17 15:16:04.386676 appDemo[2371:94976] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
[x86_64] libnetcore-856.1.8
0 libsystem_network.dylib 0x0000000112dc780e __nw_create_backtrace_string + 123
1 libnetwork.dylib 0x0000000113bfa194 nw_socket_add_input_handler + 3002
2 libnetwork.dylib 0x0000000113bd7db8 nw_endpoint_flow_attach_protocols + 3768
3 libnetwork.dylib 0x0000000113bd6dd5 nw_endpoint_flow_setup_socket + 563
4 libnetwork.dylib 0x0000000113bd5b34 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
5 libnetwork.dylib 0x0000000113bf0d11 nw_endpoint_handler_path_change + 1261
6 libnetwork.dylib 0x0000000113bf0740 nw_endpoint_handler_start + 570
7 libdispatch.dylib 0x0000000112b44980 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x0000000112b6e
2016-09-17 15:16:04.387153 appDemo[2371:94976] [] nw_endpoint_flow_attach_protocols [2 192.168.0.100:80 in_progress socket-flow (satisfied)] Attached flow protocol
2016-09-17 15:16:04.387679 appDemo[2371:94976] [] nw_connection_endpoint_report [2 192.168.0.100:80 in_progress socket-flow (satisfied)] reported event flow:start_connect


I'm using
xcode 8
version with
ios 10
. Now, I'm working an API. If, I use the API in
Xcode 7
its works fine but when same API I used in
xcode 8
error message appears Unable to parse.

Answer

I found the solution as follows:

  1. Go to Edit Scheme
  2. Go to Environment Variable
  3. Set OS_ACTIVITY_MODE disable
  4. Then try the following code:

            NSString *deviceToken = [[NSUserDefaults standardUserDefaults]valueForKey:kDeviceToken];
        if (deviceToken.length==0)
        {
            deviceToken = @"123";
        }
        NSDictionary *dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:
                                    name,@"fullname",
                                    email,@"email",
                                    password,@"password",
                                    deviceToken,@"device_token",
                                    @"2",@"platform",
                                    nil];
    
        [[APIMaster getSharedInstance]callAPIWithURL:@"users/registration" andPostDictionary:dictionary WithCallBackResponse:^(NSURLSessionDataTask *operation, id responseObject, NSError *error) {
    
            if (error)
            {
                NSLog(@"error is %@",error.localizedDescription);
                [self stopLoadingIndicator]; // stop loading indicator
            }
            else
            {
                [self stopLoadingIndicator]; // stop loading indicator
    
                NSDictionary* json = (NSDictionary* ) responseObject;
                NSLog(@"response is %@",json);
    
    
                if ([[json valueForKey:@"code"]integerValue]==200) //success
                {
                    [[NSUserDefaults standardUserDefaults]setObject:[json objectForKey:@"response"] forKey:kLoginData];
                    [[NSUserDefaults standardUserDefaults]synchronize];
    
                    NSString *email_status = [NSString stringWithFormat:@"%@",[[[NSUserDefaults standardUserDefaults] valueForKey:kLoginData] valueForKey:@"status"]];
    
                    NSString *phone_number_skip = [NSString stringWithFormat:@"%@",[[[NSUserDefaults standardUserDefaults] valueForKey:kLoginData] valueForKey:@"skip"]];
    
                    if ([email_status integerValue]==0 || [email_status isEqualToString:@"0"]) // email not verified
                    {
                        EmailVerificationVC *emailVerify = [[EmailVerificationVC alloc]init];
                        [self.navigationController pushViewController:emailVerify animated:YES];
                    }
                    else if ([phone_number_skip integerValue]==0 || [phone_number_skip isEqualToString:@"0"]) //phone number not skipped
                    {
                        AddPhoneVC *registerClass = [[AddPhoneVC alloc]init];
                        [self.navigationController pushViewController:registerClass animated:YES];
                    }
                    else //phone number skipped. directly open landing page.
                    {
                        LandingPageVC *summary = [[LandingPageVC alloc]init];
                        [self.navigationController pushViewController:summary animated:YES];
                    }
                }
    
                else if ([[json valueForKey:@"code"]integerValue]==401) //invalid access token
                {
                    [appDelegate() functionToHandleInvalidAccessToken];
                }
                else // error message
                {
                    NSString *message = [UIFunction showErrorMessageWithCode:[[json valueForKey:@"code"] integerValue]];
                    [self showAlertFromServerWithMessage: message];
                }
            }
        }];