Phonegap,Cordova - 插件问题

时间:2013-07-30 09:12:46

标签: javascript ios plugins cordova

我已经安装了Phonegap(3.0.3)和Cordova CLI。

我也在运行iOS作为平台(使用$ cordova platforms ls确认)

我安装了插件($ cordova plugins ls

org.apache.cordova.core.dialogs
org.apache.cordova.core.vibration

但是,当我运行此控制台命令($ cordova emulate ios)时,我收到以下错误。

Undefined symbols for architecture i386:
  "_AudioServicesAddSystemSoundCompletion", referenced from:
      _playBeep in CDVNotification.o
  "_AudioServicesCreateSystemSoundID", referenced from:
      _playBeep in CDVNotification.o
  "_AudioServicesDisposeSystemSoundID", referenced from:
      _soundCompletionCallback in CDVNotification.o
  "_AudioServicesPlaySystemSound", referenced from:
      _playBeep in CDVNotification.o
      -[CDVVibration vibrate:] in CDVVibration.o
  "_AudioServicesRemoveSystemSoundCompletion", referenced from:
      _soundCompletionCallback in CDVNotification.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)


** BUILD FAILED **


The following build commands failed:
    Ld build/MyApp.app/MyApp normal i386
(1 failure)

我已按照此处的API页面(http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification)中的说明进行操作,以下是我在MyApp > www > config.xml文件中的config.xml文件,该文件会导致错误。

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>MyApp</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@callback.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <plugin name="Notification" value="CDVNotification" />
    <access origin="*" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />   
</widget>

任何建议可能是什么问题,以及我如何解决它?

3 个答案:

答案 0 :(得分:14)

在Xcode项目中添加AudioToolbox框架:

你的目标&gt;构建阶段&gt;链接二进制文件库

点击“+”按钮

选择AudioToolbox.framework

答案 1 :(得分:0)

您运行了cordova build ios吗?

然后cordova emulate ios

如果在构建阶段未将源添加到编译源,则会发生此错误。 尝试添加插件:

TargetSettings - &gt;构建阶段 - &gt;编译源 - &gt;添加你的.m类

答案 2 :(得分:0)

看看CDVNotification.h - #import行告诉你需要添加到编译源构建阶段的所有内容。

基金会/ Foundation.h UIKit中/ UIKit.h AudioToolbox / AudioServices.h

添加3,它将编译。

更新 - CDVNotification.m中需要进行其他更改

playBeep()调用soundCompletionCallback() soundCompletionCallback调用playBeep()

为了使playBeep无错误,必须声明soundCompletionCallback。简单的解决方案是在playBeep之前声明它,然后在之后定义它。

在静态void playBeep(int count)

之前添加此行
// declared but not defined to avoid undeclared error in playBeep
static void soundCompletionCallback(SystemSoundID  ssid, void* data);