React Native Config with separated build configurations doesn't work with Xcode Archive

71 views Asked by At

After making the Xcode archive and publishing it to TestFlight internal testing, my app is loading with debug environments - however the Archive has been done with Release and/or Staging scheme which theoretically should automatically load the release/staging env file.

It works fine on launching the app on real device: I choose the Release schema, chose my physical iPhone and press Run, after which Application is successfully launched with release environment variables. That's why I ignored the following section from the react-native-config documentation:

In the Xcode menu, go to Product > Scheme > Edit Scheme
Click Duplicate Scheme on the bottom
Give it a proper name on the top left. For instance: "Myapp (staging)"
Make sure the "Shared" checkbox is checked so the scheme is added to your version control system

This is my Podfile:

ENVFILES = {
  'Debug' => '$(PODS_ROOT)/../../.env.debug',
  'Staging' => '$(PODS_ROOT)/../../.env.staging',
  'Release' => '$(PODS_ROOT)/../../.env.production',
}

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.name == 'react-native-config'
        config.build_settings['ENVFILE'] = ENVFILES[config.name]
      end
    end
  end
end

Is there a reason why Archiving doesn't load the required env files depending on the selected Schema, while running application on real device does so?

Thank you mates in advance!

0

There are 0 answers