分類
React Native

[React Native] Config.h not found

使用 Xcode 載入並編譯 ReactNatie 的 ios項目時出現“Config.h not found” in mutex.h
移動到 /專案目錄/node_modules/react-native/third-party/glog-0.3.4/
執行 ./configure
再執行 make
解決該問題之後,重新編譯發生 gflags.h not found。
參考此篇

分類
React Native

[React Native] Error: Unable to resolve module ModuleName from xxx.js

Error Message :

error: Error: Unable to resolve module react-navigation-redux-helpers from /project_path/App/Navigation/utils/redux.js: react-navigation-redux-helpers could not be found within the project or in these directories:
node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
2 | createReactNavigationReduxMiddleware,
3 | createReduxBoundAddListener,
> 4 | } from 'react-navigation-redux-helpers';
| ^
5 |
6 | const middleware = createReactNavigationReduxMiddleware(
7 | "root",

 
1.go to https://www.npmjs.com/ and input your missing module name as below

it will show match modules

 
3. click module link on page then show module info

4. Go to your project root directory and type install command in terminal
npm i react-navigation-redux-helpers
or using “rnpm installl react-navigation-redux-helpers” if you installed rnpm
5. Terminate running Node and restart it by type “npm start”
6. Press Reload JS button on Device
 
 

分類
React Native

[React Native] 初始化專案名稱時不要加入底線

在初始化專案時除了底線,其他特殊字元(!@#$%^&*()_+)最好也不要加入。
否則使用 npx react-native init ProjectName 會出現以下錯誤

...
bash: /ProjectName/node_modules/react-native/scripts/generate-specs.sh: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
...
...
 The following build commands failed:
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Test06291048-dsjrkgluxojtqccvgedklqhljofa/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-F3218021401063C6A0EDA18B9CC60218.sh
(1 failure)

基本上可以看到就是 generate-specs.sh 發生了 No such file or directory。
有時間再去看看內容吧。
 

分類
React Native

[React Native] Xcode 編譯緩慢(30min~50min)問題

這是接手新專案的第一個Issue。狀況如下
每一次使用Xcode編譯ReactNative的ios專案都要花費30~50分鐘,就連最基本的HelloWorld也要20分。
ReactNative 環境參數如下

Environment:
OS: macOS 11.4
Node: 12.13.0
Yarn: 1.22.10
npm: 6.12.0
Watchman: Not Found
Xcode: Xcode 12.4 Build version 12D4e
Android Studio: 4.1 AI-201.8743.12.41.7199119
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: ~0.55.2 => 0.55.4

因為是舊專案了,所以ReactNative版本離現在有一段差距(0.55.2)
本來懷疑是Apple M1 問題(Mac Mini 2020),查來查去也沒發現太多內容。
調整Xcode設定也調了兩三天,沒有頭緒!!
還好找到一篇
https://stackoverflow.com/questions/49436853/slow-compile-times-with-react-native-ios-app
基本上就是調整 Xcode -> Build Phases -> Bundle React Native code and Images -> 把 Run Script : For install builds only 打勾

基本上可以把編譯時間從30~60分,降到1分以內。
雖然還需要了解選項到底在做啥,不過先解決燃眉之急吧!!