1. npx react-native init LongserDemo --template react-native-template-typescript
  1. cd LongserDemo
  2. npm install --save @react-navigation/native
  3. npm install --save @react-navigation/native-stack
  4. npm install --save @react-navigation/bottom-tabs
  5. npm install --save react-native-screens
  6. npm install --save react-native-safe-area-context
  7. npm install --save react-native-vector-icons
  8. npm install --save-dev @types/react-native-vector-icons
  9. npm install --save react-native-linear-gradient
  10. npm install --save react-native-safe-area-context
  11. npm install --save create-react-class
  12. npm install --save-dev @types/create-react-class
  13. npm install --save @react-native-community/datetimepicker
  14. npm install --save react-native-qrcode-svg
  15. npm install --save @react-native-community/netinfo
  16. npm install --save @react-native-picker/picker
  17. npm install --save @react-native-community/slider
  18. npm install --save @react-native-async-storage/async-storage
  19. npm install --save react-native-webview
  20. npm install --save react-native-gesture-handler
  21. npm install --save react-native-share
  22. npm install --save pinyin-pro
  23. npm install --save umi-request
  24. npm install --save async-validator
  25. npm install --save-dev babel-plugin-module-resolver
  26. //npm install --save-dev babel-plugin-transform-inline-environment-variables
  27. npm install --save async-validator
  28. npx install-expo-modules
  29. npm install -g expo-cli
  30. expo install expo-application
  31. expo install expo-camera
  32. expo install expo-barcode-scanner
  33. expo install expo-image-picker
  34. expo install react-native-svg
  35. expo install expo-image-manipulator
  36. expo install expo-brightness
  37. expo install expo-location
  38. expo install expo-print
  39. expo install expo-web-browser
  40. expo install expo-local-authentication
  41. expo install expo-contacts
  42. expo install expo-device
  43. expo install expo-random
  44. expo install expo-sharing
  45. expo install expo-secure-store
  46. expo install expo-sqlite
  47. cd ios
  48. pod install
  49. cd ..
  50. mkdir src
  51. mv app.json src
  52. mv App.tsx src

index.js

  1. import App from './App';
  2. import App from './src/App';
  3. import {name as appName} from './app.json';
  4. import {name as appName} from './src/app.json';

tsconfig.json

  1. "baseUrl": "./",
  2. "paths": {
  3. "components": ["./src/components"],
  4. "components/*": ["./src/components/*"],
  5. "screens/*": ["./src/screens/*"],
  6. "theme": ["./src/theme"],
  7. "demos": ["./src/components/demo.ts"],
  8. },
  9. ...
  10. }
  11. "include": ["src"],

babel.config.js

  1. module.exports = {
  2. presets: ['module:metro-react-native-babel-preset'],
  3. plugins: [
  4. [
  5. require.resolve('babel-plugin-module-resolver'), {
  6. extensions: [
  7. ".ios.js",
  8. ".android.js",
  9. ".js",
  10. ".ts",
  11. ".tsx",
  12. ".json"
  13. ],
  14. alias: {
  15. "components": "./src/components",
  16. "screens": "./src/screens",
  17. "demos": "./src/components/demo.ts",
  18. "theme": "./src/theme"
  19. }
  20. }]
  21. ]
  22. };

ios/LongserDemo/info.plist

  1. <key>NSAppTransportSecurity</key>
  2. <dict>
  3. <key>NSExceptionDomains</key>
  4. <dict>
  5. <key>localhost</key>
  6. <dict>
  7. <key>NSExceptionAllowsInsecureHTTPLoads</key>
  8. <true/>
  9. </dict>
  10. </dict>
  11. + <key>NSAllowsArbitraryLoads</key>
  12. + <true/>
  13. </dict>
  14. + <key>NSCameraUsageDescription</key>
  15. + <string>Allow $(PRODUCT_NAME) to use the camera</string>
  16. + <key>NSMicrophoneUsageDescription</key>
  17. + <string>Allow $(PRODUCT_NAME) to use the microphone</string>
  18. + <key>NSPhotoLibraryUsageDescription</key>
  19. + <string>"Allow $(PRODUCT_NAME) to access your photos"</string>
  20. + <key>NSFaceIDUsageDescription</key>
  21. + <string>"$(PRODUCT_NAME) 只访问认证接口,并不会读取手机采集的数据"</string>
  22. + <key>NSContactsUsageDescription</key>
  23. + <string>Allow $(PRODUCT_NAME) to access your contacts</string>
  24. + <key>UIAppFonts</key>
  25. + <array/>
  1. <key>NSCameraUsageDescription</key>
  2. <string>Allow $(PRODUCT_NAME) to use the camera</string>
  3. <key>NSMicrophoneUsageDescription</key>
  4. <string>Allow $(PRODUCT_NAME) to use the microphone</string>
  5. <key>NSPhotoLibraryUsageDescription</key>
  6. <string>"Allow $(PRODUCT_NAME) to access your photos"</string>
  7. <key>NSFaceIDUsageDescription</key>
  8. <string>"$(PRODUCT_NAME) 只访问认证接口,并不会读取手机采集的数据"</string>
  9. <key>NSContactsUsageDescription</key>
  10. <string>Allow $(PRODUCT_NAME) to access your contacts</string>
  11. <key>UIAppFonts</key>
  12. <array/>
  13. LSApplicationQueriesSchemes

src/app.json

  1. {
  2. "name": "LongserDemo",
  3. "displayName": "LongserDemo",
  4. "expo": {
  5. "plugins": [
  6. [
  7. "expo-image-picker",
  8. {
  9. "photosPermission": "The app accesses your photos to let you share them with your friends."
  10. }
  11. ]
  12. ]
  13. },
  14. "ios": {
  15. "entitlements": {
  16. "com.apple.developer.networking.wifi-info": "true"
  17. }
  18. }
  19. }

替换 App.tsx,复制其他文件过来

开两个窗口

  1. npx react-native start
  1. npx react-native run-ios

image.png
image.png
image.png

直接设置图标和Splash,完全不需要外部的Splash库

Todo: clear Console.log

https://icon.wuruihong.com
https://github.com/crazycodeboy/react-native-splash-screen/blob/master/add-LaunchScreen-tutorial-for-ios.md

React-Native启动页及ICON设置