简体   繁体   English

Phonegap,Cordova - 插件问题

[英]Phonegap, Cordova - Issue with Plugins

I have installed Phonegap (3.0.3) and the Cordova CLI. 我已经安装了Phonegap(3.0.3)和Cordova CLI。

I am also running iOS as a platform (confirmed using $ cordova platforms ls ) 我也在运行iOS作为平台(使用$ cordova platforms ls确认)

I have installed the plugins ( $ cordova plugins ls ) 我已经安装了插件( $ cordova plugins ls

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

However, when I run this console command ( $ cordova emulate ios ), I get the following error. 但是,当我运行此控制台命令( $ 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)

I have followed the directions from the API page here ( http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification ) and below is my config.xml file in the MyApp > www > config.xml file which causes the error. 我已按照API页面中的说明进行操作( http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification ),以下是我在MyApp > www > config.xml中的config.xml文件导致错误的MyApp > www > 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>

Any suggestions what the issue might be, and how I can go about fixing it? 任何建议可能是什么问题,以及如何解决它?

Add AudioToolbox framework in your Xcode project: 在Xcode项目中添加AudioToolbox框架:

Your Target > Build Phases > Link Binary With Libraries 您的目标>构建阶段>链接二进制库

Click the '+' button 单击“+”按钮

Choose AudioToolbox.framework 选择AudioToolbox.framework

Did you run cordova build ios ? 你有没有运行过cordova build ios

then cordova emulate ios 然后cordova emulate ios

This error happen when you don't add the source to the Compile sources in build phase. 如果在构建阶段未将源添加到编译源,则会发生此错误。 Try to add plugins with : 尝试添加插件:

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

Take a look at CDVNotification.h - the #import lines tell you everything you need to add to your compile sources build phase. 看一下CDVNotification.h - #import行告诉你需要添加到编译源构建阶段的所有内容。

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

Add those 3, and it will compile. 添加这3个,它将编译。

UPDATE - an additional change is necessary in CDVNotification.m 更新 - CDVNotification.m中需要进行其他更改

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

In order for playBeep to be error free, soundCompletionCallback must be declared. 为了使playBeep无错误,必须声明soundCompletionCallback。 The simple solution is to declare it before playBeep, then define it after. 简单的解决方案是在playBeep之前声明它,然后在之后定义它。

Add this line just before static void playBeep(int count) 在静态void playBeep(int count)之前添加此行

// declared but not defined to avoid undeclared error in playBeep
static void soundCompletionCallback(SystemSoundID  ssid, void* data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM