Posts

How to use Sets in Swift?

Image
Set are basically a collection of items that aren’t ordered but are unique. Let's go over different operations/functions that Swift has when it comes to Sets. Creating a Set Initialize an empty set Sets  in swift are of a generic nature so they can hold any type if it conforms to Hashable Protocol. For the simplicity of this article, we will use String and Int. var fruits = Set<String>() Initialize a Set with elements We can also initialize a set with some default elements. var fruits:Set<String> = ["apple","mango","guava"] Initialize a Set with a capacity We can set a space pre-allocated for minimum number/capacity var fruits = Set<String>(minimumCapacity: 2) Inspecting a set Check for empty Since  Set  conforms to  Collection Protocol  we can use a check for isEmpty. var fruits = Set<String>() fruits.isEmpty //true Count We can easily get the number of elements in our  Set  by accessing the count property. var fruits:Set...

How to make iOS App Secure from Jailbroken Device?

Image
Thanks to the mobile era we have mobile apps for everything these days. Every business from a barbers shop to huge retailers has apps so that they can be closer to their customers. On one hand, we really leverage this convenience but on the other hand, there are risks of exposing a lot of confidential information while using these apps. And it becomes very vital when dealing with payments and other sensitive information. As a developer of these apps, it is our responsibility to put checks to make sure privacy and security are not compromised. Here is a  comprehensive list of security best practices . But this article focuses on detecting if an iOS device is jailbroken.  JailBroken detections techniques basically fall under these categories 1. File Extension Checks If a device is jailbroken, there are some files that exist in the system. One common file is Cydia. Let take a look at the code below how we would check for the existence of these files 2. URI Schemes iOS App all...

How to make iOS app secure from screenshot and recording?

Image
  Thanks to the mobile era we have mobile apps for everything these days. Every business from a barbers shop to huge retailers has apps so that they can be closer to their customers. On one hand, we really leverage this convenience but on the other hand, there are risks of exposing a lot of confidential information while using these apps. And it becomes very vital when dealing with payments and other sensitive information. As a developer of these apps, it is our responsibility to put checks to make sure privacy and security are not compromised. One of the ways is to detect/prevent screenshot and screen recording action and taken an action or inform the user to take appropriate action.  Use Cases Here are some use cases where screen capture and screen recording can expose sensitive information: 1. Login information can be recorded Any app that requires a login to get access to sensitive information. We need to make sure that only the intended person can log in. If screen record...

How to transfer your App from one Xcode Simulator to another

Image
Here is how the story began! I was asked by product team to run the app under development on their machines. Not all the members own the physical iOS device which obviously aren't cheap :D. As a developer I think everyone will agree with me that product teams in the company are always eager to get their hands on the project status in a tangible manner. And when it comes to a mobile app, eagerness is even more as everyone has a smart device in their pocket.  This was an interesting requirement so I set out to explore solutions. Since this would be used by non-developers my goal was to: Find a simplest solution which doesn't involve too much technicality Come up with an automated way to minimize the developer time in training and maintaining it.  After spending a lot of time searching on the internet Here are some options I found: Solution 1: Simply run the app from Xcode   Even though this option can work but has multiple complexities and dependencies Basic understanding o...