How to debug/run Xamarin.Forms app on iPhone device?

batmacibatmaci DEMember ✭✭✭✭✭

I don't understand the best way to debug xamarin.forms app to debug on an actual device using MacBook.
I have no problem to debug on an emulator. it is super fast indeed but when I want to debug on an iPhone, using test provisining, I am having several problems.
1) first of all I tried to test on an old iPhone 4 device and it has 32 bit size limitation which makes it impossible to debug as we need to enable linking+llvm. it looks like that llvm is the only option to run it on old devices but this is disabled on debug build. why?
2) I tried to run it in release build. another problem comes out. I have entitlements file and it complains that app I build using Xcode for test provision doesn't have same entitlements. is that xamarin specific? I couldn't find a way to build it using Xcode.
3) finally I removed enititlements from xamarin.ios app and app was installed on iPhone but when I run it, it crashes after splash screen. I checked the device logs, I am seeing errors below. If I understand correctly, my app is not able to connect internet although iPhone has cellular internet access working fine. how can I fix it? as far as I know, xamarin iOS has no setting like "allow internet" like android project has. does this occur because I removed entitlements
file where I had some permissions and capabilities. I tested it on emulator, it works fine. Why even app is crashing if I don't have internet access? I download some app data at the time of app load but this shouldn't crash the app, it should show app without data. Scenario works fine on emulator.

Error (2013) / myappiOS(CFNetwork): TIC TCP Conn Failed [1:0x17df1890]: 1:50 Err(50)
Error (2013) / myappiOS(CFNetwork): TIC TCP Conn Failed [2:0x17f664e0]: 1:50 Err(50)
Error (2013) / myappiOS(CFNetwork): HTTP load failed (error code: -1009 [1:50])
Error (2013) / myappiOS(CFNetwork): NSURLSessionTask finished with error - code: -1009
Error (2013) / myappiOS(CFNetwork): HTTP load failed (error code: -1009 [1:50])
Error (2013) / myappiOS(CFNetwork): NSURLSessionTask finished with error - code: -1009
Error (2013) / myappiOS(CFNetwork): TIC TCP Conn Failed [3:0x197ecf10]: 1:50 Err(50)
Error (2013) / myappiOS(CFNetwork): HTTP load failed (error code: -1009 [1:50])
Error (2013) / myappiOS(CFNetwork): NSURLSessionTask finished with error - code: -1009

Answers

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    After iOS 10.0 . Internet is unavailable in default . And it will display an alert to get the when you first install the app .

    So it is unwise to access data in method FinishedLaunching . If you do want to do this , you can add a notification and access the data when user allow the network .

    in FinishedLaunching

    if(UIDevice.CurrentDevice.CheckSystemVersion(10,0))
     {
        CheckStates(app, options);
     }
    
    else
     {
        //load data
     }
    

    And

    void CheckStates (UIApplication app, NSDictionary options)
            {
                CTCellularData cellularData = new CTCellularData();
    
                cellularData.RestrictionDidUpdateNotifier += (state) =>{
    
                    if(state== CTCellularDataRestrictedState.NotRestricted)
                    {
                        // load data
                    }
    
                    else if(state== CTCellularDataRestrictedState.Restricted)
                    {
                        // user does not allow network access 
                        //you can use UIAlertViewController to remind user change the value in System Setting
                    }
    
                    else
                    {
                        // unknow error
                    }
    
    
                };
    
            }
    
  • batmacibatmaci DEMember ✭✭✭✭✭

    thanks for that information. good to know but it has nothing to do with this. I have enabled NSUrlSession for http client as in the screenshot but my iPhone returns CFNetwork results as above logs shows. I am not sure if that is something to do with old iPhone 4 32 bit device. although it is running on iOS 10.3 and it supposed to support NSUrlSession. any idea why I am seeing CFNetwork in my logs?

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    Why did you test you app on such an old device ?

  • batmacibatmaci DEMember ✭✭✭✭✭

    because I want to support minimum iPhone 4.

  • batmacibatmaci DEMember ✭✭✭✭✭
    edited June 16
    Actually I found the problem. It is a bug in vs 2019 mac I believe. iPhone 4 supports ios 7 max version but when I connect to mac , vs tells me that I need to use min ios 10.3. When I build and install on the device, it does install but app wont start.
  • JohnHJohnH GBMember ✭✭✭✭✭
    Xamarin Forms minimum iOS version is 8.
  • batmacibatmaci DEMember ✭✭✭✭✭

    thats fine but point is that as i said, i didnt know anything about iphone 4 (android user :)) . just connected it blindly to see how my app works on it and VS 2019 gives me warning that iphone 4 needs to use ios 10 which is wrong statement. it supposed to say that device isn't supported. Instead it let me build and install the app on the device and even splash screen loads fine but then mainpage fails instantly.

  • NMackayNMackay GBInsider, University mod
    edited June 17

    Apple only supports 64bit chipsets now, iPhone 5s upwards....and I'm an Android user :D

Sign In or Register to comment.