I want to create a feature toggle in the settings bundle of our app. So, if we on/off the toggle, we can show/hide a specific feature that’s currently being developed. But, I don’t want to show the toggle option on the production settings yet. Users who download the app don’t need to see this feature. So, How do I hide the toggle if its on production mode?
Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
Wrapped the Toggle in
#if DEBUG
I would recommend moving to use a Feature Flag tool that supports iOS such as LaunchDarkly or DevCycle.
This way you can not only control if a feature is on or off in production but also control which specific user or group of users can see that feature.
You can also integrate the Feature Flag into your back end as well so that users of a specific version of your application can get specific APIs or data sets.
In this example, you would enable Feature Flags (using DevCycle) in your application. Docs are at: https://docs.devcycle.com/docs/sdk/client-side-sdks/ios
Then if you wanted to toggle on a feature, such as an option on an admin screen you would wrap the code this way:
You can then turn on this Feature Flag for users who have appVersion 1.1.1, and it will be off for all other users.