![](/img/trans.png)
[英]How to configure plugin.xml for IOS plugin upgrade from 2.x to 3.0 in cordova / phonegap
[英]How to add Resources with the same name but different folders in plugin.xml?
我有一個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中添加具有相同名稱但不同文件夾的資源?
根據插件規范http://cordova.apache.org/docs/en/edge/plugin_ref_spec.md.html#Plugin%20Specification
resource-file元素不支持任何目標屬性。 target屬性適用於android,不適用於iOS。
解決方案很簡單,只需刪除plugin.xml中的代碼(上面的代碼),然后將<resource-file src="src/ios/TGCameraViewController"/>
在plugin.xml中,然后嘗試構建即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.