xcode가 설치 되어 있지 않다면 App Store에서 설치
home brew가 설치 되어 있지 않다면 Homebrew 설치
node.js가 설치 되어 있지 않다면 brew install node
명령어로 설치
react native를 run 하기 위한 세팅
brew install watchman
arch -x86_64 sudo gem install cocoapods
arch -x86_64 sudo gem install ffi
arch -x86_64 pod install
ReactNative 설치
npm install -g react-native-cli
6번 부터는 공식 문서를 보면 쉽게 할 수 있다.
TypeScript 프로젝트 생성
npx react-native init MyApp --template react-native-template-typescript
yarn add -D typescript @types/jest @types/react @types/react-native @types/react-test-renderer
tsconfig.json 수정
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["es2017"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}
jest.config.js 파일 생성
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
yarn tsc
명령어로 확인 및 npx react-native run-ios