expo prebuild는 expo설정기반으로 ios android디렉토리 재생성하기 때문에 덮어씌워질 위험이 있음
expo prebuild를 해야하는 경우는 expo install로 네이티브 라이브러리를 추가한 경우 라이브러리가 적용되도록 하기 위해서. 혹은 app.json등의 expo설정 변경
네이티브 코드를 변경한 이후에는 prebuild를 할 필요가 없다 오히려 덮어씌워진다!!
그러므로 expo run:android로 빌드만 다시 수행한 이후 expo start해서 핫 리로딩으로 사용하면 되지 prebuild하면 안된다.
따라서 기존에 수정했던 내용 덮어씌우고 싶은게 아니라면 prebuild를 피해야함
npx expo run android는 개발서버 실행하는 명령어는 아니다 빌드 명령어지. 근데 마지막에 개발서버도 expo start로 실행해주는거임
Config Plugin은 Expo의 prebuild 시 네이티브 프로젝트(ios/, android/)의 설정을 자동으로 수정해 주는 도구입니다.
이를 통해 수동으로 네이티브 파일을 수정하지 않고도, 앱 구성(app.json 또는 app.config.js) 기반으로 원하는 네이티브 설정을 적용할 수 있습니다.
https://docs.expo.dev/config-plugins/introduction/
플러그인 파일 생성
예를 들어, 프로젝트 루트에 withMyCustomConfig.js 파일을 만듭니다.
js
CopyEdit
// withMyCustomConfig.js
const { withAndroidManifest, withInfoPlist } = require('@expo/config-plugins');
// AndroidManifest.xml 수정 예시
const withCustomAndroidManifest = (config) => {
return withAndroidManifest(config, config => {
// 예: 기존 Manifest에 새로운 intent-filter 추가 등
const manifest = config.modResults;
// 수정 로직을 여기에 작성
return config;
});
};
// Info.plist 수정 예시
const withCustomInfoPlist = (config) => {
return withInfoPlist(config, config => {
// 예: 새로운 키-값 추가
config.modResults.MyCustomKey = "MyCustomValue";
return config;
});
};
// 플러그인 메인 함수
const withMyCustomConfig = (config) => {
config = withCustomAndroidManifest(config);
config = withCustomInfoPlist(config);
return config;
};
module.exports = withMyCustomConfig;
앱 구성에 플러그인 추가
app.json 또는 app.config.js 파일에 플러그인 경로를 추가합니다.
json
CopyEdit
{
"expo": {
"name": "MyApp",
"slug": "myapp",
"plugins": [
"./withMyCustomConfig.js"
]
}
}
prebuild 실행
앱 구성 파일에 플러그인을 추가한 후, expo prebuild를 실행하면 플러그인에서 정의한 네이티브 수정 사항이 ios/ 및 android/ 폴더에 반영됩니다.