我有一个iOS objective-c组件,应该包含在PhoneGap / Cordova插件中。
以下是我在plugin.xml文件中的一部分:
<platform name="ios">
...
<resource-file src="src/ios/TGCameraViewController/View/Base.lproj/TGCameraAuthorizationViewController.xib" target-dir="TGCameraViewController/View/Base.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/Base.lproj/TGCameraViewController.xib" target-dir="TGCameraViewController/View/Base.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/Base.lproj/TGPhotoViewController.xib" target-dir="TGCameraViewController/View/Base.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/de.lproj/TGCameraAuthorizationViewController.strings" target-dir="TGCameraViewController/View/de.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/de.lproj/TGCameraViewController.strings" target-dir="TGCameraViewController/View/de.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/de.lproj/TGPhotoViewController.strings" target-dir="TGCameraViewController/View/de.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/pt-BR.lproj/TGCameraAuthorizationViewController.strings" target-dir="TGCameraViewController/View/pt-BR.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/pt-BR.lproj/TGCameraViewController.strings" target-dir="TGCameraViewController/View/pt-BR.lproj" />
<resource-file src="src/ios/TGCameraViewController/View/pt-BR.lproj/TGPhotoViewController.strings" target-dir="TGCameraViewController/View/pt-BR.lproj" />
</platform>
当我尝试将插件添加到我的应用程序时,我收到以下错误:
Failed to install 'org.test.cordova.TestPlugin':Error: Uh oh!
target destination "/Users/mg/Documents/iOS/hello/platforms/ios/HelloWorld/Resources/TGCameraAuthorizationViewController.strings" already exists
at module.exports.resource-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/ios.js:128:48)
at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:72:25)
at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:591:20)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:340:28
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:509:49
at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: Uh oh!
target destination "/Users/mg/Documents/iOS/hello/platforms/ios/HelloWorld/Resources/TGCameraAuthorizationViewController.strings" already exists
at module.exports.resource-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/ios.js:128:48)
at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:72:25)
at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:591:20)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:340:28
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:509:49
at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
我试图使用:
<framework src="src/ios/TGCameraViewController" custom="true" />
这样我可以包含整个文件夹,但是当我想要#import“SomeClass.h”时,它找不到该文件。
如何在plugin.xml中添加名称相同但文件夹不同的资源?
答案 0 :(得分:6)
根据插件规范http://cordova.apache.org/docs/en/edge/plugin_ref_spec.md.html#Plugin%20Specification
resource-file元素不支持任何目标属性。目标属性适用于Android,而不适用于iOS。
解决方案很简单,删除plugin.xml中的内容(上面的代码),然后在plugin.xml中保留<resource-file src="src/ios/TGCameraViewController"/>
并尝试构建。