apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 990 forks source link

Build Fail after adding Notification Service Extension in Xcode #664

Open 2xSamurai opened 5 years ago

2xSamurai commented 5 years ago

Bug Report

After adding Notification Service Extension in Xcode, cordova build command from cli fails.

Problem

What is expected to happen?

Build without any issues.

What does actually happen?

App is only getting built successfully after removing 'Notification Service Extension' inside Xcode.

Information

The verbose console log of error.

`MacBook-Pro:AppName username$ ionic cordova run ios --verbose ionic:lib Terminal info: { tty: true, ci: false, windows: false } +0ms ionic:lib CLI global options: { _: [ 'cordova', 'run', 'ios' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +4ms ionic:lib:project Project type from config: Ionic 1 (ionic1) +0ms ionic:lib:project Project details: { configPath: '/Users/username/Work/Projects/AppName/Code/AppName/ionic.config.json', errors: [], context: 'app', type: 'ionic1' } +0ms ionic Context: { binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/usr/local/lib/node_modules/ionic', execPath: '/Users/username/Work/Projects/AppName/Code/AppName', version: '4.9.0' } +0ms ionic:lib:integrations:cordova:config Using config.xml: /Users/username/Work/Projects/AppName/Code/AppName/config.xml +0ms ionic:lib:telemetry Sending telemetry for command: 'ionic cordova run' [ 'ios', '--verbose', '--interactive', '--color' ] +0ms ionic:lib:hooks Looking for ionic:build:before npm script. +0ms ionic:lib:build Looking for ionic:build npm script. +0ms

ionic-v1 build ionic:v1-toolkit:lib:gulp Using gulpfile: /Users/username/Work/Projects/AppName/Code/AppName/gulpfile.js +0ms ionic:v1-toolkit:lib:gulp Using gulp: /Users/username/Work/Projects/AppName/Code/AppName/node_modules/gulp/index.js +3ms [12:02:49] Cannot load gulp: Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (57) For more information on which environments are supported please see: https://github.com/sass/node-sass/releases/tag/v3.13.1 [12:02:49] Cannot run sass task: missing in gulpfile.js ionic:lib:hooks Looking for ionic:build:after npm script. +2s cordova run ios --verbose No scripts found for hook "before_run". Executing script found in plugin cordova-custom-config for hook "before_prepare": plugins/cordova-custom-config/hooks/restoreBackups.js cordova-custom-config: Running restoreBackups.js cordova-custom-config: Loaded module dependencies cordova-custom-config: Skipping auto-restore of config file backup(s) Executing script found in plugin cordova-custom-config for hook "before_prepare": plugins/cordova-custom-config/hooks/applyCustomConfig.js cordova-custom-config: Running applyCustomConfig.js cordova-custom-config: Loaded module dependencies cordova-custom-config: Finished applying platform config Checking config.xml and package.json for saved platforms that haven't been added to the project Config.xml and package.json platforms are the same. No pkg.json modification. Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms. PlatformApi successfully found for platform ios Checking config.xml for saved plugins that haven't been added to the project Checking for any plugins added to the project that have not been installed in ios platform No differences found between plugins added to project and installed in ios platform. Continuing... Generating platform-specific config.xml from defaults for iOS at /Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/AppName/config.xml Merging project's config.xml into platform-specific iOS config.xml Merging and updating files from [www, platforms/ios/platform_www] to platforms/ios/www Current launch storyboard CDVLaunchScreen Not changing launch storyboard setting in info plist. Wrote out iOS Bundle Identifier "com.AppName.app" and iOS Bundle Version "1.9.0" to /Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/AppName/AppName-Info.plist No need to update build settings for launch storyboard support. iOS Product Name has not changed (still "AppName") Updating icons at platforms/ios/AppName/Images.xcassets/AppIcon.appiconset/ Updating splash screens at platforms/ios/AppName/Images.xcassets/LaunchImage.launchimage/ Updating launch storyboard images at platforms/ios/AppName/Images.xcassets/LaunchStoryboard.imageset/ Updating Storyboard image set contents.json Could not find *-Info.plist file, or config.xml file. Error at Object.parseProjectFile [as parse] (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/lib/projectFile.js:49:15) at updateFileResources (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/lib/prepare.js:480:33) at /Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/lib/prepare.js:65:13 at _fulfilled (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:854:54) at self.promiseDispatch.done (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:883:30) at Promise.promise.promiseDispatch (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:816:13) at /Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:570:49 at runSingle (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:137:13) at flush (/Users/username/Work/Projects/AppName/Code/AppName/platforms/ios/cordova/node_modules/q/q.js:125:13) at _combinedTickCallback (internal/process/next_tick.js:131:7) [ERROR] An error occurred while running subprocess cordova.

    cordova run ios --verbose exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms ionic:cli-framework:utils:process onBeforeExit handler: running 2 functions +0ms ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 1) +55ms`

Command or Code

ionic cordova build ios

Environment, Platform, Device

`MacBook-Pro:AppName username$ ionic info

Ionic:

ionic (Ionic CLI) : 4.9.0 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic1 1.3.5 @ionic/v1-toolkit : 1.0.8

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova Platforms : ios 4.5.5 Cordova Plugins : cordova-plugin-ionic-webview 1.2.1, (and 27 other plugins)

System:

Android SDK Tools : 26.1.1 (/Users/username/Library/Android/sdk) ios-deploy : 1.9.2 ios-sim : 5.0.13 NodeJS : v8.3.0 (/Users/username/.nvm/versions/node/v8.3.0/bin/node) npm : 5.3.0 OS : macOS Mojave Xcode : Xcode 10.2 Build version 10E125 `

Version information

Checklist

Any help would be much appreciated.

Note: I have been scouring the web for almost 3 days now. Without any success. When I delete the Notification Service Extension target from XCode. Building from the cli once again starts to work.

VM8198 commented 4 years ago

hey @2xSamurai are you able to solve this issue ? I am getting same issue right now

leogoesger commented 4 years ago

same here

leogoesger commented 4 years ago

In ios/cordova/lib/projectFile.js

  var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
  var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
    return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE;
  });

with

var projectName = fs
    .readdirSync(project_dir)
    .find(d => d.includes(".xcworkspace"))
    .replace(".xcworkspace", "");

 var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
 var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
    return (
      entry.buildSettings &&
      entry.buildSettings.INFOPLIST_FILE &&
      entry.buildSettings.INFOPLIST_FILE.includes(projectName)
    );
 });

Detail here for how we solved it. https://github.com/apache/cordova-ios/issues/764