LoginSignup
0
0

More than 3 years have passed since last update.

React NativeでのXcodeBuild時のduplicateエラーの解消方法

Last updated at Posted at 2019-10-29

概要

普段はReact NativeでiOSアプリを開発してます
今回は、react-native-google-mapsなどの導入により、ReactやYogaなどをpod installした際Xcodeでbuildするとduplicateエラーが出る問題を解決するメモを共有します


platform :ios, '9.0'
target 'Your App Name' do
 pod 'Yoga', :path => '../node_modules/react- native/ReactCommon/yoga'

 pod "React", :path =>  '../node_modules/react-native', :subspecs => [
     "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "BatchedBridge"
  ]

  pod 'GoogleMaps'
  pod 'react-native-maps', path: '../node_modules/react-native-maps' 
  pod 'react-native-google-maps', path: '../node_modules/react-native-maps' 

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
  end
end

上記のようなpodfileでpod installをすると下記のようなエラーが出ます

ld: warning: directory not found for option '-L/Directory/Your/App/name'
duplicate symbol _OBJC_CLASS_$_RCTVibration in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libReact.a(RCTVibration.o)
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libRCTVibration.a(RCTVibration.o)
duplicate symbol _OBJC_METACLASS_$_RCTVibration in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libReact.a(RCTVibration.o)
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libRCTVibration.a(RCTVibration.o)
duplicate symbol _OBJC_CLASS_$_RCTFrameAnimation in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libReact.a(RCTFrameAnimation.o)
~~~中略~~~
duplicate symbol _OBJC_METACLASS_$_RCTWebSocketModule in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libReact.a(RCTWebSocketModule.o)
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libRCTWebSocket.a(RCTWebSocketModule.o)
duplicate symbol _OBJC_CLASS_$_PodsDummy_Yoga in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libYoga.a(Yoga-dummy.o)
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libyoga.a(Yoga-dummy.o)
duplicate symbol _OBJC_METACLASS_$_PodsDummy_Yoga in:
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libYoga.a(Yoga-dummy.o)
    /Directory/Your/App/NameBuild/Intermediates.noindex/ArchiveIntermediates/yourappname/BuildProductsPath/Release-iphoneos/libyoga.a(Yoga-dummy.o)
ld: 421 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解決

pod install時にReactとYogaがpodでインストールされてしまっているので、workspaceから開いてpodプロジェクトを選択する
スクリーンショット 2019-10-29 18.24.28.png
ReactとYogaがあるので
下画像のようにReactとYogaをTargetから取り除く
スクリーンショット 2019-10-29 18.16.58.png

これでduplicateが出なくなるのでbuildが正常に行えるようになります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0