【问题标题】:Phonegap plugin for version 2.02.0 版的Phonegap 插件
【发布时间】:2012-09-12 09:55:24
【问题描述】:

好吧,我对电话间隙很陌生。一天前,我用 Xcode 4.2 版将它安装在 MAC OSX 10.7.1 上。

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

NativeControls.h

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

那么谁能指出我做错了什么?是否需要重新添加 CDVPlugin.h 及相关文件?

【问题讨论】:

    标签: iphone cordova xcode4.2 phonegap-plugins


    【解决方案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

    希望这会有所帮助。

    【讨论】:

    • 我重新编辑了我之前的帖子。试试上面的解决方案,让我知道这是否可行:S...
    • 你好,伙计! :) 它现在可以正常工作了 :) 我正在关注这个docs.phonegap.com/en/2.0.0/…。更改 .h 后它起作用了 :) 谢谢 :)
    【解决方案2】:

    在 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>
    

    【讨论】:

    • 我确信这只是一个 hack,因为我的项目中的其他内容未配置 - 它的构建和工作。这次就好了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多