-
Install CocoaPods, here the installation guide.
-
Inside the iOS folder run
pod init
, this will create the initialpod
file. -
Update your
pod
file to look like the following ( Remember to replaceMyApp
with your target name ):# Allowed sources source 'https://github.com/CocoaPods/Specs.git' target 'MyApp' do # As we use Swift, ensure that `use_frameworks` is enabled. use_frameworks! # Specific iOS platform we are targetting platform :ios, '8.0' # Point to the installed version pod 'RNDateTimePicker', :path => '../node_modules/@react-native-community/datetimepicker/RNDateTimePicker.podspec' # React/React-Native specific pods pod 'React', :path => '../node_modules/react-native', :subspecs => [ 'Core', 'CxxBridge', # Include this for RN >= 0.47 'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43 'RCTText', 'RCTNetwork', 'RCTWebSocket', # Needed for debugging ] # Explicitly include Yoga if you are using RN >= 0.42.0 pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' # Third party deps podspec link pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' end
-
Run
pod install
inside the same folder where thepod
file was created -
npm run start
-
npm run start:ios
-
Add the following lines to
android/settings.gradle
:include ':@react-native-community_datetimepicker' project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')
-
Add the compile line to the dependencies in
android/app/build.gradle
:dependencies { ... implementation project(':@react-native-community_datetimepicker') }
-
Add the import and link the package in
MainApplication.java
:+ import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage; public class MainApplication extends Application implements ReactApplication { @Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: + packages.add(new RNDateTimePickerPackage()); return packages; } }
- Open the solution in Visual Studio 2019
- Right-click solution icon in Solution Explorer > Add > Existing Project Select 'D:\pathToYourApp\node_modules@react-native-community\datetimepicker\windows\DateTimePickerWindows\DateTimePickerWindows.vcxproj'
Add a reference to DateTimePickerWindows
to your main application project. From Visual Studio 2019:
Right-click main application project > Add > Reference... Check 'DateTimePickerWindows' from the 'Project > Solution' tab on the left.
Add #include "winrt/DateTimePicker.h"
.
Add PackageProviders().Append(winrt::DateTimePicker::ReactPackageProvider());
before InitializeComponent();
.