앱 빌드/개발 환경에 맞춰 깔끔하게 환경변수를 설정하기 위해 react-native-config 를 사용하고 있다

https://github.com/luggit/react-native-config

 

GitHub - luggit/react-native-config: Bring some 12 factor love to your mobile apps!

Bring some 12 factor love to your mobile apps! Contribute to luggit/react-native-config development by creating an account on GitHub.

github.com

 

android 의 경우 공식 문서를 따라가면 잘 실행이 되지만,

ios 의 경우 공식 문서를 정확히 따라가도 환경변수를 읽을 수 없는 문제가 발생하는데

접해보지 못한 여러 원인들이 있을 수 있겠지만, 나의 경우 apple chip (M2) 이 원인이었다.

(뜬금없지만 Docker 를 사용하는 경우에도 intel -> apple chip 으로 넘어오는 경우 build 명령어에 --platform=linux/amd64 를 추가해주어야한다..)

 

ios/Podfile 의 맨 하단 > post_install do |installer| 에 아래 명령어를 추가해준다

 

installer.pods_project.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"

 

위 명령어는 IOS 시뮬레이터 중에서 시뮬레이터를 지원하지 않는 아키텍처인 arm64 를 빌드 과정에서 제외하도록 설정한다.

...생략...

post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    installer.pods_project.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
          end

    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
end

+ Recent posts