Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Duplicate symbols error when build with CocoaPods #43

Closed
maoesx opened this issue Oct 3, 2019 · 17 comments
Closed

Duplicate symbols error when build with CocoaPods #43

maoesx opened this issue Oct 3, 2019 · 17 comments

Comments

@maoesx
Copy link

maoesx commented Oct 3, 2019

Expected Behaviour

App should be successful build after link library and pod install

Actual Behaviour

Shows duplicate symbols error

Steps to Reproduce

npm install @adobe/react-native-acpcore
react-native link @adobe/react-native-acpcore
cd ios/ && pod install
cd .. && react-native run-ios

Platform and Version

Node v10.15.0
Npm 6.4.1
react-native-cli: 2.0.1
react-native: 0.59.3

Logs taken while reproducing problem

info duplicate symbol OBJC_CLASS$_ADBAlertViewController in:
/appPath/node_modules/@adobe/react-native-acpcore/ios/libs/libACPCore_iOS.a(ADBAlertHandler.o)
/appPath/Build/Products/Debug-iphonesimulator/libRNAdobeAnalytics.a(ADBMessageAlert.o)

duplicate symbol OBJC_METACLASS$_ADBAlertViewController in:
/appPath/node_modules/@adobe/react-native-acpcore/ios/libs/libACPCore_iOS.a(ADBAlertHandler.o)
/appPath/ios/build/BMAApp/Build/Products/Debug-iphonesimulator/libRNAdobeAnalytics.a(ADBMessageAlert.o)

info ld: 2 duplicate symbols for architecture x86_64

info clang: error:

info linker command failed with exit code 1 (use -v to see invocation)

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 3, 2019

@maoesx If you're using Cocoapods you shouldn't need to run react-native link @adobe/react-native-acpcore as it'll link the project twice. I'd recommend running react-native unlink @adobe/react-native-acpcore to unlink. If this works let me know and I'll update the README to be more specific.

@maoesx
Copy link
Author

maoesx commented Oct 3, 2019

I thought that too, so I tried run pod install without link @adobe/react-native-acpcore, I noticed that in the podfile the line "pod 'RCTACPCore', :path => '../node_modules/@adobe/react-native-acpcore'" was no longer there.

And if I continue run the app with
"import {ACPCore, ACPLifecycle, ACPIdentity, ACPSignal, ACPMobileLogLevel} from '@adobe/react-native-acpcore';"

initSDK(){
ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
...
}

it will claim "TypeError: Cannot read property 'setLogLevel' of undefined"

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 3, 2019

@maoesx I followed your reproduction steps and saw this log on RN 0.60.0 and got this log:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - @adobe/react-native-acpcore (to unlink run: "react-native unlink @adobe/react-native-acpcore")

I'm guessing 0.60.0 made auto linking more forgiving if you're already manually linked as I compiled without error.

The second error your posted TypeError: Cannot read property 'setLogLevel' of undefined sounds like the SDK isn't linked at that point.

I would suggest trying to remove @adobe/react-native-acpcore from your project, then re-install and skipping the react-native link command if you're using Cocoapods.

@maoesx
Copy link
Author

maoesx commented Oct 3, 2019

Tried these steps:

  1. remove @adobe/react-native-acpcore from node_modules
  2. npm install @adobe/react-native-acpcore
  3. cd ios && pod install
  4. react-native run-ios
    still seeing "TypeError: Cannot read property 'setLogLevel' of undefined" when I try to call ACPCore.setLogLevel

@nporter-adbe
Copy link
Contributor

@maoesx can you share your podfile (or some portion of it enough to run pod install)?

@maoesx
Copy link
Author

maoesx commented Oct 3, 2019

platform :ios, '10.0'

target 'BMAApp' do
rn_path = '../node_modules/react-native'
rn_maps_path = '../node_modules/react-native-maps'

# See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
pod 'React', path: rn_path, subspecs: [
  'Core',
  'CxxBridge',
  'DevSupport',
  'RCTActionSheet',
  'RCTAnimation',
  'RCTGeolocation',
  'RCTImage',
  'RCTLinkingIOS',
  'RCTNetwork',
  'RCTSettings',
  'RCTText',
  'RCTVibration',
  'RCTWebSocket',
]

pod 'Firebase/Core', '~> 5.20.1'
pod 'Firebase/Messaging', '~> 5.20.1'
pod 'GoogleMobileVision/BarcodeDetector'
pod 'Fabric', '~> 1.9.0'
pod 'Crashlytics', '~> 3.12.0'

# React Native third party dependencies podspecs
pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
# If you are using React Native <0.54, you will get the following error:
# "The name of the given podspec `GLog` doesn't match the expected one `glog`"
# Use the following line instead:
#pod 'GLog', :podspec => "#{rn_path}/third-party-podspecs/GLog.podspec"
pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

# react-native-maps dependencies
pod 'react-native-maps', path: rn_maps_path
# pod 'react-native-google-maps', path: rn_maps_path  # Uncomment this line if you want to support GoogleMaps on iOS
# pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
# pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS
pod 'react-native-passkit-wallet', :path => '../node_modules/react-native-passkit-wallet'

pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]

pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'

pod 'react-native-webview', :path => '../node_modules/react-native-webview'

pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'

pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

pod 'RNImageCropPicker', :path =>  '../node_modules/react-native-image-crop-picker'

end

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
# The following is needed to ensure the "archive" step works in XCode.
# It removes React & Yoga from the Pods project, as it is already included in the main project.
# Without this, you'd see errors when you archive like:
# "Multiple commands produce ... libReact.a"
# "Multiple commands produce ... libyoga.a"
targets_to_ignore = %w(React yoga)
if targets_to_ignore.include? target.name

    target.remove_from_project
  end
end

end

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 3, 2019

@maoesx I wasn't able to reproduce your issue with a new app running RN 0.59.3. Here are the steps I took:

react-native init gitissuedupe

cd ios && pod init

updated podfile with your podfile

ran pod install, ensured the app built, etc.

npm install @adobe/react-native-acpcore

react-native link @adobe/react-native-acpcore notice the line added in Podfile

cd ios && pod install notice RCTACPCore is installed

update App.js to include some SDK code

react-native run-ios app runs without issue.

I've created a repo with the app, hope this helps: https://github.com/nporter-adbe/gitissuedupe

@maoesx
Copy link
Author

maoesx commented Oct 3, 2019

Thank you for the effort, I notice you still run both react-native link @adobe/react-native-acpcore and pod install?

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 3, 2019

@maoesx Yeah, the react-native link command added RCTACPCore to the Podfile. Seems the README is correct to instruct the react-native link command even when using Cocoapods.

@maoesx
Copy link
Author

maoesx commented Oct 3, 2019

I'm able to run your demo flawlessly too, seems it's my local issue. Thanks a lot anyway.
For the README, I think you can go more spefic like CocoaPods users need an extra step to run pod install after the react-native link @adobe/react-native-acpcore.

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 3, 2019

@maoesx glad to hear the sample I provided built as expected. We have a note in the README to run pod install if you’re using Cocoapods, but I think I can improve the wording. Thanks for the feedback!

@samitha9125
Copy link

I'm getting 88 duplications in both acpcore and acpanalytics

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 18, 2019

@samitha9125 please post exact steps to replicate in a fresh app. You should not have duplicate symbols unless you have installed the SDK multiple times.

@samitha9125
Copy link

samitha9125 commented Oct 18, 2019

Sure. What I did was in my project,

  1. npm install @adobe/react-native-acpcore
  2. npm install @adobe/react-native-acpanalytics
  3. from my project folder, cd ios && pod install
  4. Ran project on Xcode.

This generated 88 duplicated files. Also after this issue, I did manual linking for both core and analytics and disabled autolinking with react-native.config.js . It built fine on debug but an error occured saying RCTBridgeModule.h is not found on release scheme.

Autolinking works perfectly and project builds without any issues when I removed acpcore and acpanalytics

@nporter-adbe
Copy link
Contributor

@samitha9125 what version of react native are you using?

@samitha9125
Copy link

@maoesx react native 0.61.2

@nporter-adbe
Copy link
Contributor

nporter-adbe commented Oct 18, 2019

@samitha9125 I am unable to reproduce your issue on 0.61.2. I created a fresh app that you can find here: https://github.com/nporter-adbe/dupeSymbols

I followed the steps provided and I can build and launch the app without error. Please ensure you have followed the install instructions correctly. It might be helpful to checkout the issues in the react native repo related to duplicate symbols for what might be causing this issue in your project: https://github.com/facebook/react-native/issues?utf8=%E2%9C%93&q=is%3Aissue+duplicate+symbols

This issue seems to fix a similar issue: facebook/react-native#25484

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants