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 broken in 0.69 #2267

Closed
oblador opened this issue Jun 7, 2022 · 23 comments · Fixed by #2332 or getsentry/sentry-wizard#173
Closed

Autolinking broken in 0.69 #2267

oblador opened this issue Jun 7, 2022 · 23 comments · Fixed by #2332 or getsentry/sentry-wizard#173

Comments

@oblador
Copy link
Contributor

oblador commented Jun 7, 2022

Due to react-native-community/cli#1537 some things in your react-native.config.js have been deprecated and removed, thus failing autolinking schema validation (for example ios.sharedLibraries).

Steps to Reproduce

  1. Create a vanilla RN project with latest 0.69 RC with npx react-native init Example --version 0.69.0-rc.6.
  2. Add this package.
  3. Observe it not being autolinked.
@marandaneto
Copy link
Contributor

Thanks @oblador we will have a look at it.
Likely a side effect of #2226

@oblador
Copy link
Contributor Author

oblador commented Jun 7, 2022

@marandaneto no it's unrelated, it's because of the linked PR.

@renchap
Copy link

renchap commented Jun 21, 2022

I can confirm this.

After upgrading to the latest RN 0.69-rc6 version and running pod update, I get:

Downloading dependencies
Installing DoubleConversion 1.1.6
Installing FBLazyVector 0.69.0-rc.6 (was 0.68.2)
Installing FBReactNativeSpec 0.69.0-rc.6 (was 0.68.2)
Installing Flipper-DoubleConversion 3.2.0.1 (was 3.2.0)
Installing Flipper-Glog 0.5.0.5 (was 0.5.0.4)
Installing RCTRequired 0.69.0-rc.6 (was 0.68.2)
Installing RCTTypeSafety 0.69.0-rc.6 (was 0.68.2)
Installing RNReanimated 2.8.0
Installing React 0.69.0-rc.6 (was 0.68.2)
Installing React-Codegen 0.69.0-rc.6 (was 0.68.2)
Installing React-Core 0.69.0-rc.6 (was 0.68.2)
Installing React-CoreModules 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTActionSheet 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTAnimation 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTBlob 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTImage 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTLinking 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTNetwork 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTSettings 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTText 0.69.0-rc.6 (was 0.68.2)
Installing React-RCTVibration 0.69.0-rc.6 (was 0.68.2)
Installing React-bridging (0.69.0-rc.6)
Installing React-callinvoker 0.69.0-rc.6 (was 0.68.2)
Installing React-cxxreact 0.69.0-rc.6 (was 0.68.2)
Installing React-jsi 0.69.0-rc.6 (was 0.68.2)
Installing React-jsiexecutor 0.69.0-rc.6 (was 0.68.2)
Installing React-jsinspector 0.69.0-rc.6 (was 0.68.2)
Installing React-logger 0.69.0-rc.6 (was 0.68.2)
Installing React-perflogger 0.69.0-rc.6 (was 0.68.2)
Installing React-runtimeexecutor 0.69.0-rc.6 (was 0.68.2)
Installing ReactCommon 0.69.0-rc.6 (was 0.68.2)
Installing Yoga 1.14.0
Installing glog 0.3.5
Removing Sentry
Generating Pods project

Please note the Removing Sentry line.

And after the upgrade, there is no Sentry-related packages in my Podfile.lock.

As the OP said, this is most probably due to the removal of react-native link command and the refactor of auto-linking made in the PR mentioned above.

@kelset
Copy link

kelset commented Jun 22, 2022

@marandaneto just as an headsup, we are planning on releasing 0.69.0 this week

@marandaneto
Copy link
Contributor

marandaneto commented Jun 22, 2022

@marandaneto just as an headsup, we are planning on releasing 0.69.0 this week

We're going to look into this, thanks for the heads up.

Edit: maybe useful read: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
hooks were removed so there's a problem when doing this:

hooks: {
postlink:
'node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android',
postunlink:
'node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android --uninstall'
}

@lucas-zimerman
Copy link
Collaborator

lucas-zimerman commented Jun 22, 2022

Additionally, we need to remove the sharedLibraries from react-native.configs in order to allow the auto link to happen.
Or add a filter to not include those fields if running 0.69 or higher ( if that's possible)

Despite removing those fields, something is odd with Sentry CLI

image
Not sure which file or folder is missing.

@marandaneto
Copy link
Contributor

@lucas-zimerman iirc React Native has changed the way how it finds node, it could be related to that.
https://reactnative.dev/blog/2022/06/21/version-069#highlights-of-069

Addition of the new .xcode.env configuration file for more deterministically sourcing the node executable

@marandaneto
Copy link
Contributor

marandaneto commented Jun 23, 2022

sentry-wizard patches the xcode project file in order to be able to auto-upload debug symbols.
The default code script has changed https://github.com/facebook/react-native/blob/main/template/ios/HelloWorld.xcodeproj/project.pbxproj#L267=
and I guess that sentry-wizard is replacing its default react-native configuration, this could also be the culprit for sentry-cli to fail.

Edit: also facebook/react-native#33777 (comment)

@renchap
Copy link

renchap commented Jun 24, 2022

Another change for 0.69: when using XCode, there is now a .xcode.env file that allows you to set the proper environment variables for the bundle build step, for example $NODE_BINARY.

It comes with a react-native/scripts/xcode/with-environment.sh script that will set the env var, then call its argument.

The bundle build step becomes something like:

export SENTRY_PROPERTIES=sentry.properties
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export PROJECT_ROOT=$PWD/..
export NODE_MODULES_ROOT=$PROJECT_ROOT/../../node_modules

WITH_ENVIRONMENT="$NODE_MODULES_ROOT/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$NODE_MODULES_ROOT/react-native/scripts/react-native-xcode.sh"

$WITH_ENVIRONMENT $NODE_MODULES_ROOT/expo-constants/scripts/get-app-config-ios.sh
$WITH_ENVIRONMENT $NODE_MODULES_ROOT/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE

Unfortunately, this breaks @sentry/cli and I am not sure why:

Node found at: /Users/renchap/.nvm/versions/node/v16.14.0/bin/node # <== this is the first `with-environment.sh` call for expo-constants
Node found at: /Users/renchap/.nvm/versions/node/v16.14.0/bin/node # <== this is the second `with-environment.sh` call for sentry-cli
sentry-cli 1.74.4

Command line utility for Sentry.

This tool helps you manage remote resources on a Sentry server like
sourcemaps, debug symbols or releases.  Use `--help` on the subcommands
to learn more about them.

USAGE:
    sentry-cli <SUBCOMMAND>

OPTIONS:
        --api-key <API_KEY>          The given Sentry API key.
        --auth-token <AUTH_TOKEN>    Use the given Sentry auth token.
    -h, --help                       Print this help message.
        --log-level <LOG_LEVEL>      Set the log output verbosity. [possible values: trace, debug,
                                     info, warn, error]
        --url <URL>                  Fully qualified URL to the Sentry server.
                                     [defaults to https://sentry.io/]
    -V, --version                    Print version information.

SUBCOMMANDS:
    bash-hook          Prints out a bash script that does error handling.
    difutil            Locate or analyze debug information files.
    help               Prints this message or the help of the given subcommand(s)
    info               Print information about the Sentry server.
    issues             Manage issues in Sentry.
    login              Authenticate with the Sentry server.
    projects           Manage projects on Sentry.
    react-native       Upload build artifacts for react-native projects.
    releases           Manage releases on Sentry.
    repos              Manage repositories on Sentry.
    send-event         Send a manual event to Sentry.
    upload-dif         Upload debugging information files.
    upload-proguard    Upload ProGuard mapping files to a project.

I guess the CLI does not properly looks up its arguments, and as it is wrapped by with-environment.sh it tries to parse sentry-cli as an argument?

@marandaneto
Copy link
Contributor

marandaneto commented Jun 24, 2022

I'm currently working on a troubleshooting page with a workaround in order to unblock folks.
getsentry/sentry-docs#5208 -> preview
We'll work on a fix as soon as we know what has to be changed.

@ken0nek
Copy link

ken0nek commented Jun 24, 2022

Found an related issue => adjust/react_native_sdk#186

@matinzd
Copy link

matinzd commented Jun 25, 2022

I can verify that Sentry is being removed while running pod install on 0.69.0.

Installing FBLazyVector 0.69.0 (was 0.68.2)
Installing FBReactNativeSpec 0.69.0 (was 0.68.2)
Installing Flipper-DoubleConversion 3.2.0.1 (was 3.2.0)
Installing Flipper-Glog 0.5.0.5 (was 0.5.0.4)
Installing RCTRequired 0.69.0 (was 0.68.2)
Installing RCTTypeSafety 0.69.0 (was 0.68.2)
Installing RNReanimated 2.8.0
Installing React 0.69.0 (was 0.68.2)
Installing React-Codegen 0.69.0 (was 0.68.2)
Installing React-Core 0.69.0 (was 0.68.2)
Installing React-CoreModules 0.69.0 (was 0.68.2)
Installing React-RCTActionSheet 0.69.0 (was 0.68.2)
Installing React-RCTAnimation 0.69.0 (was 0.68.2)
Installing React-RCTBlob 0.69.0 (was 0.68.2)
Installing React-RCTImage 0.69.0 (was 0.68.2)
Installing React-RCTLinking 0.69.0 (was 0.68.2)
Installing React-RCTNetwork 0.69.0 (was 0.68.2)
Installing React-RCTSettings 0.69.0 (was 0.68.2)
Installing React-RCTText 0.69.0 (was 0.68.2)
Installing React-RCTVibration 0.69.0 (was 0.68.2)
Installing React-bridging (0.69.0)
Installing React-callinvoker 0.69.0 (was 0.68.2)
Installing React-cxxreact 0.69.0 (was 0.68.2)
Installing React-jsi 0.69.0 (was 0.68.2)
Installing React-jsiexecutor 0.69.0 (was 0.68.2)
Installing React-jsinspector 0.69.0 (was 0.68.2)
Installing React-logger 0.69.0 (was 0.68.2)
Installing React-perflogger 0.69.0 (was 0.68.2)
Installing React-runtimeexecutor 0.69.0 (was 0.68.2)
Installing ReactCommon 0.69.0 (was 0.68.2)
Installing Yoga 1.14.0
Installing react-native-render-html (6.3.4)
Removing Sentry

@marandaneto
Copy link
Contributor

marandaneto commented Jun 25, 2022

@matinzd for now there's a quick workaround:
https://docs.sentry.io/platforms/react-native/troubleshooting/#react-native-069-and-higher

Do that and install pods again.

@mysport12
Copy link

I was able to apply the patch for the react-native.config.js file as noted in the workaround.

However I simply added these two lines:

export SENTRY_PROPERTIES=sentry.properties
export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"

in the .xcode.env file and left the default shellScript in project.pbxproj

shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";

Everything seems happy so far....

@marandaneto
Copy link
Contributor

@mysport12 That's fine but if you do that and skip the sentry-cli part, you've to upload the bundle and source maps manually to Sentry, in this case, you don't even need the export SENTRY_PROPERTIES=sentry.properties either.

@ken0nek
Copy link

ken0nek commented Jun 30, 2022

It would be great if we can respect .xcode.env, keep WITH_ENVIRONMENT and also make sentry work. Will take a look.

@marandaneto
Copy link
Contributor

It would be great if we can respect .xcode.env, keep WITH_ENVIRONMENT and also make sentry work. Will take a look.

That's already possible, See docs getsentry/sentry-docs#5240

@ken0nek
Copy link

ken0nek commented Jul 1, 2022

Thank you so much for the info!

@jmz527
Copy link

jmz527 commented Jul 12, 2022

Hi there! Just checking on that status of this? Should I not wait and just go w/ the workaround?

@sunchanras
Copy link

Any update on release fix ?

@bruno-garcia
Copy link
Member

The patch from @marandaneto has been approved by @kamilogorek : getsentry/sentry-wizard#173 (review)

Manoel is back online tomorrow so we should see this patch merged, and a new release of sentry-wizard coming out soon. Sorry for the delay on this one folks.

@marandaneto
Copy link
Contributor

marandaneto commented Jul 21, 2022

I'll release a new version once https://github.com/getsentry/sentry-wizard 2.0.0 and #2332 gets released.

@marandaneto marandaneto reopened this Jul 21, 2022
@marandaneto
Copy link
Contributor

Going to be released as 5.0.0-alpha.0

@marandaneto marandaneto added this to the 5.0.0 milestone Aug 17, 2022
@getsentry getsentry locked and limited conversation to collaborators Aug 30, 2022
@kahest kahest unpinned this issue Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.