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

Autolinking fails if android/app folder or Xcode project are missing #1054

Closed
tido64 opened this issue Mar 16, 2020 · 4 comments
Closed

Autolinking fails if android/app folder or Xcode project are missing #1054

tido64 opened this issue Mar 16, 2020 · 4 comments

Comments

@tido64
Copy link
Contributor

tido64 commented Mar 16, 2020

Environment

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 938.13 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.16.1 - /usr/local/opt/node@12/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/opt/node@12/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
  npmGlobalPackages:
    react-native-cli: 2.0.1

Description

In monorepos where packages are split by platform, react-native config is not able to populate projects because it makes assumptions on the folder structure of the package. For example, given a project like below:

my-component
└── packages
    ├── my-component-core
    │   ├── package.json
    │   └── src
    ├── my-component-android
    │   ├── build.gradle
    │   ├── package.json
    │   └── src
    └── my-component-ios
        ├── TestApp.xcworkspace
        ├── package.json
        └── src

The output of react-native config in my-component-android/-ios is currently:

{
  "..."
  "project": {
    "ios": null,
    "android": null
  }
}

This had no consequences up until 3.0, when autolinking started using it in #768. Autolinking is currently broken for repos with a different folder structure.

It is possible to work around this issue by adding a react-native.config.js with the following content:

module.exports = {
  project: {
    ios: {
      project: "ReactTestApp-Dummy.xcodeproj"
    }
  }
};

Reproducible Demo

Checkout this repo and branch: https://github.com/microsoft/react-native-test-app/tree/tido/autolink-fail-repro.

Then run the following:

cd example
yarn
pod install --project-directory=ios

Output:

% pod install --project-directory=ios

[!] Invalid `Podfile` file: undefined method `[]' for nil:NilClass.

 #  from /~/react-native-test-app/example/ios/Podfile:5
 #  -------------------------------------------
 #
 >  use_test_app! __dir__ do |target|
 #    case target
 #  -------------------------------------------

cc @arazabishov in case you need more Android details.

@tido64
Copy link
Contributor Author

tido64 commented Mar 16, 2020

Ping @alloy, @grabbou, @thymikee

@grabbou
Copy link
Member

grabbou commented Mar 18, 2020

Interesting, I would say that the expected and supported behaviour would be for react-native config to work within each folder, reporting either iOS or Android being present, depending on where we are.

Definitely to be fixed.

@grabbou grabbou added the bug Something isn't working label Mar 18, 2020
@grabbou grabbou added this to the 4.x milestone Mar 18, 2020
@grabbou
Copy link
Member

grabbou commented Mar 18, 2020

Okay, this is not a bug but a feature.

The new autolinking is based on top of the legacy link, which used to look for .xcodeproj in order to work.

This requirement is no longer valid for dependencies (they can just ship with a Podfile).

For projects, .xcodeproj or .xcworkspace is still required, but I guess you're working on a prototype for detached mode, where this will be provided by the 3rd party.

Either way, leaving that as a feature.

@grabbou grabbou added command: link feature request and removed bug Something isn't working bug report labels Mar 18, 2020
tido64 added a commit to tido64/react-native-cli that referenced this issue Jul 12, 2021
grabbou pushed a commit that referenced this issue Aug 5, 2021
* fix(platform-ios): fix `sourceDir` detection

See also #1054 and #1436.

Resolves #1435.

* yarn lint --fix
thymikee pushed a commit that referenced this issue Aug 5, 2021
* fix(platform-ios): fix `sourceDir` detection

See also #1054 and #1436.

Resolves #1435.

* yarn lint --fix
@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Nov 28, 2022
@tido64 tido64 closed this as completed Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants