- React-native-svg support was added for iOS
- JS methods can take arguments
(for all possible architectures, rename respectively after creation to prevent overwriting) xcodebuild -project RNSVG.xcodeproj -sdk iphonesimulator11.4 -arch x86_64 -configuration Debug clean build xcodebuild -project RNSVG.xcodeproj -sdk iphonesimulator11.4 -arch i386 -configuration Debug clean build Only these 2 architectures are available for debugging. Combine the above into one fat library file: lipo -create -output libRNSVG.Debug.a libRNSVG.iphonesimulator-x86_64-Debug.a libRNSVG.iphonesimulator-i386-Debug.a
xcodebuild -project RNSVG.xcodeproj -sdk iphoneos11.4 -arch arm64 -configuration Release clean build xcodebuild -project RNSVG.xcodeproj -sdk iphoneos11.4 -arch armv7 -configuration Release clean build Combine them all in one fat library: lipo -create -output libRNSVG.Release.a libRNSVG.iphoneos-arm64-Release.a libRNSVG.iphoneos-armv7-Release.a
-it must be exported in ApiDefinition.cs
yarn bundle-ios
yarn bundle-android
make callback work on JS
This project is inspired and based on https://github.com/cluxton/xamarin-react-native. Credits to him, for his good work! 👍
This example includes a working proof-of-concept for both Xamarin.Android and Xamarin.iOS. Also there are renderers for Xamarin.Forms.
This is mainly a proof-of-concept and a challange to make transitioning projects from Xamarin to react-native a lot easier.
To get startet just install the NuGet packages you need for your project. It depends on which project type you are dealing with. The version of the NuGet package indicates in which version of react-native is targeted. For example the version 1.0.**50** targets react-native ^0.50.0.
- Xamarin.Droid - https://www.nuget.org/packages/ReactNative.Droid/
- Xamarin.iOS - https://www.nuget.org/packages/ReactNative.iOS/
- Xamarin.iOS for Debugging (see notes in 1. Getting your hands dirty) https://www.nuget.org/packages/ReactNative.iOS.Debug/
- Xamarin.Forms.Droid - https://www.nuget.org/packages/ReactNative.Forms.Droid/
- Xamarin.Forms.iOS - https://www.nuget.org/packages/ReactNative.Forms.iOS/
(you can and should use the ReactNative.iOS.Debug package in exchange for ReactNative.iOS for debugging purposes)
There are a lot of react-native components which need native linking. This binding already contains a precompiled and linked version of react-native. In theroy every component which need native linking should work if bound to C# seperatly. Make sure it is referencing this base react-native binding.
To build the application you will first need to download React Native & build the static library for Xamarin to use.
It is crucial to understand, that since the library is compiled and linked statically you have to ship seperate *.dlls for release and debug. For example a release build of libReactNative.a won't contain the DevSupport tools. See the commands below on how you can change the build configuration.
After checking out the project run the following commands:
# inside of ./binding/ReactNative.iOS
# install all node dependencies
yarn install
# build static react native library and the binding
make build CONFIGURATION=Debug # or Release respectively (case sensitive), default: DebugThis will only work for debug builds. Run the following command and check that your javascript bundle is available on http://localhost:8081/index.bundle
If you deploy to a physical device make sure you update the url inside SampleApp.iOS/AppDelegate.cs with your local ip address, so that the device can reach the packager in your local network.
# inside of ./binding
# run react native packager
yarn startThis is recommended for release builds. You will need to update the javascript source inside samples/SampleApp.iOS/AppDelegate.cs or samples/SampleApp.Forms/Mainpage.xaml to the bundled asset.
# inside of ./binding
# bundle javascript to embeddable main.jsbundle
yarn bundle-iosAfter you have done this, you can open the project samples/SampleApp.sln and deploy it to a device or simulator.
After checking out the project run the following commands:
# inside of ./binding/ReactNative.Droid
# install all node dependencies
yarn install
# build the android binding
make buildThis is recommended for release builds.
# inside of ./binding/
# bundle javascript to embeddable index.android
yarn bundle-androidUsing the react packager is only possible once the app already started and loaded it's bundle from Assets/. See Known Issues.
This will only work for debug builds. Run the following command and check that your javascript bundle is available on http://localhost:8081/index.bundle
# inside of ./binding
# run react native packager
yarn startOpen the react dev support menu and Refresh the view or Enable hot reloading to check if everything works.
After you have done this, you can open the project samples/SampleApp.sln and deploy it to a device or simulator.
- The precompiled
ReactNative.Droidassembly references theSquare.Okiopackage. This will cause build errors in the DEXer build step if you are usingmodernhttpclient. This is becausemodernhttpclientships with its own prebundled version ofokhttp.- Workaround: You have to compile
ReactNative.Droidby yourself and remove the duplicated native references. Alternatively you can use a fork ofmodernhttpclientwhich does not embed its own version ofokhttp.
- Workaround: You have to compile
- The Android sample application does not initially load from the react packager. Or is this the intended behavior?
- Workaround: Instead you have to
yarn bundleand include theindex.android.bundlein the androidAssets/directory.
- Workaround: Instead you have to