Post

Replies

Boosts

Views

Activity

Injecting variables from shell to UI test runtime
Hey there, I am currently struggling with this problem. When running UI tests for my iOS application I want to acquire an authentication token from an API first, in order to be directly authenticated while the tests run. For using that API I need a client secret, which, because it's a secret, needs to be kept in a secure storage. I can't have that client secret be just somewhere plain text in code or any other unsecured file (xcconfig, plist, ...). That's why I want to put that client secret into macOS' key chain. I also already found out how to access that secret from command line in a build phase script (like security find-generic-password -l ClientSecret -g). What I also know is how to use launch arguments or environment during UI testing (like ProcessInfo().environment["clientSecret"]). But I can't seem to find a way to make the connection between an environment variable that I set in a build phase or run pre-action script like export CLIENTSECRET=$(security find-generic-password -l ClientSecret -w) I tried using that environment variable like clientSecret=$(CLIENTSECRET) in scheme's launch arguments or environment variables, but that doesn't work for me. Is it even possible to access the bash runtime env variables from within the scheme's arguments? Is there some other way? Or is there alternatively a chance for me to access the macOS system keychain from the UI test Swift code? Anyone having an idea? Please help!
2
0
1.4k
Nov ’20
DateIntervalFormatter with unexpected strings for some locales
I am currently facing a problem with DateIntevalFormatter. When using the formatter with dateStyle = .long and timeStyle = .none the string output for some locales is not in the expected formatting. While the output for locales like en_US, de_de or fr_fr is as expected, locales like zh_Hans, ja and ko is not consistent with the dateStyle = .long of a DateFormatter. Using the dateTemplate/setLocalizedDateFormatFromTemplate() with template MMMMddyyyy seems to provide a consistent output. Is that maybe a bug in DateIntervalFormatter? Here some exemplary output of the below Playground code: It seems that the forum is not accepting some of the Chinese, Korean or Japanese characters, therefore you can only find the actual output of below code as attachment. Code output import UIKit func printDate(starteDate: Date, endDate: Date, locale: Locale) { let interval = DateIntervalFormatter() interval.locale = locale interval.dateTemplate = "MMMMddyyyy" let formatter = DateFormatter() formatter.locale = locale formatter.setLocalizedDateFormatFromTemplate("MMMMddyyyy") print("Locale: \(locale), template: MMMMddyyyy") print("Interval = \(interval.string(from: starteDate, to: endDate))") print("Format = \(formatter.string(from: starteDate))") print("Locale: \(locale), dateStyle: long") interval.dateStyle = .long interval.timeStyle = .none formatter.dateStyle = .long formatter.timeStyle = .none print("Interval = \(interval.string(from: starteDate, to: endDate))") print("Format = \(formatter.string(from: starteDate))") } let date1 = DateComponents(calendar: Calendar(identifier: Calendar.Identifier.gregorian), timeZone: TimeZone(abbreviation: "UTC"), year: 2019, month: 12, day: 20).date let date2 = DateComponents(calendar: Calendar(identifier: Calendar.Identifier.gregorian), timeZone: TimeZone(abbreviation: "UTC"), year: 2019, month: 12, day: 22).date printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "en_US")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "de_de")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "zh-Hans")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "ko")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "ja"))
1
0
375
Jun ’23