Git Product home page Git Product logo

nine41's Introduction

Nine41 CI

Automate overriding the status bars for all running iOS simulators


perfect status bar

About

Blog posts:

Xcode 11 shipped with simctl status_bar, a tool to override the status bar values in the simulator so you can take perfect screenshots.

However, it has some issues:

  • The overrides do not persist across launches of the simulator
  • The numerous override options are difficult to remember
  • There are no sensible defaults

This script fixes most of those issues. It overrides the status bars for all currently running simulators using "Apple's defaults" — full cellular bars, full wifi bars, full battery, no "carrier" name, and 9:41 for the time.

Requirements

  • Swift 5.9+
  • Xcode 15.0+

Installation

Add Nine41 to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/jessesquires/Nine41.git", from: "3.0.0")
]

Alternatively, you can add the package directly via Xcode.

pod 'Nine41'

Usage

After cloning the repo, you can create a custom bash command:

function nine41() {
  swift run --package-path /PATH/TO/Nine41/
}

Then you can run this from the command line.

Example run with 2 open simulators:

$ nine41
Fixing status bars...
✅ iPhone 8, 65A6C323-E74D-452C-B85E-7F576259E022
✅ iPhone 11, 52E8FAD0-7743-4F85-AA2E-26E4C1275F38

Example run with no open simulators:

$ nine41
Fixing status bars...
❌ No simulators are running. Launch the iOS simulator first.

Automation with Xcode build phases

As described in this post, you can automate your perfect status bars using Xcode build phases.

  1. Add the Swift package to your Xcode project
  2. Add a "Run Script" build phase with the following:

For Swift Package Manager installations:

/usr/bin/xcrun --sdk macosx swift run --package-path "${BUILD_ROOT}/../../SourcePackages/checkouts/Nine41"

For CocoaPods installations:

/usr/bin/xcrun --sdk macosx swift "${PODS_ROOT}/Nine41/Sources/main.swift"
  1. Build and run. Note that simulators must be booted for the script to work, which means the very first run may not produce results but the subsequent runs will.

Contributing

Interested in making contributions to this project? Please review the guides below.

Also, consider sponsoring this project or buying my apps! ✌️

License

Released under an MIT License. See LICENSE for details.

Copyright © 2019-present Jesse Squires.

nine41's People

Contributors

dependabot[bot] avatar jessesquires avatar ricsantos avatar tfe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nine41's Issues

self.waitUntilExit() hangs

Thank you so much for giving us this - really useful!
Most of the time (for me) the script hangs on self.waitUntilExit() . I'm running macOS 10.15.4 (19E287) and Xcode Version 11.4.1 (11E503a). I moved the let data = pipe.fileHandleForReading.readDataToEndOfFile() to just before the waitUntilExit() and everything seems to work just fine. Isn't this the prefered order?

"Invalid argument" error for `--time` value in Xcode 15.3

An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Simulator device failed to complete the requested operation.
Invalid argument
Underlying error (domain=NSPOSIXErrorDomain, code=22):
	Invalid, non-ISO date/time string
	Invalid argument

We are providing a valid ISO date/time string, but it now expects to have fractional seconds. 🤦🏼‍♂️

Show "9:41" in other timezones

The resulting time of "9:41" on iPhone simulators is shown in Pacific Time Zone. As a developer who wants to take screenshots in Eastern Time Zone, it shows 12:41. As a temporary solution I had to manually subtract 3 * 3600 from the hard-coded time in main.swift.

Update date-time for iPad simulators based on iPad release dates

Ok, #4 got me curious about what the specific date should be for iPad.

After browsing through all the images on the various iPad and iPhone product pages, it turns out that Apple marketing materials appear to always use:

  • 9:41 for iPhone status bar. And they never display the lock screen with a date. (We already knew this.)

  • 9:41 AM is also used for iPads, but their status bars now also display a date since iOS 13 (or 12?). This date is always the release date of the device.

So, what would be cool is to make our script choose the correct date for each iPad simulator. We can simplify by just using the latest devices, so we would only need dates for: [iPad Pro, iPad Air, iPad, iPad Mini].

Implementation notes

I think the only way to determine this precisely is from the simulator name + iOS version? If we can't determine the actual device, then we can fallback to one of: (1) the existing date we are using (first iPhone launch), (2) the date for the very first iPad, or (3) the date of the most recently release iPad. Not sure which is better.

A list of all devices and release dates:
https://en.wikipedia.org/wiki/List_of_iOS_devices

Script hangs

The line self.waitUntilExit() hangs the script in my case. I had to comment it out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.