Post

Replies

Boosts

Views

Activity

Reply to Run identical UI/Unit tests on different build targets
I discovered this nugget of Apple Documentation. It visualises how the scheme is the link specifying which build target is used by the test target. Unfortunately this doesn't seem to be the case. The host application field in the test target (general tab) appears to be the main determinator. So my assumptions above seem to be correct, and you can be easily be misled into assuming one build target is used whereas in fact another target is used. Tip: Include a screenshot of the about page of your app/clip/widget to avoid being misled.
Nov ’24
Reply to How to create a second target for an app with a linked App Clip?
Here's how to fix it... In the target for the Test Flight App in the general tab you'll find a framework, library, clips section and this contains the reference to the clip ( a relic of copying the original production target.) This must be deleted. However, you cannot delete it here (if you try, you'll get warning popups etc but the deletion fails. ) Instead, navigate to the Build Phases tab and scroll down to the Embed App Clips section and here you can delete it. Warning: Make sure you do this in the test flight target not the production target.
Feb ’25
Reply to Force a locale from string catalog
LocalizedStringResource didn't seem to work. The .environment modifier may work on Views but not on the content of the view ( strings in the view used to build the shared content) However, the localizedString method suggested by AI did work despite looking messy. A shame there's not a simpler solution. @State var isOtherLanguage = false var body: some View { var myLocale: String { isOtherLanguage ? "de" : "en" } VStack { Toggle("Switch language", isOn: $isOtherLanguage).frame(maxWidth: 200) HStack { Text("❌\(myLocale): ") Text( LocalizedStringResource( "Hello world!", table: "Localizable", locale: Locale(identifier: myLocale) ) ) } HStack { Text("❌\(myLocale): ") Text( String( localized: "Hello world!", locale: (Locale(identifier: myLocale)), comment: "To share" ) ) .environment(\.locale, Locale(identifier: myLocale)) } HStack { Text("❌\(myLocale): ") Text(localizedString) } HStack { Text("✅\(myLocale): ") Text("Hello world!") .environment(\.locale, Locale(identifier: myLocale)) } HStack { Text("✅\(myLocale): ") Text(localizedString("Hello world!", locale: myLocale)) } } } func localizedString(_ key: String.LocalizationValue, locale: String) -> String { guard let path = Bundle.main.path(forResource: locale, ofType: "lproj"), let bundle = Bundle(path: path) else { return String(localized: key) } return String(localized: key, bundle: bundle) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25
Reply to Force a locale from string catalog
Many thanks Apple Engineer, func localizedString( is exactly what I needed and the fog is clearing :) Reminder to myself: func localizedString(_ resource: LocalizedStringResource, _ myLocale: String) -> String { var locale: Locale { Locale(identifier: myLocale) } var resource = resource resource.locale = locale return String(localized: resource) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25