Code Monkey home page Code Monkey logo

xcode-build-times's Introduction

Xcode build times

Have you ever wondered how much time a day you spend waiting for Xcode to do your builds? Wonder no more, this SwiftBar or xbar (the BitBar reboot) plugin shows the time wasted right in your menu bar!

Installation

You can use this plugin with Swiftbar or xbar (the BitBar reboot)

So first install SwiftBar or xbar (FYI: I am using SwiftBar, so some features are SwiftBar only)

On the first run select a directory you wish to use as your plugin directory, for example ~/SwiftBarPlugins.

If you are using macOS Monterey then you must install PHP, because it is not bundled in macOS anymore. E.g. from Homebrew: brew install php and you must have path to php executable in PATH variable.

Plugin installation

Download the xcodeBuildTimes.1m.php file from the sources folder in this repository and place it the plugin folder and make it executable.

You can do it manually or via terminal

cd ~/SwiftBarPlugins
curl https://raw.githubusercontent.com/matopeto/xcode-build-times/master/sources/xcodeBuildTimes.1m.php --output xcodeBuildTimes.1m.php
chmod +x xcodeBuildTimes.1m.php

Before the first usage of the plugin you must configure the plugin. Just run:

php xcodeBuildTimes.1m.php configure

If you now refresh xbar/SwiftBar data you should see the script being loaded.

Xcode setup

The final step is to make Xcode call the script on every build.

To do this open Preferences | Behaviors in Xcode and set the script to Run when the Build starts

fails

and succeeds

Optional setup

The script is called xcodeBuildTimes.1m.php so xbar/SwiftBar will refresh the data every minute. If you want to use a different refresh interval, just change the 1m in the script name to your desired interval.

You can find more info about the refresh intervals in the xbar/SwiftBar documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

xcode-build-times's People

Contributors

igorkulman avatar magauran avatar matopeto 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

xcode-build-times's Issues

Warning shown on first run

When you run the plugin for the first time and there is no data file yet, it should not show a warning. I would just show 0m so a warning is not the first thing a user sees.

Xcode not calling script

Hi @matopeto I'm having issues getting this working (had it working on a previous machine). I've narrowed it down to an issue with Xcode running the script. If I call it myself in terminal (php xcodeBuildTimes.1m.php start and php xcodeBuildTimes.1m.php success) it works (and records an entry in the .csv), but when I build via Xcode it's not getting executed for some reason. Here's a screenshot of my Xcode prefs which clearly shows it's there. Is there any additional debugging or logging I can do to figure out what's going on? Any recent issues you're aware of? Thank you! 🙏

Screen Shot 2022-03-17 at 12 00 52 PM

Rewrite from PHP

Because ine new macOS Monterey PHP will be removed, rewrite from PHP to other language, eg swift

Wrong data when two Project builds are overlapping

I started building Project 1 and while the build was in progress I started building Project 2. The result was a broken entry with wrong duration

"2020-04-28 14:11:08",1588083068,success,,itlwm.xcodepro

skewing the total and average build times quite significantly

Screenshot 2020-04-28 at 18 03 32

Monterey issues: Xcode error "Failed to launch script .... No such file or directory" or "php: bad interpreter" or "env: php: No such file or directory"

I create this issue because in macOS Monterey there is no PHP that can run this script.

If you have this problem and you want to use this plugin on Monterey you must

  1. install PHP

E.g. from Hombrew

brew install php
  1. Update/download the plugin to the latests version

If you are using https://github.com/swiftbar/SwiftBar and you are getting

env: php: No such file or directory

It is because $PATH is not correct for the plugin.

If your default shell is Zsh just go to Swiftbar Settings and switch Shell to the "Zsh"

⚠️ but there is another bug that xcode cannot run hombrew PHP (yet), it don't see homebrew bin folder in the PATH
If it is your problem you must now after plugin download change first line of plugin

from:

#!/usr/bin/env php or #!/usr/bin/php

to path where PHP is actually stored (you can determine it by run the command which php

#!/opt/homebrew/bin/php

I will resolve this issue later. Sorry for inconvenience.


If you don't want use this plugin anymore, just disable it in SwiftBar/Bitbar in settings, Remove from plugin directory and remove from Xcode Behaviours

Xcode -> Preferences -> Behaviors, and uncheck "Run" at the end of all the phases (oposite as is in the readme)

I maybe rewrite this plugin from PHP to other language, but maybe not. See #12 for updates :)

Handle local timezone

Now in data file is written only time without timezone (in UTC?) and duration. And we compute and show statisticts in default php timezone) So today's statistics is not always correct. For correct today's statistics use system timezone for compute and show statistics.

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.