Cordova 集成 Cocoapods 与 极光推送收不到的问题等解决

最近使用 Cordova 进行混合开发了, 前端使用 Angular + ionicUI 感觉还是不错的, 但是也不可避免用到原生的功能, 比如相册, 相机, 推送等, 刚好在写推送的时候遇到了一些问题, 记录一下 Cordova 集成 Cocoapods 的过程。

首先还是在根目录创建Podfile然后编写想要安装的pods, 然后执行pod installpods 安装完之后再build工程会报一个错误

1
2
3
diff: /../Podfile.lock: No such file or directory   
diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. 
Run 'pod install' or update your CocoaPods installation. 

这个时候我们去工程的目录里面, 找到Resources, 找到build-debug.xcconfig文件这是他原本的内容

1
2
3
4
5
6
7
8
9
#include "build.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1

#include "build-extras.xcconfig"

// (CB-11792)
// @COCOAPODS_SILENCE_WARNINGS@ //
#include "../pods-debug.xcconfig"

现在我们找到pod的debug.xcconfig, 拿到它的路径在上面的build-debug.xcconfig文件里面引入那Resources中的build-debug.xcconfig就变成了这样

1
2
3
4
5
6
7
8
9
10
11
12
#include "build.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1

#include "build-extras.xcconfig"

// (CB-11792)
// @COCOAPODS_SILENCE_WARNINGS@ //
// 这句注释掉了 没有这个路径
//#include "../pods-debug.xcconfig"

#include "Pods/Target Support Files/Pods-HelloCordova/Pods-HelloCordova.debug.xcconfig"

之后再 clean + build 即可正常运行, 也可以正常引入第三方库了

还有两个问题 一个是 Cordova 貌似对 #DEBUG 这种宏命令不支持 可以通过这个解决 在Build Setting中:

还有可能出现weakself报错的问题, 在Build Setting中找到C Language Dialect, 将C99改为GNU99

之后就是极光推送收不到的问题, 我用我新建的工程是可以收到推送的, 但是生成的 Cordova 中却怎么也收不到, 需要设置这里:这里原来的选项是New Build System, 改成Legacy Build System, 删掉手机中的工程, 重新运行, 问题解决~

1
2
3
4
5
6
7
8
9
10
11
// 顺便贴一下安卓安装第三方库找不到的问题
app/build.gradle
dependencies {
    // implementation fileTree(dir: 'libs', include: '*.jar')
    // 上面这个z👆替换成下面这个👇
    implementation fileTree(include: ['*.jar','*.so'], dir: 'libs')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    implementation "com.android.support:support-annotations:27.+"
    // SUB-PROJECT DEPENDENCIES END
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值