document autolinking setup for libraries with example app but no yarn workspaces
See original GitHub issueThis is a continuation of https://github.com/react-native-community/cli/issues/1100. While I’m able to build the react-native-community/datetimepicker
example project, autolinking of native modules does not work on android (didn’t try ios yet) 😩
EDIT: I’m not sure if it’s because of custom project.android.sourceDir, might be unrelated
It’s possible I’m doing something wrong (configuring the cli wrong). Using RN 0.62.2 and cli 4.8.0. My react-native-config.js
const root = process.cwd();
module.exports = {
dependencies: {
datetimepicker: {
root,
},
},
project: {
android: {
sourceDir: './example/android',
},
},
};
why autolinking does not work? It’s because the datetimepicker
dependency of the example project is not found by
it’s because the output of react-native config
is different based on where it’s executed from:
running `react-native config` from repo root
vojta@Vojta-MacBook-Pro datetimepicker (fix/ios-module-rn-62)*$ pwd
/Users/vojta/dev/_own/datetimepicker
vojta@Vojta-MacBook-Pro datetimepicker (fix/ios-module-rn-62)*$ node -e "console.log(require('react-native/cli').bin);"
/Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli/build/bin.js
vojta@Vojta-MacBook-Pro datetimepicker (fix/ios-module-rn-62)*$ /Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli/build/bin.js config
{
"root": "/Users/vojta/dev/_own/datetimepicker",
"reactNativePath": "/Users/vojta/dev/_own/datetimepicker/node_modules/react-native",
"dependencies": {
"datetimepicker": {
"root": "/Users/vojta/dev/_own/datetimepicker",
"name": "datetimepicker",
"platforms": {
"ios": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/ios",
"folder": "/Users/vojta/dev/_own/datetimepicker",
"pbxprojPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj/project.pbxproj",
"podfile": null,
"podspecPath": "/Users/vojta/dev/_own/datetimepicker/RNDateTimePicker.podspec",
"projectPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj",
"projectName": "RNDateTimePicker.xcodeproj",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
},
"android": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/android",
"folder": "/Users/vojta/dev/_own/datetimepicker",
"packageImportPath": "import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;",
"packageInstance": "new RNDateTimePickerPackage()"
}
},
"assets": [],
"hooks": {},
"params": []
}
},
"commands": [
...
],
"options": [
...
]
},
{
"name": "log-android",
"description": "starts logkitty"
},
{
"name": "run-android",
"description": "builds your app and starts it on a connected Android emulator or device",
"options": [
...
]
}
],
"assets": [],
"platforms": {
"ios": {},
"android": {}
},
"project": {
"ios": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/ios",
"folder": "/Users/vojta/dev/_own/datetimepicker",
"pbxprojPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj/project.pbxproj",
"podfile": null,
"podspecPath": "/Users/vojta/dev/_own/datetimepicker/RNDateTimePicker.podspec",
"projectPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj",
"projectName": "RNDateTimePicker.xcodeproj",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
},
"android": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/example/android",
"isFlat": true,
"folder": "/Users/vojta/dev/_own/datetimepicker",
"stringsPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/res/values/strings.xml",
"manifestPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/AndroidManifest.xml",
"buildGradlePath": "/Users/vojta/dev/_own/datetimepicker/example/android/build.gradle",
"settingsGradlePath": "/Users/vojta/dev/_own/datetimepicker/example/android/settings.gradle",
"assetsPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/assets",
"mainFilePath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/java/com/example/MainApplication.java",
"packageName": "com.example",
"packageFolder": "com/example",
"appName": "app"
}
}
}
running `react-native config` from /example
vojta@Vojta-MacBook-Pro android (fix/ios-module-rn-62)*$ pwd
/Users/vojta/dev/_own/datetimepicker/example/android
vojta@Vojta-MacBook-Pro android (fix/ios-module-rn-62)*$ node -e "console.log(require('react-native/cli').bin);"
/Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli/build/bin.js
vojta@Vojta-MacBook-Pro android (fix/ios-module-rn-62)*$ /Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli/build/bin.js config
{
"root": "/Users/vojta/dev/_own/datetimepicker",
"reactNativePath": "/Users/vojta/dev/_own/datetimepicker/node_modules/react-native",
"dependencies": {},
"commands": [
{
"name": "log-ios",
"description": "starts iOS device syslog tail"
},
{
"name": "run-ios",
"description": "builds your app and starts it on iOS simulator",
"examples": [
...
],
"options": [
...
]
},
{
"name": "log-android",
"description": "starts logkitty"
},
{
"name": "run-android",
"description": "builds your app and starts it on a connected Android emulator or device",
"options": [
...
]
}
],
"assets": [],
"platforms": {
"ios": {},
"android": {}
},
"project": {
"ios": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/ios",
"folder": "/Users/vojta/dev/_own/datetimepicker",
"pbxprojPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj/project.pbxproj",
"podfile": null,
"podspecPath": "/Users/vojta/dev/_own/datetimepicker/RNDateTimePicker.podspec",
"projectPath": "/Users/vojta/dev/_own/datetimepicker/ios/RNDateTimePicker.xcodeproj",
"projectName": "RNDateTimePicker.xcodeproj",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
},
"android": {
"sourceDir": "/Users/vojta/dev/_own/datetimepicker/example/android",
"isFlat": true,
"folder": "/Users/vojta/dev/_own/datetimepicker",
"stringsPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/res/values/strings.xml",
"manifestPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/AndroidManifest.xml",
"buildGradlePath": "/Users/vojta/dev/_own/datetimepicker/example/android/build.gradle",
"settingsGradlePath": "/Users/vojta/dev/_own/datetimepicker/example/android/settings.gradle",
"assetsPath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/assets",
"mainFilePath": "/Users/vojta/dev/_own/datetimepicker/example/android/app/src/main/java/com/example/MainApplication.java",
"packageName": "com.example",
"packageFolder": "com/example",
"appName": "app"
}
}
}
At this point, I’m not sure if this is a bug or a feature. 😄 How do I make this work? What is the right way to link a library with its example project? Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Great. It would be lovely to document this better. I’ll rephrase the issue and leave it open so we don’t forget. Thanks for the cooperation!
There hasn’t been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.