Photo by Ricardo Gomez Angel on Unsplash

While working with protocols in swift, you might have written a type conforming to multiple protocols.
Here comes Protocol Composition a technique to combine multiple protocols into a single representation.

How it is written:



Printing logs is the most important while you are debugging. It becomes more challenging when there are different function calls involved in a feature you are debugging.
Most of the developers use random print statements to check how the code flow is behaving e.g.

print(“someFunction -> 1”)
print(“someFunction -> 2”)
and so on….

Here comes Literal Expression

Literal Expression is a source code representation of a value that can be of any possible types in Swift (Int, String, Floating-Point, Boolean, Array or dictionary etc.).

e.g. #file, #function, #line and there are many more.

Now, how to use it

Here I am taking just few basic examples that’ll help you in basic logging.

Bonus Point

When used as default-parameter, they have values of where they are evaluated i.e. the call-site

Thanks for reading.



XCode scans your all methods written in your test class and tests all which start with ‘test’.
You can be simply disabled just by adding anything before ‘test’.

For example: modify it like this ‘func xyztestBusinessLogic()’ and this test wouldn’t be picked by XCTest.