React Native compiling for Android -Beginner - react-native

I am a newbie to react native.
1.) I need to know if I can create a react native application and import it to Xcode, then add code in swift?
2.) I also need to know if the components I developed with swift can be compiled and run as a Android application?

Yes you can definitely do this, it's pretty common.
No, that swift code will not run on android
To help understand this, all UI code written in React Native is translated into corresponding native languages, everything else stays as Javascript.
Your Swift code cannot be translated back into Javascript that can then run on Android and certainly cannot be translated into Java.

Related

Bridging React Native and Swift Classes with Objective C

I am bridging React native and Swift Modules. I have completely done that. I am trying to add my existing IOS project and wanted to add in React Native.
For instance, When i create a new project for ReactNative. My Current Project become
ReactNative/ios
Now Is there any way to export the IOS project directly in the folder and make a reference to call from React Native ?
You can bridge native with react native. you can either import modules from either side or create buttons and shift your control to each side.
- You can create a button in RN and call Native module or complete project. please have look at this link
https://facebook.github.io/react-native/docs/communication-ios.html
Hope this helps. I will be most probably developing a project which allows you to bridge 2 apps by one button with complete documentation.

Use native components that not provided by RN team

Is there anyway to use native components that not provided by the RN team? For example UICollectionView?
Absolutely! It's a bit more work, but essentially what you will be doing is creating a Native Module, which is essentially what all the built-in React Native components are. Essentially, you need to create a bridge between Javascript and the native Objective-C (or Swift) code. You can also do this with components you build yourself in Objective C/Swift, not just the default native iOS ones.

Using React Native to run JavaScript code from an existing native app without having to display a component

The official documentation for React Native explains how to add React Native views to existing native applications. However, it does not explain how to run React Native code written in JavaScript from a native application, without having to display any React Native component. Does the framework provide a way to do this?
I think reason being, R-N works on top of Native components and not other way round. I have not come across anything that you are looking.

Is it possible to use code push when native code has changed?

If I add a package that requires changes in the native code, like MainActivity for android, is it still possible to use codepush to update the app?
I don't think that's possible, since code-push runtime on the device can only replace the javascript part and not the native parts.

Is there a way to convert cocos2d-x project working on iOS and Android to convert it to html without converting the code to JS?

I have completed a project which is completed on iOS and Android with all native code like in-app purchases and leaderboard completed. I want to convert that project into HTML 5 but without changing my C++ code to javascript and using the same resources. Is there any method/way to convert my code?
I was a native obj-c programmer who joined cocos2d-x porting from cocos2d-iphone. I have little/no knowledge of html or javascript.
If you want the resulting app to run within the browser, then no. There's no cocos2d variant that makes this possible. You would have to port the app to a completely different (but still C++) framework. See: How to build native C++ apps with HTML/CSS UI?
You can of course build a c++ app with cocos2d-x that presents a html5 view, but it won't run within the browser.