React-native link only links to 1st Xcode target
See original GitHub issue- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Memory: 53.57 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.9.1 - ~/.nvm/versions/node/v8.9.1/bin/node Yarn: 1.3.2 - ~/.nvm/versions/node/v8.9.1/bin/yarn npm: 5.5.1 - ~/.nvm/versions/node/v8.9.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0 Android SDK: Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.1 API Levels: 22, 23, 24, 25, 26, 27, 28 IDEs: Android Studio: 3.1 AI-173.4819257 Xcode: 10.0/10A255 - /usr/bin/xcodebuild npmPackages: @types/react: ^16.4.14 => 16.4.18 @types/react-native: ^0.57.6 => 0.57.6 react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 react-native: 0.57.3 => 0.57.3 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-cli: 2.0.1 react-native: 0.50.3
Description
If you have multiple targets in Xcode, and try to link a new dependency with react-native link, it will only link for the first Xcode target.
This is a problem for us as I can already see the bugs being opened where one of the builds we distribute has bugs because of an unlinked dependency in the target.
The desired behaviour would be either one (or both) of the following:
react-native link
will link all targets by default- allow a
--target=""
flag for react-native link, so that each target can be linked via the cli
Reproducible Demo
- Create an ejected RN project
- Add a second target in Xcode
- Install a new project dependency and then run
react-native link
to link that dependency - Look at the Linked Frameworks & Libraries in Xcode under both targets. The new library will only be listed under your first target.
Note, this was opened in the past and has been auto-closed several times. https://github.com/facebook/react-native/issues/18503 https://github.com/facebook/react-native/issues/17381
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top GitHub Comments
I would just like to add a way to deal with library dependencies in Xcode that I use for every project that has more than 1 target.
Instead of duplicating the dependencies to each target, I create a single Cocoa Touch Library target (named base), to which I add all dependencies. Then that base target is added as a dependency to all other targets. It is a more DRY approach to dependencies in Xcode and works well with react-native link if you make sure the base target is the first one in the list.
Add this:
Make sure it’s at the top:
This target has your deps:
Your targets just have this list of deps:
Hope the base library approach helps you find that convenience back 😃
This approach would not work if we change the behaviour of
react-native link
to add it to each target. So I think it may be hard to foresee the impact of your proposed change on all the various Xcode project setups out there. People do things in different ways and assuming each target should have each dependency linked is dangerous.Is having more than 1 target really an “expert Xcode setup”. Are we saying that React Native should only provide abstractions for the most simple projects and anything more than that means go native and lose a ton of convenience? What is the downside to having a more powerful cli?
@bartolkaruza I would like to contribute although I was hoping that if was not too arduous a change that it’d be a lot faster and easier for an existing contributor. If it’s came up several times then there is demand out there and my goal was to reinforce that demand. I may look into it if needs must though.