[iOS] Integrating into existing app: RCTJSCWrapper.h 'string' file not found
See original GitHub issueI’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
- 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.
- 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:
- Created 7 years ago
- Reactions:11
- Comments:15 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Alright, I’ve changed the API in https://github.com/facebook/react-native/commit/85983d0ae4fac0fc22048bd0d729cdc3ca755d91. Can you guys test it now?
I think more fundamentally this is because
RCTJSCWrapper.h
has a C++ dependency in the header itself (a typedef usingstd::string
), effectively in React’s public API, which means theReact
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 ?