在react-native项目总添加 realm时,发现在iOS工程中无法下载realm-sync-cocoa,一直卡在:
Installing RealmJS (10.1.3)
> Running prepare command
$ /bin/bash -c set -e ./scripts/xcode-download-realm.sh ./scripts
Resolved requirements: {
SYNC_SERVER_FOLDER: 'sync',
SYNC_ARCHIVE: 'realm-sync-cocoa-10.1.6.tar.gz',
SYNC_ARCHIVE_ROOT: 'core'
}
Resolved options: { platform: 'ios', sync: true }
No lockfile found at the target /Users/yif/Desktop/family-robot-one-desktop/node_modules/realm/vendor/realm-ios, proceeding.
Download url: https://static.realm.io/downloads/sync/realm-sync-cocoa-10.1.6.tar.gz
最终使用该方式解决:https://www.jianshu.com/p/0ea2903d8b00
- 先把压缩包下载下来,具体路径查看控制台输出的Download url,然后修改node_modules/realm/scripts/download-realm.js 的download函数,将其修改成:
if (copyLocal(archive, destination)) {
return Promise.resolve();
}
const url = `https://static.realm.io/downloads/${serverFolder}/${archive}`;
console.log(`Download url: ${url}`);
console.log(`destination path: ${destination}`);
return new Promise(resole => {
setTimeout(()=>{
console.log('Time finished');
resole();
}, 120 * 1000);
});
- 在控制台继续通过pod安装realm,控制台会输出缓存路径:
destination path: /var/folders/8k/1q1ryw2d3vb4970w99zqpjtw0000gn/T/0421c79b252416274f2b94054db89f4aa3940f35/realm-sync-cocoa-10.1.6.tar.gz
3.将你预先下载的压缩包直接放入该文件目录中
4.等待修改函数的计数器执行完毕即可。