Skip to content

Commit

Permalink
build(app): workaround for some app setup issues on iOS
Browse files Browse the repository at this point in the history
Renaming the native folder and the install pods option seem to both have started to cause some issues recently.
  • Loading branch information
tobua committed Jan 15, 2024
1 parent 4f5ac17 commit e056792
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
package-lock.json
dist
ResponsiveApp
app-temp
app/**/*
!app/App.tsx
!app/Expandable.tsx
Expand Down
26 changes: 14 additions & 12 deletions create-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@ import { join } from 'path'
import { execSync } from 'child_process'

// Enhances source files inside /app with a fresh RN project template.
const appName = 'ResponsiveApp'
const appTemp = 'app-temp'

console.log('⌛ Initializing a fresh RN project...')

execSync(`npx react-native init ${appName} --skip-git-init true --install-pods true`, {
// Write output to cnosole.
// Renaming native folder leads to iOS build issues in some versions.
renameSync('app', appTemp)

execSync('npx react-native init app --skip-git-init true --install-pods false', {
// Write output to console.
stdio: 'inherit',
})

cpSync('app/App.tsx', `${appName}/App.tsx`)
cpSync('app/Expandable.tsx', `${appName}/Expandable.tsx`)
cpSync('app/global.d.ts', `${appName}/global.d.ts`)
cpSync('logo.png', `${appName}/logo.png`)

rmSync('app', { recursive: true })
cpSync(`${appTemp}/App.tsx`, 'app/App.tsx')
cpSync(`${appTemp}/Expandable.tsx`, 'app/Expandable.tsx')
cpSync(`${appTemp}/global.d.ts`, 'app/global.d.ts')
cpSync('logo.png', 'app/logo.png')

renameSync(appName, 'app')
rmSync(appTemp, { recursive: true })

// Run build to ensure distributed files for plugin exist.
execSync('npm run build', {
stdio: 'inherit',
})

// Install this package locally, avoiding symlinks.
execSync('npm install $(npm pack .. | tail -1) --legacy-peer-deps', {
execSync('npm install $(npm pack .. | tail -1)', {
cwd: join(process.cwd(), 'app'),
stdio: 'inherit',
})

// Additional dependency.
execSync('npm install react-native-cols mobx --legacy-peer-deps', {
execSync('npm install react-native-cols mobx', {
cwd: join(process.cwd(), 'app'),
stdio: 'inherit',
})
Expand All @@ -44,6 +45,7 @@ console.log('🍞 React Native App created inside /app.')
console.log('🛠️ To run the example with the plugin included:')
console.log('🐚 cd app')
console.log('🐚 npm run ios / npm run android')
console.log('🐚 cd ios & pod install, as automatic pod installation currently fails.')
console.log('🌪️ To copy over the changes from the plugin source run:')
console.log('🐚 npm run watch')
console.log('🛠️ This will copy changes over to the app.')
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,27 @@
"flexbox"
],
"devDependencies": {
"@react-native-community/cli": "^13.0.0",
"@react-native-community/cli": "^12.3.2",
"@react-native/babel-preset": "^0.74.0",
"@react-native/eslint-config": "^0.74.0",
"@react-native/typescript-config": "^0.74.0",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.4.3",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.0",
"@types/react": "^18.2.47",
"@types/node": "^20.11.2",
"@types/react": "^18.2.48",
"@types/react-native": "^0.72.8",
"@types/react-test-renderer": "^18.0.7",
"babel-jest": "^29.7.0",
"cpx": "^1.5.0",
"esbuild": "^0.19.11",
"eslint": "^8.56.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"mobx": "^6.12.0",
"mobx-react-lite": "^4.0.5",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.0",
"prettier": "^3.2.2",
"react": "^18.2.0",
"react-native": "^0.73.2",
"react-test-renderer": "^18.2.0",
Expand Down

0 comments on commit e056792

Please sign in to comment.