简体   繁体   English

将Pod依赖项添加到cordova插件

[英]Add Pod dependency to a cordova plugin

I'm currently building an Ionic 3 project and I need to develop a custom Cordova plugin which needs a Pod for iOS platform ( https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library ). 我目前正在构建一个Ionic 3项目,我需要开发一个自定义的Cordova插件,该插件需要一个适用于iOS平台的Pod( https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library )。

I added the line 我加了线

<framework src="iOSDFULibrary" type="podspec" spec="4.1.0"/>

to the plugin.xml file, child element of 到plugin.xml文件的子元素

<platform name="ios">

It doesn't seem to install the Pod depency. 它似乎没有安装Pod依赖关系。 Then created the podfile, added the desired pod to the podfile 然后创建podfile,将所需的pod添加到podfile

target 'MyApp' do
    use_frameworks!
    pod 'iOSDFULibrary'
end

and finally fin run pod install. 最后fin运行pod安装。 I fixed some dependencies issues whith Xcode (using $(inherited) for embedded libraries and runpath) 我修复了Xcode的一些依赖性问题(对于嵌入式库和运行路径,使用$(继承))

Then I run 然后我跑

ionic cordova build ios

from the root directoy and I get the following error : 从根目录directoy,我得到以下错误:

 ProcessProductPackaging "" /Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-cnmgcjqxsbizwzgzyunkhpaidafn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Zip.build/Zip.framework.xcent
cd /Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/Pods
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/XXX/Documents/dev/app/test/ble/ble/last/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/Cellar/android-sdk/24.1.2/tools:/usr/local/Cellar/android-sdk/24.1.2/platform-tools≈"
builtin-productPackagingUtility -entitlements -format xml -o /Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-cnmgcjqxsbizwzgzyunkhpaidafn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Zip.build/Zip.framework.xcent
 warning: Falling back to contents of entitlements file "Entitlements-Debug.plist" because it was modified during the build process. Modifying the entitlements file during the build is unsupported.error: The file “Entitlements-Debug.plist” couldn’t be opened because there is no such file.

 === BUILD TARGET CordovaLib OF PROJECT CordovaLib WITH CONFIGURATION Debug ===
 Check dependencies

 Write auxiliary files

 /bin/mkdir -p /Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/build/sharedpch/CordovaLib_Prefix-asuvblhsjpogpaeowyccynwoocft
 write-file /Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/build/sharedpch/CordovaLib_Prefix-asuvblhsjpogpaeowyccynwoocft/CordovaLib_Prefix.pch.pch.hash-criteria
 write-file /Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-cnmgcjqxsbizwzgzyunkhpaidafn/Build/Intermediates.noindex/CordovaLib.build/all-product-headers.yaml

 ** BUILD FAILED **


 The following build commands failed:
 ProcessProductPackaging ""      /Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-cnmgcjqxsbizwzgzyunkhpaidafn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Zip.build/Zip.framework.xcent
 (1 failure)
 Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/cordova/build-debug.xcconfig,-workspace,MyApp.xcworkspace,-scheme,MyApp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone SE,build,CONFIGURATION_BUILD_DIR=/Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/XXX/Documents/dev/app/test/ble/ble/last/platforms/ios/build/sharedpch

1st question : How to bundle a Cocoapod written in swift to a custom plugin written in swift ? 第一个问题 :如何将以Swift编写的Cocoapod绑定到以swift编写的自定义插件?

2nd question : What is the meaning of ProcessProductPackaging ? 第二个问题 :ProcessProductPackaging是什么意思?

Documentations 文献资料

https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

How to bundle Cocoapod dependencies with Cordova Plugin? 如何将Cocoapod依赖项与Cordova插件捆绑在一起?

https://github.com/blakgeek/cordova-plugin-cocoapods-support https://github.com/blakgeek/cordova-plugin-cocoapods-support

Any advices appreciated 任何建议表示赞赏

Check out this documentation 查看此文档

cordova spec 科尔多瓦规格

Paired with type="podspec", this is the spec string for the CocoaPod you want to install (static library only). 与type =“ podspec”配对,这是您要安装的CocoaPod的规范字符串(仅静态库)。 CocoaPod support only exists in cordova-ios 4.3.0 and cordova-cli 6.4.0. CocoaPod支持仅在cordova-ios 4.3.0和cordova-cli 6.4.0中存在。 For your plugin, make sure you add the appropriate tags and package.json dependencies to ensure backwards-compatible support. 对于您的插件,请确保添加适当的标签和package.json依赖项,以确保向后兼容。

add this to your plugin.xml 将此添加到您的plugin.xml

<engines>
    <engine name="cordova" version=">=7.0.0" />
    <engine name="cordova-android" version=">=6.3.0" />
    <engine name="cordova-ios" version=">=4.4.0" />
</engines>

and your package.json file 和你的package.json文件

  "engines": {
  "cordovaDependencies": {
      "1.0.0": { 
        "cordova-ios": ">=4.4.0",
        "cordova-android": ">6.3.0",
        "cordova": ">=7.0.0"
      }
  }
},

The 1.0.0 should be your cordova plugin version. 1.0.0应该是您的cordova插件版本。

Lastly and most importantly, Make sure you update to the latest version of node and cordova globally. 最后也是最重要的一点是,请确保您全局更新为node和cordova的最新版本。

Also update your IOS project to the minimum supported version. 还将您的IOS项目更新为最低支持版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM