This is my first blog post in almost a month. I apologize if you have been following my blog posts more regularly than I have been updating it. Workload has been crazy since last few weeks which kept me much busy. But, here it goes
A Script to automate task of cloning iOS git repository with sample project and directly run it into simulator
I have been thinking about it for a while since each time I try to download an open source library from Github it takes ages to manually clone, compile and run it into appropriate simulator. (iPhone, iPad, Apple Watch et cetra)
Couple of weeks back I came up with the script which when provided few parameters such as URL of Github repo, name of simulator type to run project into, build config will automate these all tasks. At then end you will have a project running into your simulator.
In summary this script takes following parameters. Except for Git cloning URL other command line are optional. But I would strongly recommend for you to consider giving input of simulator type and iOS version you want to run project with.
Shell script performs following series of actions.
Input the clone URL and download a Git repo in the same directory as the script
Try to find a
.xcworkspacefile. Make sure this file does not belong to
Once suitable file is found we can be sure that the demo project for library lies under it
Try if current folder has
podfile. If yes we can be ascertain that we need to to
pod installin order to install required dependencies and use
.xcworkspacefile to view demo
podfiledoes not exist, then we can directly use
.xcodeprojto run the demo
Use command line tool to run the project and store the generated
.appfile under the umbrella of current folder
Once project has successfully run, use
ios-simplug-in to run this executable directly into simulator based on the device type passed.
An example of demo run of this script on random Github library is as follows
You can directly clone the script from Github Repository. If you run into any issues or have pull request, I would be happy to have a look at it.
In order to successfully run the project, make sure the project has at least one scheme. The scheme associated with demo should be marked as shared. (Schemes marked as private won't be recognized by the command line tool and will result in
project file not founderror)
Script has subtle bug where if the project has multiple
.xcodeprojfiles with more than one schemes where one of the schemes belongs to
frameworkand other belongs to actual demo project. It will sometimes try to run project with
.schemefile belonging to
frameworkwhich will not generate a valid
.appfile. (This is essentially true with swift project since developers try to ship them in the form of standard iOS frameworks)
Again, you can download this script from Github Repo. Of course script is not perfect. I will appreciate if you could find any bugs within it and let me know so that I can take quick and necessary action to fix them