# 使用CameraRoll保存图片时报错cannot read property savetocameraroll

**URL:** <https://www.shiqidu.com/t/topic/218>\
**Category:** 开发调优\
**Tags:** React-Native\
**Created:** [2017 年8 月 30 日 09:24 UTC](https://www.shiqidu.com/t/topic/218 "2017-08-30T09:24:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Eureka](https://www.shiqidu.com/user_avatar/www.shiqidu.com/eureka/32/5_2.png) [@Eureka](https://www.shiqidu.com/u/Eureka)\
发布日期： [2017 年8 月 30 日 09:24 UTC](https://www.shiqidu.com/t/topic/218/1 "2017-08-30T09:24:56Z")

</div>

在使用`react-native-image-zoom-viewer`保存图片时，报错cannot read property ‘savetocameraroll’。  
查找之后发现`react-native-image-zoom-viewe`保存图片使用的是`CameraRoll`api。所以我们需要在xcode中添加静态库依赖。  
具体操作如下:

1. 首先打开`你的项目目录/node_modules/react-native/Libraries/CameraRoll/` 找到`RCTCameraRoll.xcodeproj`这个文件。  
 ![64a9b9e25413d805e521e2fff7ccf057.png](https://discourse.shiqidu.com/uploads_nj/article/20170830/64a9b9e25413d805e521e2fff7ccf057.png)
2. 然后把它拖到`xcode`的`Libraries`目录下。  
 ![3b128eea5723112f6ddae537ce7a6f5a.png](https://discourse.shiqidu.com/uploads_nj/article/20170830/3b128eea5723112f6ddae537ce7a6f5a.png)
3. 然后点击项目标签在`General`标签中找到`Linked Frameworks and Libraries` 点击下边的\*\*+\*\*号把`libRCTCameraRoll.a`加进来  
 ![12d2173d1acc75db86ceaa91cc157db6.png](https://discourse.shiqidu.com/uploads_nj/article/20170830/12d2173d1acc75db86ceaa91cc157db6.png)

![a1a852cade9539bf2acb1469d4747fda.png](https://discourse.shiqidu.com/uploads_nj/article/20170830/a1a852cade9539bf2acb1469d4747fda.png)

然后再返回你的项目中保存图片应该就不会错了。
