2016-06-10 100 views
1

我有一個Xcode iOS項目,我已經成功添加了Cordova WebView。如何將Cordova插件添加到嵌入式Cordova WebView的Xcode項目中?

我偶然發現他們的教程。 https://cordova.apache.org/docs/en/latest/guide/platforms/ios/webview.html

我該如何添加插件?


如果我嘗試使用Plugman建議,我得到這個錯誤:

plugman install --platform ios --project path/to/my/custom/xcode/project --plugin cordoba-plugin-console

Failed to install 'cordova-plugin-console':CordovaError: The provided path "path/to/my/custom/xcode/project" is not a Cordova iOS project.

當然,這是真的。我遵循的指示是將網絡視圖添加到NON Cordova項目。


我也嘗試在將Cordial iOS項目中的插件添加到自己的項目中之前,將其引入config.xml。

結果是,該項目將推出,但我在Xcode控制檯中看到這些錯誤:

CDVPlugin class CDVFile (pluginName: file) does not exist.

ERROR: Plugin 'File' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.


我試圖把在Plugins文件夾從參考項目到我的項目。 (有像CDVLogger.h/mCDVFile.h/m

文件中的一個。當我這樣做,我得到構建錯誤:

duplicate symbol _kCDVFilesystemURLPrefix in: /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVCapture.o /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVLocalFilesystem.o duplicate symbol _kCDVFilesystemURLPrefix in: /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVCapture.o /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVAssetLibraryFilesystem.o duplicate symbol _kCDVFilesystemURLPrefix in: /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVCapture.o /Users/dustinbahr/Library/Developer/Xcode/DerivedData/AudioCapture-hbvwvtednsahtmgofuophnczsnmj/Build/Intermediates/AudioCapture.build/Debug-iphoneos/AudioCapture.build/Objects-normal/arm64/CDVFile.o ld: 6 duplicate symbols for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

回答

0

可以使用的CocoaPods添加科爾多瓦插件到您的項目創建一個Podfile並在其指定依賴從註冊表的CocoaPods這裏得到的,看一個例子:https://cocoapods.org/pods/phonegap-ios-template

至於你得到的duplicate symbol _kCDVFilesystemURLPrefix,解決的辦法是對的常數聲明:kCDVFilesystemURLPrefix在文件CDVFile.h找到聲明並宣佈它作爲extern

extern NSString* const kCDVFilesystemURLPrefix; 

聲明的東西作爲extern告訴編譯器類型和變量將在其他地方定義。

相關問題