question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Integrating into existing app: RCTJSCWrapper.h 'string' file not found

See original GitHub issue

I’m attempting to integrate a React Native component into an existing Swift app. I am following the instructions here: https://facebook.github.io/react-native/docs/embedded-app-ios.html

  1. The documentation is unclear on the steps to bridge the RN view to the Swift app. It says to create a ReactView.h, and then a ViewController.m, and then goes on to say “For Swift apps there is no need for that.” No need for what - the ViewController.m, the ReactView.h, or both??? Very poor wording.
  2. Either way, when I create a ReactView.swift file:
import UIKit
import React

class ReactView: UIView {

  let rootView: RCTRootView = RCTRootView(bundleURL: NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios"),
    moduleName: "SimpleApp", initialProperties: nil, launchOptions: nil)

  override func layoutSubviews() {
    super.layoutSubviews()

    loadReact()
  }

  func loadReact () {
        addSubview(rootView)
        rootView.frame = self.bounds
  }
}

And import it into a View in Xcode, when I build the project I get the following error:

RCTJSCWrapper.h: 'string' file not found ReactView.swift: Could not build Objective-C module 'React'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
alexeylangcommented, Jul 4, 2016

Alright, I’ve changed the API in https://github.com/facebook/react-native/commit/85983d0ae4fac0fc22048bd0d729cdc3ca755d91. Can you guys test it now?

1reaction
robhogancommented, Jul 4, 2016

I think more fundamentally this is because RCTJSCWrapper.h has a C++ dependency in the header itself (a typedef using std::string), effectively in React’s public API, which means the React module exposed by the Pod isn’t a valid Objective-C module and one result is that it can’t be imported by swift.

It looks like it ought to be straightforward to change this signature to a const char * and restore Objective-C compatibility (eg https://github.com/rh389/react-native/commit/013285bcace15ea8894a8f0fd0f22252e3b513b8), but I don’t well enough understand what this JSCWrapper is actually doing or what it’s for.

Looks like one for @alexeylang ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

#include <string> file not found in iOS in C++ file - Stack ...
Show activity on this post. It's a clean project, and I've just added the files from the old project.
Read more >
how to localize iOS apps with string examples - Lokalise
In this tutorial, we'll focus on enabling localization in your iOS application as well as adding, managing, and integrating translations in ...
Read more >
Using C and C++ in an iOS App with Objective-C++ - SitePoint
Developing cross-platform apps using C or C++ is possible with some careful planning. Despite Swift being open source, it's not yet fully ...
Read more >
New Obj-C Header File cannot import Frameworks
Hi,. I am in the middle of a building a Dropbox application and have already been set up the Framework and its working...
Read more >
iOS - PyTorch
HelloWorld is a simple image classification application that demonstrates how ... The PyTorch C++ library is available in Cocoapods, to integrate it to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found