适用于2.0版的Phonegap插件

时间:2012-09-12 09:55:24

标签: iphone cordova xcode4.2 phonegap-plugins

嗯,我对手机差距很新。一天前,我将它安装在MAC OSX 10.7.1上,Xcode版本为4.2。

  • 首先,我在Xcode中看不到创建手机间隙应用程序的选项。但是我可以使用终端来实现它。 (后来才知道,这就是它在这个版本上的工作原理,可能)。
  • 其次,我关注this tutorial并尝试添加plugins。当我编译时,它给了我致命的错误。 'CDVPlugin.h' file not found。但我可以在 Cordovalib.xcodeproj
  • 中看到它

NativeControls.h

#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif

所以任何人都可以指出我做错了什么?我是否需要再次添加CDVPlugin.h和相关文件?

2 个答案:

答案 0 :(得分:1)

修改文件NativeControls.hNativeControls.m

后,编辑工作正常

修改后的NativeControls.h

//
// NativeControls.h
//
//
// Created by Jesse MacFadyen on 10-02-03.
// MIT Licensed

// Originally this code was developed my Michael Nachbaur
// Formerly -> PhoneGap :: UIControls.h
// Created by Michael Nachbaur on 13/04/09.
// Copyright 2009 Decaf Ninja Software. All rights reserved.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UITabBar.h>
#import <UIKit/UIToolbar.h>

//#ifdef PHONEGAP_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif

@interface NativeControls : CDVPlugin <UITabBarDelegate, UIActionSheetDelegate> {
    UITabBar* tabBar;
    NSMutableDictionary* tabBarItems;

    UIToolbar* toolBar;
    UIBarButtonItem* toolBarTitle;
    NSMutableArray* toolBarItems;

    CGRect  originalWebViewBounds;
}

/* Tab Bar methods
 */
- (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBarItems:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)updateTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)selectTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;



/* Tool Bar methods
 */
- (void)createToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)resetToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createToolBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
/* ActionSheet
 */
- (void)createActionSheet:(NSArray*)arguments withDict:(NSDictionary*)options;


@end

文件NativeControls.m中的修改:在第22行中,将PGPlugin更改为CDVPlugin

希望这会有所帮助。

答案 1 :(得分:1)

在Cordova 2.1(仅限) 我通过简单地为给定的PushNotification插件注释if / else来解决这个错误

#import <Foundation/Foundation.h>
//#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
#import <EventKitUI/EventKitUI.h>
#import <EventKit/EventKit.h>