Skip to content
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

auto link not happening for the package in react native windows #8227

Closed
ArunVenkat1994 opened this issue Jul 7, 2021 · 5 comments
Closed
Labels
bug Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) no-recent-activity Issue/PR has gone stale and may be closed (label applied by bot)

Comments

@ArunVenkat1994
Copy link

I have converted one package (react-native-fs) from older version into include few of my requirements.

When I include the package using package builder, it is linking properly.

using Microsoft.ReactNative;
using Microsoft.ReactNative.Managed;
using System.Linq;
using System.Reflection;

namespace Test
{
public partial class ReactPackageProvider : IReactPackageProvider
{
  public void CreatePackage(IReactPackageBuilder packageBuilder)
  {                      
    CreatePackageImplementation(packageBuilder);
    packageBuilder.AddViewManagers();
    packageBuilder.AddAttributedModules();
    packageBuilder.AddAttributedModules(Assembly.Load("RNFS"));
   }

   /// <summary>
  /// This method is implemented by the C# code generator
/// </summary>
partial void CreatePackageImplementation(IReactPackageBuilder packageBuilder);

private Assembly GetAssemblyByName(string name)
{
    var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
    var assemblyName = assemblies.FirstOrDefault(i => i.Name == name);
    var assembly = Assembly.Load(assemblyName);
    return assembly;
  }
 }
 }

But I try to auto link the package, it is not happening.

can anyone suggest an approach for this?

react-native autolink is not helping.

@asklar
Copy link
Member

asklar commented Jul 12, 2021

@ArunVenkat1994 can you clarify how the module was created?
The new "lib" template should put in the right information in the project file so that autolinking can pick it up. If you copied the project from an older one, it will likely not have the right Imports, etc. so that's why it may not be picked up.
See here for instructions on creating a module: https://microsoft.github.io/react-native-windows/docs/native-modules-setup#creating-a-new-native-module-library-project

@ghost ghost added the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Jul 12, 2021
@chrisglein chrisglein transferred this issue from microsoft/react-native-windows-samples Jul 12, 2021
@ArunVenkat1994
Copy link
Author

Hi @asklar,

The module is not newly created, we have taken older version of npm package - react-native-fs and converted.
Followed the steps like we have for native module development.
So it is more like an npm package. Right?
I guessed, auto linking should work for this.

@asklar
Copy link
Member

asklar commented Jul 14, 2021

I think the easiest would be to create a new module just so that it writes out the right project files (.vcxproj if C++, .csproj if C#), and then copy those over to your project, match the name to your module, etc.
@jonthysell fyi

@chrisglein
Copy link
Member

The module is not newly created, we have taken older version of npm package - react-native-fs and converted.

react-native-fs has an old windows implementation, the updated one is in PR. So that's likely a bad place to start with. Create it fresh and then you should be able to get autolinking. Let us know how that works out.

@chrisglein chrisglein added Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) bug and removed Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) labels Jul 15, 2021
@ghost ghost added the no-recent-activity Issue/PR has gone stale and may be closed (label applied by bot) label Jul 22, 2021
@ghost
Copy link

ghost commented Jul 22, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 14 days of this comment.

@ghost ghost closed this as completed Aug 5, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) no-recent-activity Issue/PR has gone stale and may be closed (label applied by bot)
Projects
None yet
Development

No branches or pull requests

3 participants