ios Cordova 中的“'CDVPlugin.h' 文件未找到”作为组件(Cleaver)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10714600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"'CDVPlugin.h' file not found" in Cordova as component (Cleaver)
提问by Michael Schmidt
I added Cordova as a component to my iOS project. Adding a custom plugin leads to the error, despite that the plugin works in a Cordova-only project:
我将 Cordova 作为组件添加到我的 iOS 项目中。添加自定义插件会导致错误,尽管该插件适用于仅限 Cordova 的项目:
'CDVPlugin.h' file not found
- PhoneGap / Cordova 1.7.0 installed
- Checked multiple times to correctly implement the steps https://github.com/apache/incubator-cordova-ios/blob/master/guides/How%20to%20Use%20Cordova%20as%20a%20Component.md("Adding Cleaver to your Xcode project (CordovaLib sub-project)")
- The Plugin works in a plain cordova-based application (Cordova Xcode template)
- Adding "-all_load" to the 'other linker flags' in the main project does have no effect
- 已安装 PhoneGap / Cordova 1.7.0
- 多次检查以正确执行步骤https://github.com/apache/incubator-cordova-ios/blob/master/guides/How%20to%20Use%20Cordova%20as%20a%20Component.md(“将 Cleaver 添加到您的 Xcode 项目(CordovaLib 子项目)”)
- 该插件在一个普通的基于cordova 的应用程序中工作(Cordova Xcode 模板)
- 将“-all_load”添加到主项目中的“其他链接器标志”没有任何效果
The problematic part is as follows:
有问题的部分如下:
#import <Foundation/Foundation.h>
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif
What am I missing?
我错过了什么?
回答by Marek Jalovec
For xcode7 add "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"
to your Header Search Paths(and you may need to set Enable Bitcodeto No- was necessary for me, but may be related to different problem with xc7)
对于 xcode7,添加"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"
到您的Header Search Paths(您可能需要将Enable Bitcode设置为No- 对我来说是必要的,但可能与 xc7 的不同问题有关)
回答by user513790
Click on the project icon in the Project Navigator,
单击项目导航器中的项目图标,
select your Project, then select the "Build Settings" tab
选择您的项目,然后选择“构建设置”选项卡
Enter "Header Search Paths" in the search field
在搜索字段中输入“标题搜索路径”
Add "$(CORDOVALIB)/Classes"
and check the Recursive checkbox - for the Header Search Pathsvalue
添加"$(CORDOVALIB)/Classes"
并选中 Recursive 复选框 - 对于Header Search Paths值
optional
Add "-all_load"
and "-Obj-C"
- for the Other Linker Flagsvalue
可选的 Add"-all_load"
和"-Obj-C"
- 用于其他链接器标志值
回答by vishnu
Change your header file to:
将头文件更改为:
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVPlugin.h>
it is working in my application.
它在我的应用程序中工作。
回答by Helzgate
I had this issue using Cordova. Come to find out my CordovaLib folder under the ios platform directory vanished.
我在使用 Cordova 时遇到了这个问题。快来发现我在ios平台目录下的CordovaLib文件夹消失了。
I did:
我做了:
cordova platform remove ios
then
然后
cordova platform add ios
...and this fixed the issue.
...这解决了这个问题。
回答by pjuzeliunas
I have spent awful lot of time trying to fix the same issue in my project, so let me share my findings. It might be relevant for those who are able to build the project in one configuration, but in another configuration (e.g. when building unit tests) precompiler fails to find CDVPlugin.h
.
我花了很多时间试图解决我的项目中的相同问题,所以让我分享我的发现。对于能够在一种配置中构建项目但在另一种配置中(例如构建单元测试时)预编译器无法找到CDVPlugin.h
.
You have to make sure that CordovaLib
sub-project has the same set of configurations as your main project.
您必须确保CordovaLib
子项目与主项目具有相同的配置集。
- Select the main project in Xcode in project navigator.
- Click on the project icon (above the Targets).
- Select
Info
tab. - Expand
Configurations
.
- 在项目导航器中选择 Xcode 中的主项目。
- 单击项目图标(目标上方)。
- 选择
Info
选项卡。 - 展开
Configurations
。
So, this is a set of your app configurations. In my example it looked like this:
所以,这是一组您的应用程序配置。在我的示例中,它看起来像这样:
You need to have the same set of configurations in your CordovaLib
sub-project.
您需要在CordovaLib
子项目中具有相同的配置集。
- Select
CordovaLib
sub-project. - Click on the project icon (above the Targets).
- Select
Info
tab. - Expand
Configurations
. - Make sure you have the same set of configurations as in the main project. If some configurations are missing:
- Click
+
button. - Select
Duplicate "Release" Configuration
- Give the right name for configuration. Copy-paste it from main project settings.
- Click
- 选择
CordovaLib
子项目。 - 单击项目图标(目标上方)。
- 选择
Info
选项卡。 - 展开
Configurations
。 - 确保您具有与主项目中相同的配置集。如果缺少某些配置:
- 单击
+
按钮。 - 选择
Duplicate "Release" Configuration
- 为配置提供正确的名称。从主项目设置复制粘贴它。
- 单击
Now perform a clean build.
现在执行一个干净的构建。
回答by Paulo
Note: Phonegap 2.9.1 (Nov 2013))
注意:Phonegap 2.9.1(2013 年 11 月))
I encountered the same problem while trying to make an open source "C" phone gap plugin work. The solution was to add the Cordovalib.xcodeproj to the target project, once done, click on your_project.xcodeproj - you will need to look in the Target Settings, under the Build Phases Tab, make sure that Cordovalib is added in Target Dependencies.
我在尝试制作开源“C”电话间隙插件时遇到了同样的问题。解决方案是将 Cordovalib.xcodeproj 添加到目标项目,完成后,单击 your_project.xcodeproj - 您需要查看目标设置,在构建阶段选项卡下,确保将 Cordovalib 添加到目标依赖项中。
Once done it should allow the statement: #import to work.
完成后,它应该允许语句:#import 起作用。
回答by bill
replace
代替
import
进口
with (
和 (
import "Classes/CDVPlugin.h"
导入“类/CDVPlugin.h”
OR
或者
import "CordovaLib/Classes/CDVPlugin.h")
导入“CordovaLib/Classes/CDVPlugin.h”)
回答by RohitAneja
In xcode 8 and 8 + simply commenting the line worked for me:
在 xcode 8 和 8 + 中,只需注释对我有用的行:
#import ...
This is specifically useful if you are trying to extend IOS app build using ionic or cordova to have watchkit or widget control natively.
如果您尝试使用 ionic 或 cordova 扩展 IOS 应用程序构建以在本地拥有 watchkit 或小部件控件,这将特别有用。
回答by A_B
Have a look at my answer here:
在这里看看我的回答:
I had the same problem while installing the ShareKit plugin on Xcode 4.5, cordova 2.1.0 & JQM 1.2.0. The problematic block was:
我在 Xcode 4.5、cordova 2.1.0 和 JQM 1.2.0 上安装 ShareKit 插件时遇到了同样的问题。有问题的块是:
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVPluginResult.h>
//#import <Cordova/JSONKit.h>
#else
#import "CDVPlugin.h"
#import "CDVPluginResult.h"
#import "JSONKit.h"
#endif
What worked for me is commenting out the #ifdef line as well as commenting out the whole #else block.
对我有用的是注释掉 #ifdef 行以及注释掉整个 #else 块。
Also, the #import line was already commented out in the source code that I downloaded with the plugin, so I didn't bother messing with that.
此外,#import 行已经在我用插件下载的源代码中注释掉了,所以我没有打扰它。
Might be of some help to you.
可能对你有些帮助。