aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

iOS - build fails due to duplicate symbols (JKBigInteger and JKBigDecimal) in @aws-amplify/react-native and amazon-cognito-identity-js #12808

Closed jstarmx closed 8 months ago

jstarmx commented 9 months ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Not applicable

Amplify Version

v6

Amplify Categories

Not applicable

Backend

None

Environment information

``` # Put output below this line System: OS: macOS 14.2.1 CPU: (11) arm64 Apple M3 Pro Memory: 211.06 MB / 36.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.15.0 - ~/.asdf/installs/nodejs/16.15.0/bin/node npm: 8.5.5 - ~/.asdf/plugins/nodejs/shims/npm Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 120.0.6099.129 Edge: 120.0.2210.121 Safari: 17.2.1 npmPackages: @apollo/client: ^3.4.17 => 3.8.8 @apollo/client/cache: undefined () @apollo/client/core: undefined () @apollo/client/dev: undefined () @apollo/client/errors: undefined () @apollo/client/link/batch: undefined () @apollo/client/link/batch-http: undefined () @apollo/client/link/context: undefined () @apollo/client/link/core: undefined () @apollo/client/link/error: undefined () @apollo/client/link/http: undefined () @apollo/client/link/persisted-queries: undefined () @apollo/client/link/remove-typename: undefined () @apollo/client/link/retry: undefined () @apollo/client/link/schema: undefined () @apollo/client/link/subscriptions: undefined () @apollo/client/link/utils: undefined () @apollo/client/link/ws: undefined () @apollo/client/react: undefined () @apollo/client/react/components: undefined () @apollo/client/react/context: undefined () @apollo/client/react/hoc: undefined () @apollo/client/react/hooks: undefined () @apollo/client/react/parser: undefined () @apollo/client/react/ssr: undefined () @apollo/client/testing: undefined () @apollo/client/testing/core: undefined () @apollo/client/utilities: undefined () @apollo/client/utilities/globals: undefined () @aws-amplify/react-native: ^1.0.10 => 1.0.10 @babel/core: ^7.20.0 => 7.23.7 @babel/plugin-proposal-class-properties: ^7.2.3 => 7.18.6 @babel/plugin-proposal-decorators: ^7.2.3 => 7.23.7 @babel/plugin-transform-flow-strip-types: ^7.2.3 => 7.23.3 @babel/preset-env: ^7.20.0 => 7.23.7 @babel/preset-flow: ^7.0.0 => 7.23.3 @babel/runtime: ^7.20.0 => 7.23.7 @doc-abode/data-models: ^1.89.0 => 1.99.0 @faker-js/faker: ^8.0.2 => 8.3.1 @notifee/react-native: ^7.0.0 => 7.8.2 @react-native-async-storage/async-storage: ^1.18.1 => 1.21.0 @react-native-community/cli-platform-android: ^6.3.0 => 10.2.0 @react-native-community/eslint-config: ^3.2.0 => 3.2.0 @react-native-community/geolocation: ^3.0.6 => 3.1.0 @react-native-community/netinfo: ^9.3.9 => 9.5.0 @react-native-community/push-notification-ios: ^1.2.0 => 1.11.0 @react-native-firebase/analytics: ^14.12.0 => 14.12.0 @react-native-firebase/app: ^14.12.0 => 14.12.0 @react-native-firebase/messaging: ^14.12.0 => 14.12.0 @react-native-picker/picker: ^2.4.10 => 2.6.1 (1.16.8) @react-navigation/bottom-tabs: ^6.0.7 => 6.5.11 @react-navigation/material-top-tabs: ^6.0.4 => 6.6.5 @react-navigation/native: ^6.0.8 => 6.1.9 @react-navigation/stack: ^6.2.0 => 6.3.20 @rnx-kit/align-deps: ^2.2.2 => 2.3.2 @sentry/react-native: ^5.5.0 => 5.15.2 @testing-library/react-native: ^12.1.3 => 12.4.3 @tsconfig/react-native: ^2.0.2 => 2.0.3 @types/jest: ^29.2.1 => 29.5.11 @types/react: ^18.0.24 => 18.2.47 @types/react-test-renderer: ^18.0.0 => 18.0.7 HelloWorld: 0.0.1 amazon-cognito-identity-js: ^6.2.0 => 6.3.9 amazon-cognito-identity-js/internals: undefined () appcenter: ^4.4.5 => 4.4.5 appcenter-analytics: ^4.4.5 => 4.4.5 appcenter-crashes: ^4.4.5 => 4.4.5 aws-amplify: ^5.2.5 => 5.3.14 babel-jest: ^29.2.1 => 29.7.0 babel-plugin-transform-inline-environment-variables: ^0.4.3 => 0.4.4 countdown: ^2.6.0 => 2.6.0 dotenv: ^16.0.3 => 16.3.1 es6-symbol: ^3.1.1 => 3.1.3 eslint: ^8.21.0 => 8.56.0 eslint-plugin-prettier: ^4.2.1 => 4.2.1 firebase-ios-sdk: ^5.7.1 => 5.7.1 geolib: ^3.3.1 => 3.3.4 geolocationexample: 0.0.0 graphql: ^16.6.0 => 16.8.1 (15.8.0) husky: ^4.2.3 => 4.3.8 jail-monkey: ^2.8.0 => 2.8.0 jest: ^29.2.1 => 29.7.0 jest-watch-typeahead: ^0.6.0 => 0.6.5 jetifier: ^1.6.8 => 1.6.8 libphonenumber-js: ^1.9.3 => 1.10.53 libphonenumber-js/build: undefined () libphonenumber-js/core: undefined () libphonenumber-js/max: undefined () libphonenumber-js/max/metadata: undefined () libphonenumber-js/min: undefined () libphonenumber-js/min/metadata: undefined () libphonenumber-js/mobile: undefined () libphonenumber-js/mobile/examples: undefined () libphonenumber-js/mobile/metadata: undefined () lint-staged: ^10.0.7 => 10.5.4 lodash: ^4.17.19 => 4.17.21 metro-react-native-babel-preset: ^0.73.7 => 0.73.10 mobx: ^5.1.0 => 5.15.7 mobx-react: ^6.3.1 => 6.3.1 mockdate: ^3.0.5 => 3.0.5 moment: ^2.23.0 => 2.30.1 patch-package: ^6.2.2 => 6.5.1 prettier: ^2.4.1 => 2.8.8 react: 18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 react-native: ^0.71.0 => 0.71.14 react-native-autocomplete-input: ^5.3.2 => 5.4.0 react-native-biometrics: ^3.0.1 => 3.0.1 react-native-calendars: ^1.1274.0 => 1.1303.0 react-native-clean-project: ^4.0.1 => 4.0.3 react-native-code-push: ^8.0.1 => 8.1.1 react-native-date-picker: ^4.2.12 => 4.3.5 react-native-device-info: ^10.6.0 => 10.12.0 (0.9.9, 10.3.0) react-native-elements: ^3.4.3 => 3.4.3 react-native-extended-stylesheet: ^0.12.0 => 0.12.0 react-native-fontawesome: ^6.0.1 => 6.0.1 react-native-gesture-handler: ^2.9.0 => 2.14.0 react-native-icon-badge: ^1.1.3 => 1.1.3 react-native-inappbrowser-reborn: ^3.7.0 => 3.7.0 react-native-intent-launcher-module: 0.2.1 => 0.2.1 react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5 react-native-keychain: ^8.1.1 => 8.1.2 react-native-markdown-display: ^6.1.6 => 6.1.6 react-native-open-maps: ^0.3.2 => 0.3.6 react-native-pager-view: ^5.4.25 => 5.4.25 react-native-phone-call: ^1.0.9 => 1.2.0 react-native-picker-select: ^8.0.4 => 8.1.0 react-native-port-patcher: ^1.0.3 => 1.0.5 react-native-reanimated: ^3.1.0 => 3.6.1 react-native-safe-area-context: ^4.4.1 => 4.8.2 react-native-screens: ^3.22.0 => 3.29.0 react-native-securerandom: ^1.0.1 => 1.0.1 react-native-sha256: ^1.4.9 => 1.4.9 react-native-tab-view: ^3.1.1 => 3.5.2 react-native-vector-icons: ^9.2.0 => 9.2.0 react-native-version: ^4.0.0 => 4.0.0 react-test-renderer: 18.2.0 => 18.2.0 regenerator-runtime: ^0.13.9 => 0.13.11 (0.14.1) sp-react-native-in-app-updates: ^1.3.1 => 1.3.1 toggle-switch-react-native: ^3.3.0 => 3.3.0 typescript: 4.8.4 => 4.8.4 npmGlobalPackages: corepack: 0.10.0 npm: 8.5.5 react-native-cli: 2.0.1 ```

Describe the bug

After installing the @aws-amplify/react-native package, running an iOS build in XCode fails with a duplicate symbols error, specifically JKBigInteger and JKBigDecimal.

I've tried cleaning everything I can - Pods, Podfile.lock, node_modules, caches, derived data, build folder. From a completely clean slate (as far as I can tell) the error still reproduces.

Expected behavior

Build should succeed without error.

Reproduction steps

  1. Run npm install with the below package.json
  2. Run Pod install
  3. Attempt to build the app using XCode

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line duplicate symbol '_OBJC_IVAR_$_JKBigDecimal.bigInteger' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigDecimal.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigDecimal.o) duplicate symbol '_OBJC_CLASS_$_JKBigDecimal' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigDecimal.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigDecimal.o) duplicate symbol '_OBJC_METACLASS_$_JKBigDecimal' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigDecimal.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigDecimal.o) duplicate symbol '_OBJC_IVAR_$_JKBigDecimal.figure' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigDecimal.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigDecimal.o) duplicate symbol '_OBJC_CLASS_$_JKBigInteger' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigInteger.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigInteger.o) duplicate symbol '_OBJC_METACLASS_$_JKBigInteger' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigInteger.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigInteger.o) duplicate symbol '_OBJC_IVAR_$_JKBigInteger.m_value' in: /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/AmplifyRTNCore/libAmplifyRTNCore.a(JKBigInteger.o) /Users/james/Library/Developer/Xcode/DerivedData/DocAbodeHcpApp-ezzaefpfhklsirbaqniqqmglvzko/Build/Products/Debug-iphonesimulator/RNAWSCognito/libRNAWSCognito.a(JKBigInteger.o) ld: 7 duplicate symbols for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

jj2020driver commented 8 months ago

I had amazon-cognito-identity-js package as a dependency in package.json.

Solution was to remove this dependency, clean everything as usual (modules, lock file, build folder in xcode) and install again npm install aws-amplify@6 @aws-amplify/react-native @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values

After this no duplicated symbols appeared.

Upd: This is actually mentioned in docs 'To upgrade React Native projects that do not utilize aws-amplify-react-native, remove amazon-cognito-identity-js from the project package.json and install @aws-amplify/react-native.'

Hsami-96 commented 8 months ago

I had amazon-cognito-identity-js package as a dependency in package.json.

Solution was to remove this dependency, clean everything as usual (modules, lock file, build folder in xcode) and install again npm install aws-amplify@6 @aws-amplify/react-native @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values

After this no duplicated symbols appeared.

Upd: This is actually mentioned in docs 'To upgrade React Native projects that do not utilize aws-amplify-react-native, remove amazon-cognito-identity-js from the project package.json and install @aws-amplify/react-native.'

This worked for me 🙌

douglasrosa0110 commented 8 months ago

Me too. Thank you so much @jj2020driver

alejandromb commented 8 months ago

for me too, it went under the hood migrating from 5 to 6 ...thanks!!!!

nadetastic commented 8 months ago

Hi @jstarmx thank you for opening this issue. Have you had a chance to try @jj2020driver solution and see if this is resolved for you?

@jj2020driver thank you for sharing the fix!

jstarmx commented 8 months ago

@nadetastic yes that works, thanks and also to @jj2020driver

The docs need updating as they instruct you to install amazon-cognito-identity-js alongside @aws-amplify/react-native. https://ui.docs.amplify.aws/react-native/connected-components/authenticator#step-2-install-dependencies

Is there somewhere I can raise a PR?

nadetastic commented 8 months ago

@jstarmx thanks for the feedback! The documentation has been updated. I'll go ahead and close out this issue for now, but let me know if you have any addtional questions.

eedeebee commented 7 months ago

Does this mean it's impossible to use AWSAmplify UI and the cognito JS in the same react native project? I'm tryinf to use both because AmplifyUI doesn't seem to have the ability to get signin details from the currently signed in user reliably and the docs more or less suggest using the cognito js library for that. Thanks for any help!