react-native iOS app not showing static assets (images) after deploying

前端 未结 5 1549
-上瘾入骨i
-上瘾入骨i 2020-12-01 12:58

I have all my static images in a folder called \"images\" in the root of my project. However, after I run the following command to bundle my app, the app works but no image

5条回答
  •  自闭症患者
    2020-12-01 13:29

    Local assets do not load even if you are working on a newer Xcode versions i.e. 12.x or later. There are two solutions to it :

    1. Upgrade react-native versions
    2. Or go to below file:
    node_modules > react-native > Libraries > Images > RCTUIImageViewAnimated.m search for `if (_currentFrame)`
    

    add the following else block to the if block as below

    if (_currentFrame) {
      layer.contentsScale = self.animatedImageScale;
      layer.contents = (__bridge id)_currentFrame.CGImage;
     } else {
      [super displayLayer:layer];
     }
    

    If its older xcode you need to add assets and main.jsbundle under Xcode -> build phases -> copy bundle resources

提交回复
热议问题