我有一个使用插件的Ionic5(cli 6.3.0)/ Cordova 9.0.3(cordova-lib@9.0.2)项目。
我正在尝试为第三方框架创建自定义插件。
我知道插件的框架是正确的,因为我是用Plugman创建的,在添加框架之前,我可以构建/运行并获得反馈,说“coolMethod”已从Objective-C文件运行。
即使添加了框架,我也可以使用ionic cordova plugin add ./packages/cordova-plugin-my-custom-stuff
使插件正确安装
我可以让Ionic / Cordova使用ionic cordova build ios
成功构建iOS项目
但是,当我尝试从Ionic命令行ionic cordova run ios
或从自动生成的xCode项目运行iOS模拟器时,我得到了
dyld: Library not loaded: @rpath/MyThirdPartySDK.framework/MyThirdPartySDK
Referenced from: /Users/myUser/Library/Developer/CoreSimulator/Devices/C9E28EFF-B017-4F5E-
BA89-5200AE5D64EA/data/Containers/Bundle/Application/775C8394-B014-4B01-89CA-
1D462FD54F4A/MyName Mobile-UAT.app/MyName Mobile-UAT
Reason: image not found
项目的结构(为简洁起见,简明扼要)如下:
MyProject
-node_modules
-packages
-cordova-plugin-my-custom-stuff
-src
-ios
MyCustomStuff.m
-MyThirdPartySDK.framework
-Headers
MobileAPI.h
MyThirdPartySDK.h
-Modules
module.modulemap
MyThirdPartySDK
-www
cordova-plugin-my-custom-stuff.js
package.json
plugin.xml
ios部分的plugin.xml如下所示:
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="MyCustomStuff">
<param name="ios-package" value="MyCustomStuff"/>
</feature>
</config-file>
<source-file src="src/ios/MyCustomStuff.m"/>
<source-file src="src/ios/MyCustomStuffSDK.framework" framework="true"/>
<header-file src="src/ios/MyCustomStuffSDK.framework/Headers/MobileAPI.h" target-dir="MyCustomStuff" />
</platform>
我正在寻找一个位于plugin.xml配置或其他一些ionic / cordovaproject配置中的解决方案。我想避免编辑xCode项目,因为这都是由ionic / cordova命令行“自动”生成的。
最佳答案
终于明白了。
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="MyCustomPlugin">
<param name="ios-package" value="MyCustomPlugin"/>
</feature>
</config-file>
<source-file src="src/ios/MyCustomPlugin.m"/>
<source-file src="src/ios/MyCustomPlugin.framework" target-dir="lib" framework="true" />
<framework src="src/ios/MyCustomPlugin.framework" embed="true" custom="true" />
<header-file src="src/ios/MyCustomPlugin.framework/Headers/MobileAPI.h" target-dir="MyCustomPlugin" />
</platform>
关于ios - 如何在Ionic/Cordova构建中正确引用iOS第三方框架,以免引发dyld:库未加载:@rpath错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61395950/