简体   繁体   中英

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 ).

I added the line

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

to the plugin.xml file, child element of

<platform name="ios">

It doesn't seem to install the Pod depency. Then created the podfile, added the desired pod to the podfile

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

and finally fin run pod install. I fixed some dependencies issues whith Xcode (using $(inherited) for embedded libraries and runpath)

Then I run

ionic cordova build ios

from the root directoy and I get the following error :

 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 ?

2nd question : What is the meaning of ProcessProductPackaging ?

Documentations

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

How to bundle Cocoapod dependencies with Cordova Plugin?

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). CocoaPod support only exists in cordova-ios 4.3.0 and cordova-cli 6.4.0. For your plugin, make sure you add the appropriate tags and package.json dependencies to ensure backwards-compatible support.

add this to your 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

  "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.

Lastly and most importantly, Make sure you update to the latest version of node and cordova globally.

Also update your IOS project to the minimum supported version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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