React Native can be weird sometimes.

You want to debug your RN app locally in a simulator and your bundler is running locally, but you might see this error:

Quick Fix

Here’s the quick fix if you are in a hurry and don’t want to clean things.

Find your ipaddress of your local machine:

$ ipconfig getifaddr en0
192.168.1.3

Search for `RCTBundleURLProvider.m` file in XCode and modify the following method:

- (NSString *)guessPackagerHost{ //Add this line - replace IP Address with your IP Address
return
@”192.168.1.3";

This should unblock you. We’ll talk about how RN handles this in another post.


If you’re investing in foreign equity, you’ll need to file ITR-2 irrespective of your income.

How to activate Schedule FA

Go to Part B- TTI, see section number 19. Once you mark this as Yes , schedule FA will be enabled.

Activate Schedule-FA

How to fill Schedule FA

Assumption: There are no other financial assets outside India except foreign equity.


You can download Java Utility from this page

Instructions

Instructions on using Java utility

After you download the zip file, extract the file containing the utilities. You’ll see multiple files inside the folder

ITR 
ITR.bat
ITR_UTILITY.log
Readme.txt
ITR.sh
ITR-2_AY202021_PR3.1.jar
ITR_UTILITY.log.lck

How to run the JAR file:

If you already have java installed, you’ll most likely see the following error when you try to run the JAR file.

//Inside folder ITR-2_2020$ java -jar ITR-2_AY202021_PR3.1.jar
Error: Could not find or load main class
com.itd.efiling.itr.main.ctrl.ThreeRedLightsIlluminate
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

This happens because only Java Runtime Version 8 is supported. More specifically, only version 8u51 is supported.

You can download JAVA version 8u51 from…


If you are using React Native for mobile, there’s a lot to gain from sharing codebase between mobile and web.

If your setup is straightforward and you just want to share one folder between web and mobile, you can refer to my previous post of sharing codebase.

However, you’ll see such setup in practice rarely. Most likely, you’ll have multiple packages or libraries in your monorepo and some of those will be shared across web and mobile.

Lerna is a great tool to manage your multiple JS/TS projects in a single codebase.

Using lerna for React Native is slightly tricky…


You might have encountered a use case where you want to hide a view but don’t want to remove it from the view hierarchy.

You can achieve this simply by making the view transparent by toggling opacity .

opacity: 0 //Fully transparent
opacity: 1 //Fully Opaque

But there’s a catch. This transparent or hidden view can still be target of touch events which is not ideal.

Here’s a handy trick to disable all touch events on this transparent view. You can utilize pointerEvents prop of the view to enable/disable touch events.

//Hidden view
.box-hidden {
opacity: 0;
pointer-events: none;
}
//Visible view
.box-visible {
opacity: 1;
pointer-events: auto;
}

Docs: https://facebook.github.io/react-native/docs/view.html#pointerevents


There will be many use cases of where you’ll want to import any file outside of the root directory e.g. you may want to share code with your web project.

A simple solution could be to create a symlink inside the root directory but metro bundler doesn’t support symlink. So we’re going to see how to directly reference any file outside of root directory..

Consider this example:

common
- components
- Utils.ts, ....code
web
- node_modules
- ....code
app
- node_modules
- src/
- ...code, metro.config.js, rn-cli.config.js, etc...

Let’s say you want to access common/ from within app/ :

//Project/app/src/App.js


Prettier

Install this plugin and you won’t ever have to worry about formatting issues. You might have experienced formatting inconsistencies, merge conflicts and non-intentional code changes while working in a team. Sharing a common config file for prettier across your team helps mitigate all those issues.

Vim

If you like to take all your vim bindings to your IDE, this vim plugin just works.

GitLens — Git supercharged

This is a really helpful git plugin when you are working on a changing codebase with multiple collaborators. The best thing about this plugin is it doesn’t get in your way, it’s just there to help you.


Getting character at a specific position

let str = "Swift"//from start
var posFromStart = 1
var index = str.index(str.startIndex, offsetBy:posFromStart)
var c = str[index] // "w"
//from end
var posFromEnd = 1
index = str.index(str.startIndex, offsetBy:posFromStart)
c = str[index] // "f"

Iterate over a string

Option 1: If you only need to iterate over the characters

let str = "Swift"//String in swift is a collection of characters
for c in str {
print("Character \(c)")
}

Option 2: If you need to iterate with both index and character

let str = "Swift"for (i, c) in str.enumerated() {
print("Character at index \(i): \(c)")
}

Option 3: If you need…


UITableView requires auto layout to specify the height because there’s intrinsic content size doesn’t define the height.

We would like to modify this behaviour to be able to do something like this (Demo project on Github):

Once you have self sizing tableView, it’s very convenient to use them inside vertical stack views.

Self Sized Table View

Here TableView’s intrinsic content size adjusts the height to show all the rows. There’s one attribute named maxHeight to limit the height. Once maxHeight is achieved, adding more rows to the table view doesn’t result in height increase.

Here’s the swift recipe:

How to use it?

  1. After adding a table view…


While working on your iOS app, you’ll most likely come across the need to implement a container view controller - some view in ParentViewController getting its content from ChildViewController.

There are two ways to setup container view controller in your iOS app.

Using Code

Container View in ParentVC

This the standard approach to do initialize child view controller into the container view inside ParentViewController.swift.

override func viewDidLoad() {
super.viewDidLoad()

guard let childVC = self.storyboard?.instantiateViewController(withIdentifier: "ChildViewController") as? ChildViewController else {
return
}
addChildViewController(childVC)
//Or, you could add auto layout constraint instead of relying on AutoResizing contraints
childVC.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]…

Dushyant Bansal

Mobile @Thoughtspot. Previously @ Facebook, GoGoVan. Founder of http://www.publisherbox.in/ Read more about me: https://www.linkedin.com/in/dushyant37/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store