4

I am developing a mobile app using Ionic Framework and Cordova, I tried to add in the Cordova media plugin and it would not build for me.

I even tried to create a fresh starter tabs project, and then add the media plugin as shown. The project does not compile due to adding the media plugin.

npm install -g cordova ionic gulp
ionic start ionicTest tabs
ionic platform add ios
cordova plugin add org.apache.cordova.media
ionic build ios

then I remove the media plugin and no problems the project compiles perfectly

cordova plugin rm org.apache.cordova.media
ionic build ios

Here is the error message I am getting, I am using Cordova version 4.1.2

The following build commands failed:
    CompileC build/ionicTest.build/Debug-iphonesimulator/ionicTest.build/Objects-normal/i386/CDVFile.o ionicTest/Plugins/org.apache.cordova.file/CDVFile.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC build/ionicTest.build/Debug-iphonesimulator/ionicTest.build/Objects-normal/i386/CDVLocalFilesystem.o ionicTest/Plugins/org.apache.cordova.file/CDVLocalFilesystem.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC build/ionicTest.build/Debug-iphonesimulator/ionicTest.build/Objects-normal/i386/CDVSound.o ionicTest/Plugins/org.apache.cordova.media/CDVSound.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC build/ionicTest.build/Debug-iphonesimulator/ionicTest.build/Objects-normal/i386/CDVAssetLibraryFilesystem.o ionicTest/Plugins/org.apache.cordova.file/CDVAssetLibraryFilesystem.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(4 failures)
Error: /Users/steven/web/ionicTest/platforms/ios/cordova/build: Command failed with exit code 65
svnm
  • 22,878
  • 21
  • 90
  • 105

1 Answers1

17

When you add a plugin, you have to remove and add the platform to make it compile (it's a bug). Try the following:

  1. cordova plugin add org.apache.cordova.media
  2. ionic platform remove ios
  3. ionic platform add ios

Also make sure you're standing in the app directory (ionicTest) when you issue the commands. Check that you have the two folders platforms and plugins in your app folder (on the same level as www). If not, create them before installing the plugin. If they are missing, plugin installation will fail, possibly without error message.

Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
  • Thanks, awesome answer... it works now. Annoying you need to remove then add the platform, I was confused that platform meant ios or Android :) but just those 2 commands is easy, I was thinking platform meant Ionic or Cordova... of course that is the framework, easy to fix. – svnm Nov 24 '14 at 11:01
  • Just a note, when this wasn't working for me, I realised that you could just use html5 audio for the same effect, and it worked as well... document.getElementById('audio').play(); – svnm Nov 24 '14 at 11:02
  • Good answer. Maybe they don't have an elegant way to partially update project while adding a plugin yet, but at least put "platform remove/add" into `inoic plugin in` :) – superarts.org Feb 25 '15 at 01:40