loadsmart / rn-salesforce-chat

React Native wrapper for Salesforce SDK chat
MIT License
7 stars 10 forks source link

ADR 2: Implement Auto Linking #8

Closed pedrohperalta closed 3 years ago

pedrohperalta commented 4 years ago

Prior to RN 0.60, to use a library that is also a native module, we need to add the dependency to package.json and also link it to our native projects so that it is included in our native builds. This can be done either using react-native link <dependency name> or manually. As of React native 0.60+, the react-native cli was extracted out and maintained separately into the react-native-community/cli repo which had a major version update. This update eliminates the need for us to manually link the native libraries after adding them to package.json. However, there're some configurations we need to do in order for this to work properly.

Here's a good article I found that explains how to do it for Android, and it also contains a link to the iOS setup too.

lenoirzamboni commented 4 years ago

@pedrohperalta For autolinking works, both library and a project using a library need to have support for it. This article that you recommended explains how to setup autolinking for a project.

We almost have support for autolinking. To be able to support it, a library needs to use Gradle for Android and have a Podspec for iOS. We have both.

The only problem that is blocking us to have full support is a Salesforce Maven dependency on the Android side that also needs to be declared on the build.gradle of the project that is using our library.

This one:

maven {
   url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' 
}

If not declared, Gradle fails to find the Salesforce dependencies and a build error happens:

Could not find com.salesforce.service:chat-ui:4.1.1.
Searched in the following locations:
  - file:/Users/user/Library/Android/sdk/extras/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/.m2/repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/.m2/repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - https://dl.google.com/dl/android/maven2/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - https://dl.google.com/dl/android/maven2/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - https://jcenter.bintray.com/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - https://jcenter.bintray.com/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Workspace/rhodes/node_modules/react-native/android/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Workspace/rhodes/node_modules/react-native/android/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
Required by:
    project :app > project :@loadsmart_rn-salesforce-chat

But I am trying to find a fix for this.

vovkind commented 3 years ago

@pedrohperalta For autolinking works, both library and a project using a library need to have support for it. This article that you recommended explains how to setup autolinking for a project.

We almost have support for autolinking. To be able to support it, a library needs to use Gradle for Android and have a Podspec for iOS. We have both.

The only problem that is blocking us to have full support is a Salesforce Maven dependency on the Android side that also needs to be declared on the build.gradle of the project that is using our library.

This one:

maven {
   url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' 
}

If not declared, Gradle fails to find the Salesforce dependencies and a build error happens:

Could not find com.salesforce.service:chat-ui:4.1.1.
Searched in the following locations:
  - file:/Users/user/Library/Android/sdk/extras/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/.m2/repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/.m2/repository/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - https://dl.google.com/dl/android/maven2/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - https://dl.google.com/dl/android/maven2/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - https://jcenter.bintray.com/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - https://jcenter.bintray.com/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
  - file:/Users/user/Workspace/rhodes/node_modules/react-native/android/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.pom
  - file:/Users/user/Workspace/rhodes/node_modules/react-native/android/com/salesforce/service/chat-ui/4.1.1/chat-ui-4.1.1.jar
Required by:
    project :app > project :@loadsmart_rn-salesforce-chat

But I am trying to find a fix for this.

hi. Was it solved ins some way?

lenoirzamboni commented 3 years ago

@vovkind After some research, we found that there is no workaround for the Salesforce maven dependency declaration on the build.gradle. The user will be forced to manually add this to the project. Although this is blocking, we can still have all the other features of Auto Linking.

Closing issue.