Xamarin Forms - iOS App - Runs well in Debug, but crashes with Adhoc or AppStore builds

Paul McKinney 6 Reputation points
2021-07-28T04:04:18.84+00:00

Hi,

The app we have developed using Xamarin Forms (also incorporating DevExpress packages, Xamarin Essentials, in-app billing plugin) works well in Android, and was working well on iOS while in Debug mode ... but as soon as I build the app for Adhoc or AppStore distribution, and use Xcode to distribute to my iPhone or to TestFlight, the app crashes immediately after the launch screen starts.

I believe that the Distribution profiles are all setup correctly, as I am able to create the archive in Visual Studio 2019 with the Development profile and then use Xcode to distribute the archive using the Appstore distribution profile and upload to TestFlight with no errors. The app validates ok in Xcode as well.

Here is the trace I am getting from the device when installing using TestFlight:

default 11:21:57.657990+1000 appstored [253E5E2C] Completed with 1 result: <ASDApp: 0x103793250>: {bundleID = com.seveno.DSApp; installed = 1}
default 11:22:04.286089+1000 lsd [FBSSystemService][0xdb39] Sending request to open "com.seveno.DSApp"
default 11:22:04.286412+1000 SpringBoard [FBSystemService][0xdb39] Received request to open "com.seveno.DSApp" from lsd:97.
default 11:22:04.286485+1000 SpringBoard Received trusted open application request for "com.seveno.DSApp" from <FBProcess: 0x100e0e4b0; daemon<com.apple.lsd>:97(vF8)>.
default 2021-07-.72207828 11:22:04+1000 SpringBoard [sceneID:com.seveno.DSApp-default] Scene action [Logical Activate][0x6262] completed with success: 0
default 11:22:04.722382+1000 SpringBoard [application<com.seveno.DSApp>:8132] Workspace connection invalidated.
default 11:22:04.722419+1000 SpringBoard [application<com.seveno.DSApp>:8132] Now flagged as pending exit for reason: workspace client connection invalidated
default 11:22:04.787540+1000 runningboardd [application<com.seveno.DSApp>:8132] termination reported by launchd (0, 0, 6)
default 11:22:04.787559+1000 runningboardd Removing process: [application<com.seveno.DSApp>:8132]
default 11:22:04.787862+1000 runningboardd Removing launch job for: [application<com.seveno.DSApp>:8132]
default 11:22:04.788008+1000 runningboardd Removed job for [application<com.seveno.DSApp>:8132]
default 11:22:04.789016+1000 runningboardd Removing assertions for terminated process: [application<com.seveno.DSApp>:8132]
default 11:22:04.789104+1000 runningboardd Removed last relative-start-date-defining assertion for process application<com.seveno.DSApp>
default 11:22:04.820358+1000 runningboardd Calculated state for application<com.seveno.DSApp>: none (role: None)
default 11:22:04.820635+1000 SpringBoard [application<com.seveno.DSApp>:8132] Process exited: <RBSProcessExitContext| voluntary>.
default 11:22:04.820652+1000 SpringBoard [application<com.seveno.DSApp>:8132] Setting process task state to: Not Running
default 11:22:04.820671+1000 SpringBoard [application<com.seveno.DSApp>:8132] Setting process visibility to: Unknown
default 11:22:04.820841+1000 runningboardd Calculated state for application<com.seveno.DSApp>: none (role: None)
default 11:22:04.821085+1000 SpringBoard [application<com.seveno.DSApp>:8132] Invalidating workspace.
default 11:22:04.821192+1000 SpringBoard Removing workspace registration for processHandle: [application<com.seveno.DSApp>:8132]
default 11:22:04.940821+1000 locationd Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.941776+1000 locationd {"msg":"#CLIUA Marking change", "clientKey":"com.seveno.DSApp", "reason":"Process state from RunningBoard", "assertionLevel":5, "coming":1}
default 11:22:04.943890+1000 aggregated Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.944319+1000 wifid Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.945125+1000 symptomsd Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.945197+1000 watchdogd Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.946419+1000 backboardd Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.946522+1000 contextstored Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.946679+1000 UserEventAgent Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.948972+1000 ReportCrash osa_update: Pid 8132 'DSApp.iOS' CORPSE: Capture Complete
default 11:22:04.949007+1000 ReportCrash Formulating fatal report for corpse[8132] DSApp.iOS
default 11:22:04.949403+1000 locationd {"msg":"#CLIUA Marking change", "clientKey":"com.seveno.DSApp", "reason":"Process state from RunningBoard", "assertionLevel":5, "coming":0}
default 11:22:04.953548+1000 callservicesd Hit the server for a process handle 13b81fd00001fc4 that resolved to: [application<com.seveno.DSApp>:8132]
default 11:22:04.954672+1000 appstored Received a beta app crash notification for com.seveno.DSApp
default 11:22:04.956487+1000 SpringBoard [Main] dispatch event:
<SBMainTransitionSwitcherModifierEvent: 0x281746f20; type: MainTransition; transitionID: 697E59E9-54D3-4E08-8E2E-CC9F8AB9E673; phase: Complete; animated: YES; fromAppLayout: <SBAppLayout: 0x2836eda00; primary: com.apple.TestFlight; environment: main>; toAppLayout: <SBAppLayout: 0x283792500; primary: com.seveno.DSApp; environment: main>; pendingTermination: {(
)}>
default 11:22:04.957396+1000 ReportCrash osa_update: Pid 8134 'DSApp.iOS' CORPSE: Symbolicating
default 11:22:04.959289+1000 SpringBoard Received request to activate alertItem: <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored; pid: 159>
default 11:22:04.959312+1000 SpringBoard Activation - Presenting <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored; pid: 159> with presenter: <SBUnlockedAlertItemPresenter: 0x282e88b20>
default 11:22:04.959554+1000 ReportCrash osa_update: Pid 8134 'DSApp.iOS' CORPSE: Symbolicating2
default 11:22:04.988651+1000 kbd Hit the server for a process handle 12d31af900001fc6 that resolved to: [application<com.seveno.DSApp>:8134]
default 11:22:04.998087+1000 runningboardd [application<com.seveno.DSApp>:8134] termination reported by launchd (0, 0, 6)
default 11:22:04.998106+1000 runningboardd Removing process: [application<com.seveno.DSApp>:8134]
default 11:22:04.998163+1000 runningboardd Removing launch job for: [application<com.seveno.DSApp>:8134]
default 11:22:04.998204+1000 runningboardd Removed job for [application<com.seveno.DSApp>:8134]
default 11:22:04.998234+1000 runningboardd Removing assertions for terminated process: [application<com.seveno.DSApp>:8134]
default 11:22:04.998600+1000 runningboardd Removed last relative-start-date-defining assertion for process application<com.seveno.DSApp>
default 11:22:05.015687+1000 runningboardd Calculated state for application<com.seveno.DSApp>: none (role: None)
default 11:22:05.015780+1000 runningboardd Calculated state for application<com.seveno.DSApp>: none (role: None)
default 11:22:05.017004+1000 SpringBoard [application<com.seveno.DSApp>:8134] Process exited: <RBSProcessExitContext| voluntary>.
default 11:22:05.017021+1000 SpringBoard [application<com.seveno.DSApp>:8134] Setting process task state to: Not Running
default 11:22:05.017040+1000 SpringBoard [application<com.seveno.DSApp>:8134] Setting process visibility to: Unknown
default 11:22:05.017167+1000 SpringBoard [application<com.seveno.DSApp>:8134] Invalidating workspace.
default 11:22:05.017184+1000 SpringBoard Removing workspace registration for processHandle: [application<com.seveno.DSApp>:8134]
default 11:22:05.017201+1000 SpringBoard Removing: <FBApplicationProcess: 0x115b96080; application<com.seveno.DSApp>:8134(v5E24)>
default 11:22:05.017472+1000 SpringBoard Process exited: <FBApplicationProcess: 0x115b96080; application<com.seveno.DSApp>:8134(v5E24)> -> <RBSProcessExitContext| voluntary>
default 11:22:05.017779+1000 SpringBoard Application process state changed for com.seveno.DSApp: (null)
default 11:22:05.024640+1000 mediaserverd -CMSessionMgr- CMSessionMgrHandleApplicationStateChange: Client com.seveno.DSApp with pid '8134' is now Terminated. Background entitlement: NO ActiveLongFormVideoSession: NO WhitelistedLongFormVideoApp NO
error 11:22:05.024733+1000 SpringBoard Ignoring state for untracked process [application<com.seveno.DSApp>:8134]: <RBSProcessState| task:none debug:none>
default 11:22:05.037045+1000 analyticsd Received event: com.apple.stability.crash {"appVersion":"3.0.2","bundleID":"com.seveno.DSApp","exceptionCodes":"0x0000000000000000, 0x0000000000000000","incidentID":"AC81DC50-C74E-450A-ABA7-AB5047329099","logwritten":0,"process":"DSApp.iOS","terminationReasonNamespace":"<NO_NS>"}
default 11:22:05.037064+1000 analyticsd Aggregated. Transform: StabilityCrashNumerator3 Dirty: 1 Event: com.apple.stability.crash {"appVersion":"3.0.2","bundleID":"com.seveno.DSApp","exceptionCodes":"0x0000000000000000, 0x0000000000000000","incidentID":"AC81DC50-C74E-450A-ABA7-AB5047329099","logwritten":0,"process":"DSApp.iOS","terminationReasonNamespace":"<NO_NS>","timestamp":1627435324704629}
default 11:22:05.128437+1000 appstored Received a beta app crash notification for com.seveno.DSApp
default 11:22:05.198461+1000 SpringBoard Received request to activate alertItem: <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored; pid: 159>
default 11:22:05.198478+1000 SpringBoard Activation - Presenting <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored; pid: 159> with presenter: <SBUnlockedAlertItemPresenter: 0x282e88b20>
default 11:22:05.497370+1000 SpringBoard [application<com.seveno.DSApp>:8134] Dropping launch assertion.
default 11:22:10.568233+1000 SpringBoard Will deactivate alertItem: <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored> for reason: Button Pressed
default 11:22:10.570991+1000 SpringBoard Will deactivate alertItem: <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored> for reason: User Dismissed
default 11:22:10.571075+1000 SpringBoard Deactivated alertItem: <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored; pid: 159>
default 11:22:10.573956+1000 appstored User pressed cancel on dialog for crash of beta app with bundleID: com.seveno.DSApp
default 11:22:10.996191+1000 SpringBoard Deactivated alertItem: <SBUserNotificationAlert: 0x11590cfa0; title: “DSApp” Crashed; source: appstored; pid: 159>
default 11:22:12.210638+1000 SpringBoard Will deactivate alertItem: <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored> for reason: Button Pressed
default 11:22:12.213071+1000 SpringBoard Will deactivate alertItem: <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored> for reason: User Dismissed
default 11:22:12.213119+1000 SpringBoard Deactivated alertItem: <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored; pid: 159>
default 11:22:12.226281+1000 appstored User pressed cancel on dialog for crash of beta app with bundleID: com.seveno.DSApp
default 11:22:12.668123+1000 SpringBoard Deactivated alertItem: <SBUserNotificationAlert: 0x11592ac00; title: “DSApp” Crashed; source: appstored; pid: 159>

Can't see much that is useful in the above, but when I install the app on my iPhone directly using Xcode, the app does crash but this time adds the following lines to the output:

default 13:38:23.696096+1000 DSApp.iOS
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'DSApp.App' threw an exception. ---> System.InvalidOperationException: You must call Xamarin.Forms.Forms.Init(); prior to using this property.
at Xamarin.Forms.Device.get_PlatformServices () <0x1036c40c0 + 0x0005c> in <978ec34c5c9c4c4eb3d73b6da958bcd6#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at Xamarin.Forms.Device.GetAssemblies () <0x1036c4c60 + 0x0000b> in <978ec34c5c9c4c4eb3d73b6da958bcd6#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at Xamarin.Forms.DependencyService.Initialize () <0x1036c3870 + 0x0009b> in <978ec34c5c9c4c4eb3d73b6da958bcd6#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at Xamarin.Forms.DependencyService.Get[T] (Xamarin.Forms.DependencyFetchTarget fetchTarget) <0x1036c2e70 + 0x0002b> in <978ec34c5c9c4c4eb3d73b6da958bcd6#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at DSApp.App..cctor () <0x1062aa4f0 + 0x0020f> in <75685e241fe14204803ce1e9928c42cd#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
--- End of inner exception stack <…>
default 13:38:23.697068+1000 DSApp.iOS Unhandled managed exception: The type initializer for 'DSApp.App' threw an exception. (System.TypeInitializationException)
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x1053a7460 + 0x0002f> in <ad1be307855442e4b2cb88e33f94f908#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1053a72d0 + 0x00043> in <ad1be307855442e4b2cb88e33f94f908#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
at DSApp.iOS.Application.Main (System.String[] args) <0x102cf6b40 + 0x00023> in <3bc27722ccd949eb8c86e64ca19b9354#2ef9c4ad2238dd5726320c6b6cf9b7e3>:0
--- inner exception ---
You must call Xamarin.Forms.Forms.Init(); prior to using this property. (System.InvalidOperationException)
at Xamarin.Forms.Device.get_PlatformServices () <0x1036c40c0 + 0x0005c> in <978ec34c5c9c<…>

This also doesn't make a lot of sense, given the first line in AppDelegate.cs in the FinishedLaunching event is global::Xamarin.Forms.Forms.Init();

If there was a fundamental problem with the logic, it wouldn't work in Debug mode in iOS, and obviously the App works well on Android, so the issue must be something in the iOS specific code or archive. I have tried various combinations of iOS build settings, to no avail - current settings are:

  • SDK 14.4
  • Linker is Link Framework SDKs only (but have tried the other options)
  • Supported architecture is ARM64

I have seen some people have similar issues with crashing on TestFlight, but have not had any luck with those approaches either, such as:
https://stackoverflow.com/questions/14499334/how-to-prevent-ios-crash-reporters-from-crashing-monotouch-apps

It feels like something is missing from the Archive that is stopping the App from starting properly.

Any assistance to at least know how to approach debugging this would be most welcome!

Kind Regards,
Paul McKinney

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
{count} vote