Synx — quick fixture for old / unmaintained XCode projects

Petro Korienev 🇺🇦
3 min readNov 20, 2018

--

IMPORTANT: SUPPORT UKRAINE NOW 🇺🇦

Please, spend few minutes reading through the website:

https://supportukrainenow.org/

Your help can save lives today!

This is an article #3 of “It’s all about Tools” cycle. So,

Recently I was given a task to analyze an iOS project and prepare descriptive documentation in order to estimate amount of work needed to prepare an Android clone. Despite it’s definitely not the best way to do the estimate, it was a quite insisting requirement to do an Android clone following iOS app architecture as close as possible — to let both apps be maintained predictably.

I started to look at the project and it seemed to be of quite regular structure (that’s very good so far):

The first thing I usually do is estimating complexity very empirically, by amount of code written. I use cloc (which is also simple yet powerful tool) for this:

machine_name:directory_name petr$ cloc TargetName
517 text files.
501 unique files.
105 files ignored.
github.com/AlDanial/cloc v 1.74 T=4.69 s (87.8 files/s, 10433.4 lines/s)
--------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------
Swift 333 7380 4814 34714
JSON 78 0 0 2025
C/C++ Header 1 2 5 1
--------------------------------------------------------------------
SUM: 412 7382 4819 36740
--------------------------------------------------------------------

Okay, 333 Swift files with 34714 SLOC. Next thing I’d like to show was a share of code between different app sections.

machine_name:directory_name petr$ cloc TargetName
0 text files.
0 unique files.
0 files ignored.
1 error:
Unable to read: TargetName/Screens
su-macbook-2e23:ios_for_sigma petr$

Weird, checking actual directory and see:

ls -la TargetName | wc -l
429

Gosh! Folder structure for project is absent — only XCode groups are in place. That’s not a situation which is easy to live with, but fortunately we have synx — an easy-to-use XCode project folder structure fix.

gem install synx # in case you did not yet
synx *.xcodeproj

Here we go!

ls -la TargetName | wc -l
44
cloc TargetName/Screens
22 text files.
22 unique files.
1 file ignored.
github.com/AlDanial/cloc v 1.74 T=0.20 s (105.1 files/s, 44861.2 lines/s)
--------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------
Swift 21 1420 572 6970
--------------------------------------------------------------------
SUM: 21 1420 572 6970
--------------------------------------------------------------------

We see 21 Swift file with 6970 SLOC for UIViewController subclasses, so it’s immediately easy to get an initial clue of UI sizing for the project.

I recommend using Synx regularly, especially if you can’t make sure that 100% of code on a project passes peer review OR you’d like to quickly organize “legacy” project. For the new projects, created from scratch in XCode it’s however not so relevant — XCode creates folders for groups now by default.

Thanks for reading and hope this helps 😃

--

--