You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

移除react-native-bootsplash生成的assets/bootsplash目录的相关疑问

环境版本
  • react-native-bootsplash: 6.3.3
  • @react-navigation/native: 7.0.14
  • react-native: 0.75.4
已完成的配置代码

所有配置均按react-native-bootsplash官方文档完成设置,相关代码如下:

iOS:ios\<my-project-name>\AppDelegate.mm

#import "AppDelegate.h"
#import "RNBootSplash.h"

#import <React/RCTBundleURLProvider.h>

@implementation AppDelegate

// other code ...

- (void)customizeRootView:(RCTRootView *)rootView {
  [super customizeRootView:rootView];
  [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
}

@end

Android:android\app\src\main\java\com\<my-project-name>\MainActivity.kt

// other import ...

import android.os.Bundle;
import com.zoontek.rnbootsplash.RNBootSplash

class MainActivity : ReactActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    RNBootSplash.init(this, R.style.BootTheme)
    super.onCreate(null)
  }

  // other methods
}

React Native 代码:src\App.jsx

import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import BootSplash from 'react-native-bootsplash';

import RootBottomTab from './navigation/RootBottomTab';

function App() {
  const onReady = React.useCallback(
    async () => await BootSplash.hide({ fade: true }),
    [],
  );

  return (
    <NavigationContainer onReady={onReady}>
      <RootBottomTab />
    </NavigationContainer>
  );
}

export default React.memo(App);
操作与疑问

执行命令 npx react-native-bootsplash generate <my-logo-path> --platforms=android,ios 后,项目生成了默认路径为 "assets/bootsplash" 的目录。移除该目录后,安卓设备上应用运行正常。

我认为该目录是中间资源,无需推送到版本控制系统,现存在以下疑问:

  1. 是否应该移除assets/bootsplash目录?
  2. 移除该目录是否会影响iOS项目?
解答
  1. 是否应该移除assets/bootsplash目录?
    可以移除。这个目录是react-native-bootsplash generate命令生成的原始资源文件,命令执行时已经将这些资源处理后同步到了iOS和Android的原生项目目录中:
  • Android端:资源被复制到android/app/src/main/res下的对应drawable目录
  • iOS端:资源被添加到Xcode项目的Assets.xcassets中

该目录属于生成过程中的中间产物,不需要保留在版本控制里,完全可以删除,也可以将其加入.gitignore文件避免后续误提交。

  1. 移除该目录是否会影响iOS项目?
    不会影响。generate命令已经将iOS所需的启动屏资源(不同尺寸的logo、背景配置)导入到Xcode项目的Assets目录和Storyboard中,原生项目已包含运行所需的所有资源,和assets/bootsplash目录无关联,移除后iOS应用启动屏可正常显示。

内容的提问来源于stack exchange,提问作者GeMiNi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 15:41:09