Tuesday, June 19, 2018

React Native - CFBundleIdentifier Does Not Exist

"CFBundleIdentifier Does Not Exist" (Image 1) - is a very common error faced by many React Native app developers. Especially who have old XCode and latest Rect Native. I spend almost a day to solve this problem. But did not find any solution. Then suddenly something clicks on my mind. I tried that trick and TADA this error is solved.


Image 1: CFBundleIdentifier Does Not Exist

The thing came to my mind was to downgrade the React Native. Now the question is how can I do it. Because I have already created the project. If I haven't then it won't be any problem. I will just create the project with " react-native init [project name] --version [react-native version] " (react-native init [project name] --version 0.52.0). After doing a little research I have found two ways to downgrade the React Native version.
  1. Delete react-native package link from your package.json file and then install the version of react-native which you wanted.
  2. Use npm code line to uninstall and re-install the new react-native in your project.

For the first method, open your package.json file. There you will find the react-native package with it's version under dependencies (Image 2). Erase it and save the file. For being on the safe side, delete package-lock.json file too. After that open the package.json file again and add  "react-native":"[RN version you want]" ("react-native":"0.52.0") under dependencies again. Save it and then run "npm install". It will take some time so just wait. After the successfull installation check your project's RN version run by writing "react-native -version"  (Image 3) in your terminal.  There you can see the version number. That's it now close the react packager and uninstall app from the simulator or from the device then run "react-native run-ios" and see the magic. The "CFBundleIdentifier Does Not Exist" will do not exist 😜
Image 2: React Native Version number under dependencies

Image 3: Checking React Native Version

Now let's talk about the second method. First of all, in your terminal run npm uninstall react-native.  Then try to check the version of react-native. It will show something like this " n/a - not inside a React Native project directory". After that run "npm install react-native@[version]" (npm install react-native@0.52.0) in terminal. Now the project will successfully run on the ios simulator. 


Now let me tell you the last trick if you don't want to do all these hassles. Just check your XCode version (Image 4). If it is not latest then update it. This error will be solved instantly. So why didn't I upgrade XCode latest version (still now is 9.4)?? Because in this XCode I can not collapse if-else block. So it gives me a huge headache.

Image 4: Old version of XCode

Coding is always fun.. if you like my post give me +1  😀

Color code use this post are

        - file name
        - command line
        - error
        - example

No comments:

Post a Comment