-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Also set date, which shows on iPad status bars #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tfe ! 💯 I really appreciate this.
Just a few minor comments. What do you think?
nine41.swift
Outdated
@@ -50,10 +50,10 @@ extension Process { | |||
/// Executes `xcrun simctl status_bar` on the specified device. | |||
/// | |||
/// - Parameter device: The device for which status bar values should be overridden. | |||
func xcrun_fix_status_bar(_ device: String) { | |||
func xcrun_fix_status_bar(_ device: String, time: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer having this just be a local var instead.
func xcrun_fix_status_bar(_ device: String) {
let time = // ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I actually tried that first but got some errors about running a Process inside another Process, so I had to break it out. But I'll try the Foundation date formatter instead which will solve this problem and that one.
nine41.swift
Outdated
let data = pipe.fileHandleForReading.readDataToEndOfFile() | ||
let output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String | ||
|
||
return output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just use Foundation's Date
and NSISO8601DateFormatter
?
that would be simpler and more familiar to folks who are likely to contribute to this project. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That... would make a ton of sense. I'm not an experienced iOS dev and was in a rush, so I just grabbed whatever was working from that Stack Overflow answer and didn't think much further about it. 🙃
I'll try that.
nine41.swift
Outdated
@@ -72,6 +88,9 @@ let json = (try! JSONSerialization.jsonObject(with: deviceData, options: [])) as | |||
let runtimes = json["devices"] as! Dictionary<String, Array<Any>> | |||
let allDevices = runtimes.values.flatMap { $0 } as! Array<Dictionary<String, AnyHashable>> | |||
|
|||
// 9:41 AM PT on Tuesday January 9, 2007 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 💯
Thanks for your patience. That was a really dumb way of doing it. 😬 This should be much better. |
@tfe No problem at all! 😄 We all have to learn some time. This is a great contribution. 💯 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇 very nice work @tfe !
I'll send you an invite to be a collaborator and have push access.
iPad status bars also show the date, so I wanted to set that to the appropriate date for 9:41am.
simctl
allows setting the date with thetime
arg, but it needs to be ISO format. That means the time we include in the ISO date string needs to be in the current time zone. So we need to get that at runtime from the system. Per this answer on SO we can get that from the system viadate
.This PR adds another function to shell out and get that magic date string, and passes it into
xcrun_fix_status_bar
for use as thetime
argument.This is what we get in the simulator: