Nine41/README.md

118 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

2020-04-12 14:55:23 +08:00
# Nine41 ![CI](https://github.com/jessesquires/Nine41/workflows/CI/badge.svg)
2019-10-01 09:15:10 +08:00
*Automate overriding the status bars for all running iOS simulators*
2021-09-19 05:30:15 +08:00
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjessesquires%2FNine41%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/jessesquires/Nine41) <br> [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjessesquires%2FNine41%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/jessesquires/Nine41)
2021-05-20 10:41:59 +08:00
![perfect status bar](https://raw.githubusercontent.com/jessesquires/Nine41/main/screenshot.png)
2019-10-01 09:15:10 +08:00
## About
Blog posts:
2020-04-14 06:51:46 +08:00
* [Fully automating perfect status bar overrides for iOS simulators with Nine41](https://www.jessesquires.com/blog/2020/04/13/fully-automating-perfect-status-bar-overrides-for-ios-simulators/)
2020-04-13 05:56:30 +08:00
* [A script to automate overriding iOS simulator status bar values](https://www.jessesquires.com/blog/2019/09/30/automating-simctl-status-bar/)
2020-04-14 06:51:46 +08:00
* [Overriding status bar display settings in the iOS simulator](https://www.jessesquires.com/blog/2019/09/26/overriding-status-bar-settings-ios-simulator/)
2019-10-01 09:15:10 +08:00
2020-04-13 00:16:17 +08:00
[Xcode 11](https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes) shipped with `simctl status_bar`, a tool to override the status bar values in the simulator so you can take perfect screenshots.
2019-10-01 09:15:10 +08:00
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
2020-04-13 01:19:43 +08:00
This script fixes most of those issues. It overrides the status bars for all currently running simulators using "Apple's defaults" &mdash; full cellular bars, full wifi bars, full battery, no "carrier" name, and `9:41` for the time.
2019-10-01 09:15:10 +08:00
2020-04-13 00:16:17 +08:00
## Requirements
- Swift 5.7+
- Xcode 14.0+
2020-04-13 00:16:17 +08:00
- [SwiftLint](https://github.com/realm/SwiftLint)
2020-04-14 06:58:59 +08:00
## Installation
### [Swift Package Manager](https://swift.org/package-manager/)
Add `Nine41` to the `dependencies` value of your `Package.swift`.
```swift
dependencies: [
2021-11-02 10:32:17 +08:00
.package(url: "https://github.com/jessesquires/Nine41.git", from: "2.0.0")
2020-04-14 06:58:59 +08:00
]
```
Alternatively, you can add the package [directly via Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).
2020-05-20 13:13:36 +08:00
### [CocoaPods](https://cocoapods.org)
```ruby
pod 'Nine41'
```
2020-04-13 01:55:28 +08:00
## Usage
After cloning the repo, you can create a custom bash command:
```bash
function nine41() {
swift run --package-path /PATH/TO/Nine41/
}
```
2020-04-13 05:56:30 +08:00
Then you can run this from the command line.
2020-04-13 01:55:28 +08:00
Example run with 2 open simulators:
```bash
$ nine41
Fixing status bars...
✅ iPhone 8, 65A6C323-E74D-452C-B85E-7F576259E022
✅ iPhone 11, 52E8FAD0-7743-4F85-AA2E-26E4C1275F38
```
Example run with no open simulators:
```bash
$ nine41
Fixing status bars...
❌ No simulators are running. Launch the iOS simulator first.
```
2020-04-14 06:58:59 +08:00
## Automation with Xcode build phases
As described [in this post](https://www.jessesquires.com/blog/2020/04/13/fully-automating-perfect-status-bar-overrides-for-ios-simulators/), 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:
2020-05-20 13:13:36 +08:00
For Swift Package Manager installations:
2020-04-14 06:58:59 +08:00
```bash
/usr/bin/xcrun --sdk macosx swift run --package-path "${BUILD_ROOT}/../../SourcePackages/checkouts/Nine41"
```
2020-05-20 13:13:36 +08:00
For CocoaPods installations:
```bash
/usr/bin/xcrun --sdk macosx swift "${PODS_ROOT}/Nine41/Sources/main.swift"
```
3. 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.
2020-04-14 06:58:59 +08:00
2020-01-21 11:02:55 +08:00
## Contributing
Interested in making contributions to this project? Please review the guides below.
- [Contributing Guidelines](https://github.com/jessesquires/.github/blob/master/CONTRIBUTING.md)
- [Code of Conduct](https://github.com/jessesquires/.github/blob/master/CODE_OF_CONDUCT.md)
- [Support and Help](https://github.com/jessesquires/.github/blob/master/SUPPORT.md)
- [Security Policy](https://github.com/jessesquires/.github/blob/master/SECURITY.md)
Also, consider [sponsoring this project](https://www.jessesquires.com/sponsor/) or [buying my apps](https://www.hexedbits.com)! :v:
2019-10-01 09:15:10 +08:00
## License
Released under an [MIT License](https://opensource.org/licenses/MIT). See `LICENSE` for details.
2020-04-13 05:56:30 +08:00
> **Copyright &copy; 2019-present Jesse Squires.**