新手入门 uni-app,配置iOS离线包里面的原生模块,如推送、一键登录等可能会遇到找不到SDK等问题。
这里以阿里云推送为例:插件地址:https://ext.dcloud.net.cn/plugin?id=7628
1、在uni-app 根目录创建 nativeplugins 文件夹放置原生本地插件包 Aliyun-Push,这只是用于云打包使用的。
2、本地iOS离线打包工程里面引用这些包里面的framework以及需要的其他依赖,直接引用 nativePlugins 目录下的资源
1.引用 nativePlugins 目录下的 framework 时,需在 Build Settings -> Search Paths -> Framework Search Paths 中 配置路径,如图。
2.引用Bundle资源包时Xcode 选择 Create folder references。
3、需要在 Info.plist 里面配置对应的推送key和秘钥以及原生插件模块名称(配置参数在插件包里面的package.json里面)。需要把如下代码拷贝至 Info.plist里面,如文档https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios.html#:
package.json的代码片段截取:
"ios": {
"hooksClass": "AliyunPushAppProxy",
"plugins": [{
"type": "module",
"name": "Aliyun-Push",
"class": "AliyunPushModule"
}],
"frameworks": [
"AliyunPush.framework",
"AlicloudSender.framework",
"AlicloudUtils.framework",
"CloudPushSDK.framework",
"EMASRest.framework",
"UTDID.framework",
"UTMini.framework",
"libz.tbd",
"libresolv.tbd",
"CoreTelephony.framework",
"SystemConfiguration.framework",
"libsqlite3.tbd"
],
"integrateType": "framework",
"deploymentTarget": "9.0",
"parameters": {
"阿里云移动推送iOS AppKey": {
"des": "阿里云EMAS移动应用标识",
"key": "aliyun:push:appKey"
},
"阿里云移动推送iOS AppSecret": {
"des": "阿里云EMAS移动应用密钥",
"key": "aliyun:push:appSecret"
}
}
}
Aliyun-Push 插件在 Info.plist 配置就是:
<key>dcloud_uniplugins</key>
<array>
<dict>
<key>hooksClass</key>
<string>AliyunPushAppProxy</string>
<key>plugins</key>
<array>
<dict>
<key>type</key>
<string>module</string>
<key>name</key>
<string>Aliyun-Push</string>
<key>class</key>
<string>AliyunPushModule</string>
</dict>
</array>
</dict>
</array>
Aliyun-Push 在 Info.plist 配置AppKey和AppSecret:
<key>aliyun</key>
<dict>
<key>push</key>
<dict>
<key>appKey</key>
<string>2323231231</string>
<key>appSecret</key>
<string>asd12313das1231dasda1231313</string>
</dict>
</dict>