EddyVerbruggen / nativescript-app-icon-changer

Change the homescreen icon of your NativeScript iOS app at runtime!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NS8 related errors

brianrclow opened this issue · comments

After upgrading my project to NS8, I am receiving these errors 1 at build time and 1 at runtime:

***** Fatal JavaScript exception - application has been terminated. ***** NativeScript encountered a fatal error: Uncaught Error: Cannot find module 'application' at webpackMissingModule(file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:3:26 at ../../node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js(file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:3:26 at __webpack_require__(file: src/webpack:/{workspace-name}/webpack/bootstrap:24:0 at fn(file: src/webpack:/{workspace-name}/webpack/runtime/hot module replacement:61:0 at ../../libs/xplat/nativescript/features/src/lib/profile/settings/user/user-settings/user-settings.component.ts(file:///app/bundle.js:37646:87) at __webpack_require__(file: src/webpack:/{workspace-name}/webpack/bootstrap:24:0 at fn(file: src/webpack:/{workspace-name}/webpack/runtime/hot module replacement:61:0 at ../../libs/xplat/nativescript/features/src/lib/profile/user-profile-routing.module.ts(file:///app/bundle.js:37727:110) at __webpack_require__(file: src/webpack:/{workspace-name}/webpack/bootstrap:24:0 at fn(file: src/webpack:/{workspace-name}/webpack/runtime/hot module replacement:61:0 at ../../libs/xplat/nativescript/features/src/lib/profile/user-profile.module.ts(file:///app/bundle.js:38088:86) at __webpack_require__(file: src/webpack:/{workspace-name}/webpack/bootstrap:24:0 at fn(file: src/webpack:/{workspace-name}/webpack/runtime/hot module replacement:61:0 at <…>

and also

CONSOLE ERROR: ERROR Error: Uncaught (in promise): Object: {"code":-1,"message":{}} CONSOLE ERROR: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nativeApp' of undefined TypeError: Cannot read property 'nativeApp' of undefined at AppIconChanger._supportsAlternateIcons (file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:9:0 at file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:18:0 at new ZoneAwarePromise (file: src/webpack:/{workspace-name}/node_modules/zone.js/fesm2015/zone.js:1387:0 at AppIconChanger.isSupported (file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:17:0 at file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:28:0 at new ZoneAwarePromise (file: src/webpack:/{workspace-name}/node_modules/zone.js/fesm2015/zone.js:1387:0 at AppIconChanger.changeIcon (file: src/webpack:/{workspace-name}/node_modules/nativescript-app-icon-changer/app-icon-changer.ios.js:26:0 at ProfileIconPickerComponent.changeAppIcon (file: src/webpack:/{workspace-name}/libs/xplat/nativescript/features/src/lib/profile/settings/components/profile-icon-picker/profile-icon-picker.component.ts:17:24 at ProfileIconPickerComponent_Template_Image_tap_3_listener (file: src/webpack:/{workspace-name}/libs/xplat/nativescript/features/src/lib/profile/settings/components/profile-icon-picker/profile-icon-picker.component.html:24:11 at executeListenerWithErrorHandling (file: src/webpack:/{workspace-name}/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:15285:0

To fix the first error which happens at build time, I updated lines 3 and 4 in app-icon-changer.ios.js in my node_modules and the project built just fine.

var application = require("@nativescript/core");
var frame_1 = require("@nativescript/core");

I was unable to fix the second error, which happens at runtime when I select an icon to change to.

I'm new (~5 months) to nativescript and am wondering if this would be the only fix that a PR might need or would there be more to bring this amazing plugin up to NS8 standards. I am using Nx workspaces with xplat on NS8 with angular. Please let me know what I can do to help get this plugin to build and run with NS8. Thank you Eddy!

Closing due to inactivity. We have decided to not use this plugin at this time.

Do you mind to write your alternate solution if you found one?
Generally it should be allowed following this article:
https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname
and there is something similar for android (hack).
I could not find any other plugin, and before going the long way by adding native code to our project, I am interested in any other possibilities.

For anyone who is interested, I found a solution which is the following.
It is not necessary to use this plugin any more, as Nativescript offers the possibility to access Objective-C types with Javascript. https://v7.docs.nativescript.org/core-concepts/ios-runtime/overview
So my code solution that worked for me is as followed:
image

I struggled a lot with the Info.plist so here is what worked for iPhones and iPads (at least in my case):
image
Do the same for <key>CFBundleIcons~ipad</key>

But most important was, to put the icons into the project folder:
image

I hope this helps. Sorry for the images, I was not able to post it in a code block in a nice way.

Nice! I plan to implement the app icons in our iOS app at some point but it is not high priority at the moment. Thanks for documenting some more on getting it running with NS8. I'm sure this will be useful to others in the future.