Fixing “:CFBundleIdentifier, Does Not Exist” Error in React Native iOS build

After spending a couple of hours trying to debug this issue, I thought I would write about the solution that worked for me. Here are some of the possible solutions I found on the web –

  1. Make sure 8081 port is free and not taken by any application. On Mac you can check this by running command lsof -i :8081. If any process is running then kill it – kill -9 <pid>
  2. Remove spaces from the folder path of the project
  3. Run react-native upgrade in the project folder

In my case the problem was #1. However simple lsof command did not show any process. But sudo lsof -i :8081did show the process. It turned out that McAfee agent was running on the same port. Killing the agent is not an option for me. So the next thing to do was find a way to change the port of Ract-Native packager.

Following steps worked for me –

  1. Opne node_modules/react-native/local-cli/server/server.js and change port 8081 to the port you want to run the packager on. In the version of React-Native I am using, it is in the following code –
    module.exports = {
      name: 'start',
      func: server,
      description: 'starts the webserver',
      options: [{
        command: '--port [number]',
        default: 8090,
        parse: (val: string) => Number(val),
      },
    
  2. Change references to port 8081 in following files –
    1. node_modules/react-native/Libraries/Core/Devtools/getDevServer.js
    2. node_modules/react-native/React/React.xcodeproj
    3. node_modules/react-native/React/ReactLegacy.xcodeproj
    4. node_modules/react-native/React/Base/RCTBundleURLProvider.m

If above changes do not fix the problem, you may want to try replacing all references to port 8081 in the files in node_modules/react-native folder.

Wish Facebook makes changing packaging port easier than the above process.

-Ram Kulkarni

Framework for interacting with embedded WebView in iOS application

Last year around the same time I had written a post about Calling Objective-C code from JavaScript in iOS applications . I created a simple framework for it and described how to use it in that post.

Recently I was working on an application that required WebView to be embedded in the same View Controller along with other native iOS controls. I decided to use the above framework, but knew that  my ViewController class will have to extend WebViewController class of the framework. Though I could have done that, I thought separating the functionality of UIWebViewDelegate from the WebViewController would be a better design. So I replaced WebViewController with WebViewDelegate which implements UIWebViewDelegate protocol. I also removed getInitialPageName method from WebViewInterface.h . So here are the files in the new framework – Continue reading “Framework for interacting with embedded WebView in iOS application”

Using iOS Native Views in PhoneGap Projects

I am working on an iOS application where I want to use PhoneGap as well as a native iOS View. I want iOS view to be the first page from which user can navigate to a view created by PhoneGap. I have developed iOS applications either completely using PhoneGap or native APIs, but never tried to use both in the same application. So figuring out how to do that took some time and I thought I would share that here.

By the way, if you want to embed PhoneGap WebView into existing iOS project then follow instructions at Embedding WebViews. In this post I am going to explain how to embed native iOS view into a PhoneGap project and set it as the initial page.

First you create a PhoneGap project. I created the project using Command Line Interface of PhoneGap 3.1. Go to the folder where you want to create the project and run following command (I am assuming project name to be iOSPhoneGapProject here)

$ phonegap create iOSPhoneGapProject ram.kulkarni.iOSPhoneGapProject iOSPhoneGapApp

Continue reading “Using iOS Native Views in PhoneGap Projects”

Calling Objective-C code from JavaScript in iOS applications

In the last post I described how to Create iOS Application with HTML User Interface . In this post I am going to describe how to access Objective-C code from JavaScript running in the WebView. It is not as easy as it is in Android. There is no direct API in UIWebView to call native code, unlike in Android which provides WebView.addJavascriptInterface function.

However, there is a work-around. We can intercept each URL before it is being loaded in the WebView. So to call the native code, we will have to construct a URL and pass method name and argument as part of the URL. We then set this URL to window.location in the JavaScript and intercept it in our ViewController.
However most examples I have seen (including PhoneGap) create an instance of iframe and set its source to the URL –
Continue reading “Calling Objective-C code from JavaScript in iOS applications”

Creating iOS Application with HTML User Interface

Last year in April, I experimented with iOS development for the first time. I have described details in this post. I wanted to spend more time learning iOS application development then, however could not get around to actually doing that till very recently.

I had written a blog post on creating Android application using HTML user interface back in March last year. I was curious to know how to do the same in an iOS application.  In this post I will describe how to embed web view and set a URL in an iOS app and in the next post I would describe how to access native Objective-C code from JavaScript running in the web view control.

Continue reading “Creating iOS Application with HTML User Interface”

Using PhoneGap Media APIs

Last week I blogged about a problem I was facing when recording audio on iOS, using PhoneGap Media APIs. I was seeing following error in the debug console –

ERROR: Method ‘create:withDict:’ not defined in Plugin ‘Media’

and audio was not recorded.

I logged a bug for this in the PhoneGap’s bug tracker, and it turned out that it was not really a bug in PhoneGap. The PhoneGap team responded quickly (thanks Filip and Shazron) and guided me to the solution.
The solution is in fact documented on the PhoneGap API Reference site, but it is easy to miss.This is what I learnt –

Continue reading “Using PhoneGap Media APIs”

My Experiment with iOS Development

Last week I decided to experiment with iOS development. When I had started out learning Android development, it was not very difficult. Android programs are written in Java, which I have been using for many years and IDE used for Android development is Eclipse, which I have been using for many years now. All I had to get familiar was Android APIs.

However iOS development is very different for me. Applications are written in Objective-C, IDE is Xcode and they have to be developed on Mac platform using Cocoa framework. I have no experience with Objective-C, Xcode and Cocoa framework and have used Mac very little, only when I had to debug ColdFusion Builder issues specific to Mac. So I was not expecting smooth sailing; and I was not disappointed.
Continue reading “My Experiment with iOS Development”

Social