簡體   English   中英

反應本機配置無法讀取 ios 中的 env 文件

[英]react native config cannot read env file in ios

我已經按照文檔: https://github.com/luggit/react-native-config#ios直到:Build settings 和 Info.plist 步驟 6 中的可用性。為將生成"tmp.xcconfig"的方案創建新的構建階段"tmp.xcconfig"在每次構建之前向 Build Settings 和 Info.plist 公開值(如果使用下面解釋的方法,則此代碼段必須放在"echo... > tmp/envfile"之后)

  • 我已經為我的應用程序創建了架構,然后在 build -> pre-actions 中。 我單擊添加新腳本並粘貼以下內容:
echo ".env.staging" > /tmp/envfile
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
  • 然后我 go 到 info.plist 並使用 $(MYENVVAR) 從 .env 文件中獲取價值,但它無法獲得任何價值。 有沒有人遇到過? 我的 package json 鎖是"react-native-config": "0.11.7"

很高興看到任何評論

如果您在import Config from 'react-native-config'時可以在 JS 中看到空配置文件,並且如果您使用的是 Pod,只需添加(沒有react-native link react-native-config

pod 'react-native-config', :path => '../node_modules/react-native-config/react-native-config.podspec'

在你的 Podfile 中。

並嘗試更新模塊版本

"react-native-config": "^1.0.0"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM