react-native-macos
react-native-macos copied to clipboard
Consider to move all MacOS-related code into a separate folder
This will reduce an energy needed to syncing with upstream and simplify using react-native for MacOS and iOS at the same time.
Is this something which is still being considered? I believe this would also make it simpler to sync with updates to React Native itself and to possibly integrate Mac OS support into React Native in the future. Is that the case?
Is this something which is still being considered?
For now, using react-native and react-native-desktop at the same time is pretty straightforward.
integrate Mac OS support into React Native in the future
No, currently I don't see how it's possible. But I believe that in the future there is no point of forking React Native, it will just require writing a UI layer for its core to achieve the same goal, so this particular project is temporary.
Thanks @ptmt! Do you have any more information about the React Native support for additional UI layers?
Take a look at how Windows version works: https://github.com/ReactWindows/react-native-windows and consider the C++ core of RN itself. But surely, it's just a baby step, and not the most important task for RN right now.
Thanks, I'll take a look. I'm looking into using React Native as a core for a Mac OS app and I'm conscious that I want it to be a stable and upgradable base to work off.
Looking at the ReactWindows code, it seems that there are some key steps to moving towards this style of extending React Native rather than forking it for MacOS. There seem to me to be:
- Separate all the native MacOS code from the native iOS code. To start with this could be as simple as renaming the
Reactdirectory. We would however need to catch the code up to the latest 0.31 version to do this effectively. - Create a separate set of Javascript files for MacOS which include anything specific for the platform and any platform specific implementations of the core components.
- Have all of this packaged as a
react-native-macosmodule. - Create an rnpm plugin which allows the user to install to install the module and sets up a template for the MacOS project files with something like Yoman.
It seems like there is a good base to work off here in terms of the work you have done to support React Native on the platform. With this project structure, it would lead to the project being a lot more maintainable. Is this something you are looking to work towards in the future or would like help with?
You're right, it's a far away from ideal right now.
ReactWindows has most of the native code written in C#, though. It has a completely different native part, (like Android inside the RN) and requires a lot of efforts to write and maintain (dedicated team). They even use their own JavaScript engine ChakraCore. The problem with macOS version is that it's almost the same codebase. Maybe 5-10% difference. So to maintain it, it still requires reviewing a lot of changes from the original upstream repository, including ObjectiveC code, even if it's a separate folder (ReactMacOS). Or we just have to ignore all the bugfixes and new features coming from RN for iOS. And this 5-10% difference in the native part is widely spread all over the project because AppKit has some strange differences with UIKit. There is a good example of different Apple platform React Native for AppleTV. I'm not sure that it's possible for AppKit currently due to a lot more fundamental changes between platform.
That being said, I do not want to sound pessimistic and I willing to try to improve the things, including all steps that you described. The current plan is at least to migrate to react-native-macos namespace. Then I will sync to latest [email protected]. Need to think more about concrete plans, because there are also some critical features and bugs, and limited resources.
Yes, the AppleTV changes are a bit more superficially than we'd need to support for MacOS. I wonder if we could do something like only forking the Library and React directories using something like git subtree? I guess that's more of a problem for the future though.
I'm happy to help out and start the migration to the macos namespace.
If I begin using this project to write my application I will be able to help out more with bug fixes and feature improvements. I think however that it would be good to get the project in sync with React Native (to 0.32 like you said) before I start doing this. It would also to be useful to document the process you go through with syncing to allow others to help you out 👍