Recently, I encountered an issue while building my Ionic 3 app using ionic cordova build ios --prod
.
Everything was functioning perfectly until a package update caused some complications, preventing me from successfully building the app.
I suspect that the error is stemming from an InjectionToken within my app.config.ts file, which I implemented based on the guidelines outlined in Angular 4 documentation.
Here's a snippet from app.config.ts:
import { InjectionToken } from '@angular/core';
export interface OneSignalConfig {
apiKey: string
};
// PROD Config
export const ONESIGNAL_CONFIG: OneSignalConfig = {
apiKey: '**apiKey**'
};
export const firebaseConfig = {
...
};
export const mixpanelToken = "**mytoken**";
// COMMON
export let ONESIGNAL_CONFIG_TOKEN = new InjectionToken<OneSignalConfig>('onesignal.config');
In my app.module.ts file, I utilized these configurations:
// Config imports
import { firebaseConfig, ONESIGNAL_CONFIG, ONESIGNAL_CONFIG_TOKEN } from './app-config.ts';
...
// the providers part
providers: [
...
OneSignal,
{ provide: ONESIGNAL_CONFIG_TOKEN, useValue: ONESIGNAL_CONFIG },
...
]
However, attempting to build the app resulted in the following issue:
[16:10:19] ngc started ...
[16:10:27] typescript error
Error encountered resolving symbol values statically. Could not resolve ./app-config.ts relative to
/Users/me/myproj/src/app/app.module.ts., resolving symbol
AppModule in /Users/me/myproj/src/app/app.module.ts,
resolving symbol AppModule in
/Users/me/myproj/src/app/app.module.ts, resolving symbol
AppModule in /Users/me/myproj/src/app/app.module.ts
Error: The Angular AoT build failed. See the issues above
at /Users/me/myproj/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
at step (/Users/me/myproj/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/Users/me/myproj/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at fulfilled (/Users/me/myproj/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
[16:10:27] copy finished in 7.84 s
Strangely enough, the app functions as expected when using serve
, run
, and emulate
. This inconsistency is quite perplexing to me.