Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Unexpectedly found nil while unwrapping an Optional value #3

Closed
estebanutz opened this issue Mar 25, 2022 · 3 comments
Closed

Comments

@estebanutz
Copy link

Hi, I'm trying to integrate your TurboController into my turbo ios app and I'm getting the error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value on line 224:

let environment = ProcessInfo.processInfo.environment["ENVIRONMENT"]! as String

When I ran your demo on my local machine no problems, so is this a configuration issue on my end or code compatibility with newer version of iOS? I noticed under Deployment target your demo is set to 14.5, while mine is 15.2, but even if I change mine to 14.5 I keep getting the error. Any help would be greatly appreciated!

Thanks!

@joemasilotti
Copy link

I believe that this environment flag is only set when the app is run via Xcode. So when you run it on a device by tapping the icon it won't be set. You could change that line to something like this to default to production when running outside of Xcode.

let environment = ProcessInfo.processInfo.environment["ENVIRONMENT"] as? String ?? "PRODUCTION"

Replacing "PRODUCTION" with whatever environment you'd like to use.

@estebanutz
Copy link
Author

@joemasilotti Thank you! That fixed the issue, but what's interesting is I ran your demo via Xcode and it does not produce the same error, that's throwing me off a little bit.

@joemasilotti
Copy link

Running via Xcode is what sets the environment variable. So if you ran the demo against a device (or opened the demo via tapping the app icon) it will crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants