ToC
- https://hacpai.com/article/1496906863683
- https://hacpai.com/article/1497002998658
- https://hacpai.com/article/1497406003289
- https://hacpai.com/article/1497235254333
Android
步骤
1 生成签名秘钥
keytool -genkey -v -keystore symapp-release-key.keystore -alias symapp -keyalg RSA -keysize 2048 -validity 10000
按照提示一路走下去
2 设置gradle变量
- 把
symapp-release-key.keystore
文件放到工程中的SymApp/android/app
文件夹下 - 创建
~/.gradle/gradle.properties
文件,添加如下的代码
MYAPP_RELEASE_STORE_FILE=symapp-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=symapp
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
3 修改 gradle 配置
打开 SymApp/android/app/build.gradle
添加如下配置
android {
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
4 打包
cd SymApp/android
./gradlew assembleRelease
5 安装
请先删除以前的 APP
./gradlew installRelease
异常
Could not list contents of 'SymApp/node_modules/react-native/third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link.
直接 unlink,也就是可以把这个文件删掉。
"symapp-release-key.keystore": Cannot recover key
第一次输入的密码(store password)和最后一次输入的密码(key password)修改为不一样的就 OK 了
iPhone
打包
真机调试
- 修改 SymApp/node_modules/react-native/Libraries/WebSocket/RCTWebSocketExecutor.m 文件中
NSString *host = [[_bridge bundleURL] host] ?: @"localhost";
此行内的 localhost 为你本机 IP - USB 连上 iPhone,选择信任
- 在 Xcode 中选中项目 -> General -> Signing -> 添加账户。然后输入你的 apple 的账户和密码。如果没有开发者账号的可以移步 # iOS 10 关于Xcode 8 无证书真机测试的问题
- 在左上角的 set the active scheme 后选择 XXX 的 iPhone,点击左侧的 build and run the current scheme
关闭远程调试
- Xcode -> Product -> Scheme -> Edit Scheme -> Run -> Info -> Build Configuration,选择 Release
- 在左上角的 set the active scheme 后选择 XXX 的 iPhone,点击左侧的 build and run the current scheme
异常
Xcode will continue when “iPhone名称” is finished.
拔线重插或锁屏再解锁
Signing for "XXX" requires a development team.
选中项目,点击项目中 Targets 为 XXX 的选项 -> General -> Signing -> Team,选择你的 Team