0

I am trying to use the react-native-config with react-native configured with Swift.

Following the usage guide, it tells me to import #import "ReactNativeConfig.h".

I imported this inside of the bridging header, but it can't find it.

Does anyone know how to use this library with a react native app build with Swift?

1 Answer 1

2

you just need to add #import "ReactNativeConfig.h" in bridging header. If you did that you can use it in your swift code without any additional import.

Here is some article I found helpful. https://medium.com/@subhangdxt/bridging-objective-c-and-swift-classes-5cb4139d9c80

And here is my code:

My app-Bridging-Header.h:

...
#import "ReactNativeConfig.h"
...

My AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

  ...

  if let gmsApiKey = ReactNativeConfig.env(for: "GOOGLE_MAPS_API_KEY") {
    GMSServices.provideAPIKey(gmsApiKey)
  } else {
    print("ERROR: No goole maps api key provided!")
  }

  bridge = RCTBridge(delegate: self,  launchOptions: launchOptions)

  ...

  return true
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.