2013-07-30 30 views
16

Tôi đã cài đặt Phonegap (3.0.3) và Cordova CLI.Phonegap, Cordova - Sự cố với Plugin

Tôi cũng chạy iOS như một nền tảng (xác nhận sử dụng $ cordova platforms ls)

Tôi đã cài đặt plugin ($ cordova plugins ls)

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

Tuy nhiên, khi tôi chạy giao diện điều khiển lệnh này ($ cordova emulate ios), tôi nhận được lỗi sau.

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) 

Tôi đã theo các hướng dẫn từ trang API đây (http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification) và dưới đây là tập tin config.xml của tôi trong tập tin MyApp > www > config.xml gây lỗi.

<?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="[email protected]" 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> 

Mọi đề xuất có thể là gì và cách tôi có thể khắc phục sự cố?

+0

Tôi có vấn đề chính xác cùng, bạn đã tìm thấy một cách để sửa lỗi này? –

Trả lời

0

Bạn có chạy cordova build ios không?

sau đó cordova emulate ios

Lỗi này xảy ra khi bạn không thêm nguồn đến nguồn Compile trong xây dựng giai đoạn. Cố gắng thêm plugin với:

TargetSettings -> Xây dựng giai đoạn -> Compile Nguồn -> thêm lớp .m bạn

14

Thêm khung AudioToolbox trong dự án Xcode của bạn:

mục tiêu của bạn> Xây dựng giai đoạn> Link binary với Libraries

Nhấp vào nút '+'

Chọn AudioToolbox.framework

+0

không hoạt động ... không quá nhiều – Michael

+2

Điều này đã làm được điều này. –

+0

Tôi đang sử dụng cordova-plugin-dialogs, tính năng này phù hợp với tôi :) – micmia

0

Hãy xem CDVNotification.h - #import lines cho bạn biết mọi thứ bạn cần thêm vào giai đoạn xây dựng nguồn biên dịch của bạn.

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

Thêm những 3, và nó sẽ biên dịch.

CẬP NHẬT - thay đổi bổ sung là cần thiết trong CDVNotification.m

playBeep() gọi soundCompletionCallback() soundCompletionCallback gọi playBeep()

Để playBeep là lỗi miễn phí, soundCompletionCallback phải được khai báo. Giải pháp đơn giản là khai báo nó trước playBeep, sau đó xác định nó sau.

Thêm dòng này ngay trước khi static void playBeep (count int)

// declared but not defined to avoid undeclared error in playBeep 
static void soundCompletionCallback(SystemSoundID ssid, void* data); 
Các vấn đề liên quan