iOS Question Simulator Build crashing on


Well-Known Member
Licensed User
I usually build SIMULATOR release apps and run them in to get screenshots of other variants and test with other higher iOS versions.
But for the past 2 days, a simple calculator app I did was not running in and I get the following errors. Its running ok on my physical device iPhone 5s running ios 12.++

Its a B4XPages project and the other 3 libraries I added is iAdmob, XUI, XUi Views. Here is the code in the Main module

Code in the Main MOdule:
'Code module
#Region  Project Attributes
    #ApplicationLabel: E-levy Calculator
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait
    #iPadOrientations: Portrait
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
    'For Admob
    #PlistExtra: <key>GADIsAdManagerApp</key><true/>
    #AdditionalLib: libsqlite3.dylib
    #AdditionalLib: libz.dylib
    #AdditionalLib: WebKit.framework
    'for titlebar color
    #PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
#End Region

'#ProvisionFile: ElevyAdhoc.mobileprovision
#ProvisionFile: ElevyStore.mobileprovision  

Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController

    Public Const NavBarBarTintColor As Int = 0xFFF8D015
    Public Const NavBarTintColor As Int = Colors.white
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Dim PagesManager As B4XPagesManager
    NavControl.NavigationBarVisible = False
    Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(NavBarBarTintColor)))
    no.GetField("view").As(View).Color = NavBarBarTintColor
    Dim no As NativeObject = App
    no.RunMethod("setStatusBarStyle:", Array(0))    '1 for white text and 0 for black text
    SetTitleColor(Nav, Colors.White)
    Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setTintColor:", Array(no.ColorToUIColor(NavBarTintColor)))

End Sub

'Template version: B4i-1.0
#Region Delegates
Private Sub Application_Background
End Sub

Private Sub Application_Foreground
End Sub
#End Region

Sub SetTitleColor(nav As NavigationController, clr As Int)
    Dim attributes As NativeObject
    attributes = attributes.Initialize("B4IAttributedString").RunMethod("createAttributes::", _
     Array(Font.CreateNew(18), attributes.ColorToUIColor(clr)))
    Dim no As NativeObject = nav
    no.GetField("navigationBar").RunMethod("setTitleTextAttributes:", Array(attributes))
End Sub

This is the error I get from Debug log, and the app crashes.

2022-04-28 23:09:25.167 E-levy Calculator[39628:30325283] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
2022-04-28 23:09:25.167 E-levy Calculator[39628:30325283] didFinishLaunchingWithOptions
2022-04-28 23:09:25.237 E-levy Calculator[39628:30325283] Test device id: xxxx-xx-xx-xx-xxxxxxxxx
2022-04-28 23:09:25.243 E-levy Calculator[39628:30325283] Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
2022-04-28 23:09:25.315 E-levy Calculator[39628:30325283] <Google> To get test ads on this device, set: GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = @[ kGADSimulatorID ];
2022-04-28 23:09:26.235 E-levy Calculator[39628:30325283] Consent state: 0
2022-04-28 23:09:26.236 E-levy Calculator[39628:30325283] true
2022-04-28 23:09:26.245 E-levy Calculator[39628:30325283] *** Terminating app due to uncaught exception 'Invalid object type', reason: 'Expected: UIViewController, object type: B4IPanelView'
*** First throw call stack:
    0   CoreFoundation                      0x00000001129871e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x00000001118be031 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001129fc975 +[NSException raise:format:] + 197
    3   E-levy Calculator                   0x000000010b5f9a4b -[B4IObjectWrapper setObject:] + 235
    4   E-levy Calculator                   0x000000010b5f9c25 +[B4IObjectWrapper createWrapper:object:] + 101
    5   E-levy Calculator                   0x000000010b5c5b14 -[ResumableSub_b4xmainpage_ConsentStateAvailable resume::] + 628
    6   E-levy Calculator                   0x000000010b5c7d11 -[b4i_b4xmainpage _consentstateavailable] + 113
    7   E-levy Calculator                   0x000000010b5c6b6a -[ResumableSub_b4xmainpage_showAd resume::] + 2186
    8   E-levy Calculator                   0x000000010b5fecd2 -[B4I checkAndRunWaitForEvent:event:params:] + 482
    9   E-levy Calculator                   0x000000010b5fe9ba -[B4I raiseEvent:event:params:] + 330
    10  E-levy Calculator                   0x000000010b5fe853 __33-[B4I raiseUIEvent:event:params:]_block_invoke + 51
    11  libdispatch.dylib                   0x00000001147a86cb _dispatch_call_block_and_release + 12
    12  libdispatch.dylib                   0x00000001147a9709 _dispatch_client_callout + 8
    13  libdispatch.dylib                   0x00000001147b3708 _dispatch_main_queue_callback_4CF + 1279
    14  CoreFoundation                      0x0000000112949c99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    15  CoreFoundation                      0x000000011290dea6 __CFRunLoopRun + 2342
    16  CoreFoundation                      0x000000011290d30b CFRunLoopRunSpecific + 635
    17  GraphicsServices                    0x0000000116eeea73 GSEventRunModal + 62
    18  UIKit                               0x000000010dfc0057 UIApplicationMain + 159
    19  E-levy Calculator                   0x000000010b593ac8 main + 104
    20  libdyld.dylib                       0x000000011481e955 start + 1
    21  ???                                 0x0000000000000001 0x0 + 1
libc++abi.dylib: terminating with uncaught exception of type NSException

EDIT: When I remove the iAdmob, the app runs in the okay. my Admob version is 1.71
Last edited:
  consent.ShowConsentForm(Root, ...
The first parameter should be a native Page object = B4XPages.GetNativeParent(Me)


Well-Known Member
Licensed User
Sub showAd
    'consent.SetDebugGeography(True) 'comment for regular operation
'    consent.RequestInfoUpdate(Array("pub-133333329340"))    'TEst
    Wait For consent_InfoUpdated (Success As Boolean)
    If Success = False Then
        Log($"Error getting consent state: ${LastException}"$)
    End If
    Log($"Consent state: ${consent.ConsentState}"$) '0 - UNKNOWN, 1 - NON_PERSONALIZED, 2 - PERSONALIZED
End Sub
Sub ConsentStateAvailable
    If consent.ConsentState = consent.STATE_UNKNOWN And consent.IsRequestLocationInEeaOrUnknown Then
        consent.ShowConsentForm(Root, "", True, True, True)
        Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
        If Success Then
            Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
            Log($"Error: ${LastException}"$)
        End If
    End If
End Sub

Sub LoadAd
    Dim builder As AdRequestBuilder
    If consent.IsRequestLocationInEeaOrUnknown And consent.ConsentState <> consent.STATE_PERSONALIZED Then
    End If
'    builder.AddTestDevice("bb5420c11bebc5700781d810ca2bc2d0") 'this is a different id than the above. Check the logs for the correct id.
End Sub
Upvote 0