-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/windows autolinking #494
Feat/windows autolinking #494
Conversation
Hey @kaiguo , mind having a look here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to build fine with autolinking once you make the changes I've recommended.
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Label="ReactNativeWindowsProps"> | ||
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change $(MSBuildThisFileDirectory)
to $(SolutionDir)
as per newer recommendations: https://microsoft.github.io/react-native-windows/docs/native-modules-setup#cwinrt
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Label="ReactNativeWindowsProps"> | ||
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the main project, replace $(MSBuildThisFileDirectory)
with $(SolutionDir)
as per https://microsoft.github.io/react-native-windows/docs/0.61/native-modules-setup#1-fixing-relative-microsoftreactnative-project-paths
website/docs/Installation.md
Outdated
*Note:* For `Windows` the [manual linking](Linking.md) is currently the only linking option. | ||
#### Windows | ||
|
||
- **React Native Windows > 0.63** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RNW >= 0.63
@@ -1,6 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" /> | |||
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed one update from Microsoft.Windows.CppWinRT.2.0.190730.2
to Microsoft.Windows.CppWinRT.2.0.200316.3
here:
-<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" />
+<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props')" />
@@ -1,6 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" /> | |||
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't just update the Microsoft.Windows.CppWinRT version in the vcxproj, you also need to update the version in the packages.config
file in this folder for this to work properly.
- split .vcxproj and .sln files for compatibility with 0.63, 0.62 and 0.61 of react-native-windows - moved common files into code directory
- fixed incorrect versions of cppwinrt package - fixed typo in installation's docs - changed directory path from MSBuildThisFileDirectory to SolutionDir
308e199
to
12247d5
Compare
Thanks for review! I applied requested changes and rebased with commit from master |
@jonthysell Thanks for jumping in! Do you think it's ready to go? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @mateusz1913 @jonthysell , great to have auto-linking for windows in 👏
Hi. Sorry if this is a newbie question. But even after the commit I'm still not able to import the changes into my project when I run |
Generally I look at the Releases page (available from the home page of any repo). In this case it's this: https://github.com/react-native-async-storage/async-storage/releases |
🎉 This PR is included in version 1.13.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Hi, since version
react-native-windows
0.63 there is autolinking implemented (https://microsoft.github.io/react-native-windows/docs/native-modules-autolinking), but apparently windows implementation of this module is not recognized during autolinking process.In order to support autolinking for windows, implementation should be changed to support RNW 0.62 and RNW 0.63+ according to (microsoft/react-native-windows#6024 (comment)) - react-native-camera and react-native-config modules are examples with windows implementation that supports autolinking.
In this PR, I have changed structure of windows implementation to support detecting project and solution files for autolinking mechanism on RNW 0.63 and also updated installation and manual linking docs.
Closes #490
Test Plan
Create react-native project with react-native-windows 0.63 version, install async-storage module without manual linking and run project (you can clone https://github.com/mateusz1913/rnwindowstest repo where I set up everything already)