Ionic Cordova IOS build fails after adding media p

2020-06-21 07:09发布

问题:

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

回答1:

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.