-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Cannot get auto-linking to work #6024
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
Comments
CC @jonthysell |
Both Autolinking was added in RNW 0.63 and will only work on properly set-up native modules which target at least RNW 0.62. There were tooling and template upgrades in 0.62 to make this possible. I am currently in the process of updating the native module setup documentation to reflect the work necessary for a module to be detected by autolinking. In the meantime, see react-native-camera for an example of a windows implementation that supports 0.61, 0.62, and 0.63, with autolinking. |
@jonthysell thanks, that cleared some things for me. I've assumed that the React version used in the app must be 0.63 for the auto-linking to work. I'll take a look at react-native-camera implementation. |
Yes, the app must use RNW 0.63 in order for autolinking to run, and the native module's build files (vcxproj) must include certain target files to be detected, which only exist in RNW 0.62+. However, this is all just a limitation of the build files - it is completely possible for a native module to have one set of source files and support 0.61+. You just need to have (at least) one project for 0.61, and one project for 0.62+. That's what react-native-camera does. And an app developer targeting 0.61 will need to manually choose the first project, an app developer targeting 0.62 will have to manually choose the second project, and an app developer targeting 0.63 can just use autolinking. For further reference, here's the installation steps for react-native-camera: https://react-native-community.github.io/react-native-camera/docs/installation#windows Unfortunately so much has changed internally in RNW from 0.61 - 0.63, that we can't really backport autolinking. So this is the compromise. |
@jonthysell I have one more final question: if I want a module to support all RNW versions since 0.61, do I need 3 separate .sln files like the ones in react-native-camera? |
The solution files are only necessary for development and testing of the module itself. Apps developers won't consume them. If you want to test that your module can build successfully against 61, 62, and 63 directly within your repo, then yes you need multiple solution files. And you'll have to make sure you yarn install the correct versions of RN/RNW to build against. However, I don't know what your current build validation looks like - if you're only testing by building against 63 for android/ios, then maybe the extra solution files will just be confusing. |
I just want to make sure the modules I'm porting will support 0.61+ and autolinking. So, if I understand correctly I only need two vcxproj files - one for 0.61 and one for 0.62+. I also don't need any solution files in the module itself to make this work? |
Closing as resolved as the linked PR was merged. |
Cannot get autlonking to work. Tried both
react-native-webview
andreact-native-config
while porting it to Windows.Environment
Run the following in your terminal and copy the results here.
npx react-native --version
:4.13.0
npx react-native run-windows --info
:reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
:Steps To Reproduce
E.g. with the
react-native-webview
. Did the following to make a sample app:Modified
App.js
with the sample self-contained code:After running

npx react-native run-windows
it looks like the module is not autolinked. I get this error:Breaking the code inside
node-modules\react-native-webview
also does not break the build process.Running
npx react-native autolink-windows --logging
produces:Similarly, when autolinking my
react-native-config
I see it being detected with emptyprojects
andnugetPackages
values, and similarly, it does not get included in the build.Expected Results
It just works
The text was updated successfully, but these errors were encountered: