App won't run under ios: unrecognized selector sent to instance

ios

#1

Hello All,
Please help me. I have some Angular experience, but new to mobile dev. I really like this developing once and deploy to everywhere idea, so I picked up angular+nativescript.

  So I followed the Groceries tutorial and was able to run it under android emulator directly (tns run android) or via Sidekick. And I can deploy to my iPhone via Sidekick and run it without issue too.

  Then I created an empty app using template **tns-template-tab-navigation-ng**, and still can run it in above 3 ways:
    1) Run it in android emulator directly: tns run android 
    2) Build it in sidekick and deploy to android emulator and run it. 
    3) Build it  in sidekick and deploy to my actual iPhone or iPad and run it successfully. 


 Now I have actually created a real app using the same template **tns-template-tab-navigation-ng** , but I can only do 1) and 2).  App runs in Android emulator exactly as I want. 
    But I have problem doing 3). I can still build in Sidekick, and install the app to iPhone/iPad. But when tap the app on the iphone/ipad, the app tries to start then crash, every single time. 
    Here is the error I got in device console:

Unzipping LiveSync folder. This could take a while…
Unzipped 165 entries in 1258.557916ms.
tns_modules folder not livesynced. Using tns_modules from the already deployed bundle…
Retrieving resting unlock: 0
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:3130:24: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
-[TNSArrayAdapter isEqualToString:]: unrecognized selector sent to instance 0x10c2421f0
*** JavaScript call stack:
(
0 initWithTitleImageTag@[native code]
1 @file:///app/tns_modules/tns-core-modules/ui/tab-view/tab-view.js:310:72
2 forEach@:1:11
3 setViewControllers@file:///app/tns_modules/tns-core-modules/ui/tab-view/tab-view.js:307:22
4 @file:///app/tns_modules/tns-core-modules/ui/tab-view/tab-view.js:375:32
5 applyAllNativeSetters@file:///app/tns_modules/tns-core-modules/ui/core/properties/properties.js:960:28
6 initNativeView@file:///app/tns_modules/tns-core-modules/ui/core/properties/properties.js:904:30
7 onResumeNativeUpdates@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:627:36
8 _resumeNativeUpdates@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:272:39
9 onLoaded@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:231:34
10 onLoaded@file:///app/tns_modules/tns-core-modules/ui/tab-view/tab-view.js:186:39
11 @file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:311:98
12 callFunctionWi<\M-b\M^@\M-&>
)
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[TNSArrayAdapter isEqualToString:]: unrecognized selector sent to instance 0x10c2421f0’
*** First throw call stack:
(0x182ceed8c 0x181ea85ec 0x182cfc098 0x182cf45c8 0x182bda41c 0x18c947dd4 0x18c947c34 0x101940044 0x10193b954 0x10193b420 0x1010411ac 0x101604f2c 0x10160da74 0x10160da84

So why is this error “unrecognized selector sent to instance”? I really don’t have any iOS specific code in the project. There are a few places like ios.position=“right” etc, and I have commented them out, still the same error.

Kinda stuck now. I don’t have access to macOS, so I cannot try to run it in macOS emulator. I have to run it in a real ios device through Sidekick.

Your help is really appreciated!

Martin


#2

Hello All,
I found the problem. The bracket [] around setting is the problem. Well, Android does not complain at all. I was testing property binding in this tabItem case. I need dynamic title, so I need two way binding here. still no avail, but removing [] makes iOS happy.

<page-router-outlet
*tabItem="{title: [setting], iconSource: getIconSource(‘setting’)}"
name=“settingTab”>

Thanks for looking.