CodexBloom - Programming Q&A Platform

How to implement guide with displaying localized strings in swiftui on iphone 12 with ios 15

👀 Views: 92 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-06
SwiftUI Localization iOS Swift

I'm maintaining legacy code that I'm converting an old project and I'm converting an old project and I'm working through a tutorial and This might be a silly question, but I'm experiencing an scenario with displaying localized strings in my SwiftUI app on an iPhone 12 running iOS 15. Despite having my `Localizable.strings` files set up correctly for English and Spanish, the app seems to default to English regardless of the device language settings. I've verified that my `Localizable.strings` files are correctly named and in the appropriate folders. Here's a snippet of how I'm attempting to access the localized strings: ```swift Text(NSLocalizedString("welcome_message", comment: "Welcome message for the user")) ``` I've also ensured that the supported languages are added in the project settings under `Info.plist`: ```xml <key>CFBundleLocalizations</key> <array> <string>en</string> <string>es</string> </array> ``` When I run the app on the simulator set to Spanish, it still shows the English version. I've tried cleaning the build folder and rebuilding the project, and I've also double-checked the device's language settings, which are indeed set to Spanish. What could be going wrong here? Any insights would be greatly appreciated! I'm working on a API that needs to handle this. For context: I'm using Swift on Linux. This is part of a larger desktop app I'm building. What's the correct way to implement this? What's the correct way to implement this? I'm on Linux using the latest version of Swift.