iOS building error

I have a problem with iOS building:

> $appName@ ionic:build /Volumes/Data/projects/ionic2/$appName
> ionic-app-scripts build "--prod"

[20:42:43]  ionic-app-scripts 1.0.0 
[20:42:43]  build prod started ... 
[20:42:43]  clean started ... 
[20:42:43]  clean finished in less than 1 ms 
[20:42:43]  copy started ... 
[20:42:43]  ngc started ... 
[20:42:44]  ionic-app-script task: "build" 
[20:42:44]  TypeError: compiler_cli_1.ReflectorHost is not a constructor 
TypeError: compiler_cli_1.ReflectorHost is not a constructor
    at new AotCompiler (/Volumes/Data/projects/ionic2/$appName/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:31:30)
    at ngcWorker (/Volumes/Data/projects/ionic2/$appName/node_modules/@ionic/app-scripts/dist/ngc.js:19:20)
    at Object.ngc (/Volumes/Data/projects/ionic2/$appName/node_modules/@ionic/app-scripts/dist/ngc.js:9:12)
    at buildProject (/Volumes/Data/projects/ionic2/$appName/node_modules/@ionic/app-scripts/dist/build.js:95:51)
    at /Volumes/Data/projects/ionic2/$appName/node_modules/@ionic/app-scripts/dist/build.js:43:16

npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ionic:build" "--" "--prod"
npm ERR! node v7.7.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! $appName@ ionic:build: `ionic-app-scripts build "--prod"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the $appName@ ionic:build script 'ionic-app-scripts build "--prod"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the $appName package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build "--prod"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs $appName
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls $appName
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Volumes/Data/projects/ionic2/$appName/npm-debug.log

If I execute ā€œionic-app-scripts buildā€ without ā€œā€“prodā€ā€¦ it works. Why?

Thanks in advance

This looks exactly like a known issue with a previous version of ngc/angular-cli. Please post your ionic info, and your package.json.

1 Like

IONIC INFO:

Your system information:

Cordova CLI: 7.0.0 
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v7.7.0
Xcode version: Xcode 8.3.2 Build version 8E2002

package.json

{
    "name": "xxxxx",
    "author": "xxxxx",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "2.4.8",
        "@angular/compiler": "2.4.8",
        "@angular/compiler-cli": "2.4.8",
        "@angular/core": "2.4.8",
        "@angular/forms": "2.4.8",
        "@angular/http": "2.4.8",
        "@angular/platform-browser": "2.4.8",
        "@angular/platform-browser-dynamic": "2.4.8",
        "@angular/platform-server": "2.4.8",
        "@ionic/storage": "2.0.1",
        "com-sarriaroman-photoviewer": "^1.1.10",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-whitelist": "^1.3.2",
        "cordova-sqlite-storage": "~2.0.3",
        "ionic-angular": "2.2.0",
        "ionic-img-viewer": "^1.3.4",
        "ionic-native": "2.4.1",
        "ionicons": "3.0.0",
        "rxjs": "5.0.1",
        "sw-toolbox": "3.4.0",
        "zone.js": "0.7.2"
    },
    "devDependencies": {
        "@ionic/app-scripts": "1.0.0",
        "typescript": "2.0.9"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
    ],
    "cordovaPlatforms": [],
    "description": "L'applicazione ufficiale del Flannery PUB di Via Caravaglios di Napoli",
    "cordova": {
        "plugins": {
            "com-sarriaroman-photoviewer": {},
            "cordova-sqlite-storage": {},
            "cordova-plugin-whitelist": {},
            "cordova-plugin-splashscreen": {}
        },
        "platforms": [
            "android"
        ]
    }
}

The problem is probably that your app-scripts is old, and itā€™s running an old version of ngc when you give it the --prod flag. Iā€™m not 100% sure, but I would suggest that you update to the most recent ionic-app-scripts, and try again.

1 Like

I update to ā€œ@ionic/app-scriptsā€: ā€œ1.3.7ā€ and it works.

Only one error:
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

Thank you very much for your support

I have a next problem. I open the project into xCode and I have this error after build:

ā€¦/Classes/AppDelegate.h:28:9: ā€˜Cordova/CDVViewController.hā€™ file not found

I already add
"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"
at my Build Settings -> Header Search Paths:

Remove and re-add your platforms - this sounds a bit like relicts from earlier builds.

Removed and re-add but the problem is the same:

ā€¦/Classes/AppDelegate.h:28:9: ā€˜Cordova/CDVViewController.hā€™ file not found

Your system information:

Cordova CLI: 7.0.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.7
ios-deploy version: Not installed
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v7.7.0
Xcode version: Xcode 8.3.2 Build version 8E2002

solvedā€¦

ionic resources
ionic platform remove ios
ionic platform add ios

1 Like

Which does exactly the same thing as remving and readding the platform as you did beforeā€¦

Well, Iā€™m happy that it works.

1 Like