16

我已经安装了 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#NotificationMyApp > 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>

有什么建议可能是什么问题,我该如何解决?

4

3 回答 3

14

在 Xcode 项目中添加 AudioToolbox 框架:

您的目标 > 构建阶段 > 将二进制文件与库链接

点击“+”按钮

选择 AudioToolbox.framework

于 2013-08-28T15:16:42.153 回答
0

Take a look at CDVNotification.h - the #import lines tell you everything you need to add to your compile sources build phase.

Foundation/Foundation.h UIKit/UIKit.h AudioToolbox/AudioServices.h

Add those 3, and it will compile.

UPDATE - an additional change is necessary in CDVNotification.m

playBeep() calls soundCompletionCallback() soundCompletionCallback calls playBeep()

In order for playBeep to be error free, soundCompletionCallback must be declared. The simple solution is to declare it before playBeep, then define it after.

Add this line just before static void playBeep(int count)

// declared but not defined to avoid undeclared error in playBeep
static void soundCompletionCallback(SystemSoundID  ssid, void* data);
于 2013-12-20T06:11:35.637 回答
0

你跑了cordova build ios吗?

然后cordova emulate ios

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

TargetSettings -> Build Phases -> Compile Sources -> 添加你的 .m 类

于 2013-08-26T12:55:11.403 回答