Ionic-framework: ios **BUILD FAILED ** duplicate symbols for architecture x86_64

Created on 20 Sep 2017  ·  19Comments  ·  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
After an undefined period of time, my app can't build for ios devices anymore.

Expected behavior:
It should be able to build for ios devices.

Steps to reproduce:
I have no Idea how this happens

Related code:
This is what I get when trying to build for ios

> cordova build ios
✖ Running command - failed!
[ERROR] An error occurred while running cordova build ios (exit code 1):


        (truncated) ... licate symbol _OBJC_IVAR_$_UNIHTTPStringResponse._body in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-6AE7BF574F7FD89D.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-ACD8B349DA1366AA.o
        duplicate symbol _OBJC_CLASS_$_UNIHTTPStringResponse in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-6AE7BF574F7FD89D.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-ACD8B349DA1366AA.o
        duplicate symbol _OBJC_METACLASS_$_UNIHTTPStringResponse in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-6AE7BF574F7FD89D.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIHTTPStringResponse-ACD8B349DA1366AA.o
        duplicate symbol _OBJC_IVAR_$_UNIJsonNode._array in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-7600CC35AA339D64.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-B9FEAECE639D8883.o
        duplicate symbol _OBJC_IVAR_$_UNIJsonNode._object in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-7600CC35AA339D64.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-B9FEAECE639D8883.o
        duplicate symbol _OBJC_CLASS_$_UNIJsonNode in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-7600CC35AA339D64.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-B9FEAECE639D8883.o
        duplicate symbol _OBJC_METACLASS_$_UNIJsonNode in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-7600CC35AA339D64.o

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/UNIJsonNode-B9FEAECE639D8883.o
        duplicate symbol _OBJC_CLASS_$_CDVLogger in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/CDVLogger.o

        /Applications/XAMPP/xamppfiles/htdocs/LVDLV/clone_new/lvdlv/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
        duplicate symbol _OBJC_METACLASS_$_CDVLogger in:

        /Users/Alexandre/Library/Developer/Xcode/DerivedData/ShOroom-egyzqumtqhesmlcsgwngozvucwss/Build/Intermediates/ShOroom.build/Debug-iphonesimulator/ShOroom.build/Objects-normal/x86_64/CDVLogger.o

        /Applications/XAMPP/xamppfiles/htdocs/LVDLV/clone_new/lvdlv/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
        ld: 260 duplicate symbols for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)

        ** BUILD FAILED **


        The following build commands failed:
                Ld build/emulator/ShOroom.app/ShOroom normal x86_64
        (1 failure)
        Error: Error code 65 for command: xcodebuild with args: 
        -xcconfig,/Applications/XAMPP/xamppfiles/htdocs/LVDLV/clone_new/lvdlv/platforms/ios/cordova/build-debug.xcconfig,-workspace,ShOroom.xcworkspace,-scheme,ShOroom,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS 
        Simulator,name=iPhone 
        SE,build,CONFIGURATION_BUILD_DIR=/Applications/XAMPP/xamppfiles/htdocs/LVDLV/clone_new/lvdlv/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Applications/XAMPP/xamppfiles/htdocs/LVDLV/clone_new/lvdlv/platforms/ios/build/sharedpch

Other information:
It's the second time this happens to me, after the first time I had to create an ionic project from scratch and slowly integrate what was in the original project and building for ios after each iteration in order to detect the problem. A few hours later and the code copied in its entirety, I was somehow able to build for ios.
Tried to build for ios this morning and I'm still getting the same issue [see related code section].
Also tried to delete my /plugins & /node_modules directories but it did not help.
Could not find anything on the web to help me neither..

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

cli packages:
    @ionic/cli-utils  : 1.10.2
    ionic (Ionic CLI) : 3.10.3

global packages:
    Cordova CLI : 7.0.1

local packages:
    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.1

System:
    ios-deploy : 1.9.1
    ios-sim    : 6.0.0
    Node       : v6.11.0
    npm        : 3.10.10
    OS         : OS X El Capitan
    Xcode      : Xcode 8.2.1 Build version 8C1002
reply

Most helpful comment

Try remove plugin console and try again, I had the same issues. But I have Cordova ios 4.5

The problem is CDVLogger that is already in cordova cli 7

Cc @kensodemann

All 19 comments

Hello! Thank you for opening an issue with us!

I cannot duplicate your error, which makes total sense because as you say, it generally works and then mysteriously stops. So... let's start with some versions of things:

I am using Xcode 9, what version are you using?
I am using cordova-ios version 4.4.0, which looks the same as what you are using...

Hmmmm... I am going to try a couple of things

Hey @kensodemann , I am currently on Xcode Version 8.2.1

Thank you!

Try remove plugin console and try again, I had the same issues. But I have Cordova ios 4.5

The problem is CDVLogger that is already in cordova cli 7

Cc @kensodemann

Duplicated it and fixed it, though I am not entirely sure this is your issue, but worth a shot.

First, I remove my node_modules and platform/ios directories and did an npm i and ionic build, which ended up installing cordova-ios version 4.5.0, which caused the exact same issue you have.

My guess (and it is only a guess) is that you somehow have cordova-ios 4.5.0 even though ionic info is reporting 4.4.0 (weird, but I have no better explanation at this point).

So I did this:

  1. In package.json, change "cordova-ios": "^4.4.0" to "cordova-ios": "4.4.0" (no '^')
  2. In config.xml, change <engine name="ios" spec="^4.4.0" /> to <engine name="ios" spec="4.4.0" />
  3. rm -rf node_modules/ platforms/ios/
  4. npm i
  5. ionic cordova build ios
  6. * BUILD SUCCEEDED *

So at least for me, the key to the fix was pinning the cordova-ios version to 4.4.0 rather than using ^4.4.0, which will take upgrades to the minor version.

Of course, this means when it is time to upgrade cordova-ios, you will have to do it manually, but you probably want that control anyhow.

Anyhow, give that a try and let me know if that works for you.

@kensodemann Exactly the issue!

@kensodemann Hooray, I can now build, Thank you!!

Here's the thing, before doing ioinc build I went into my package.json file and here's what I found "cordova-ios": "^4.4.0", and not ^4.5.0.

Anyway, so I followed your instructions, ran rm -rf node_modules/ platform/ios then npm i and npm build.

That last command then changed my "cordova-ios": "^4.4.0", to "cordova-ios": "^4.5.0",.
In order to follow your instructions as close as possible, I changed it to your suggestion "cordova-ios": "4.4.0", (same thing for config.xml).

Uninstalled my node_modules & platform/ios once again and ran npm i then ionic cordova build ios and it worked.

Surprisingly enough, after doing so, I still find myself with "cordova-ios": "^4.4.0", in my package.json and <engine name="ios" spec="^4.4.0" /> in my config.xml

Surprisingly enough, after doing so, I still found myself with "cordova-ios": "^4.4.0", in my package.json and in my config.xml

My guess is that Cordova does that. Personally not a fan of tools mucking with my setup... :(

I am going to close this then. Glad it is working for you now.

@nuno is correct, the console plugin is the root cause, that has been included in cordova 7, so simply remove the plugin fixes the problem.

@kensodemann
Not worked for me. I got

Ld build/emulator/MyApp.app/MyApp normal x86_64
cd /Applications/IonicApps/BabyName/platforms/ios
export IPHONEOS_DEPLOYMENT_TARGET=9.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/saikrishna/Softwares/android-sdks/platform-tools:/Users/saikrishna/Softwares/android-sdks/tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -L/Applications/IonicApps/BabyName/platforms/ios/build/emulator -F/Applications/IonicApps/BabyName/platforms/ios/build/emulator -FMyApp/Plugins/cordova-plugin-facebook4 -FMyApp/Plugins/cordova-plugin-googleplus -filelist /Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp_lto.o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/MyApp.app.xcent /Applications/IonicApps/BabyName/platforms/ios/build/emulator/libCordova.a -weak_framework AudioToolbox -framework StoreKit -framework Bolts -framework FBSDKCoreKit -framework FBSDKLoginKit -framework FBSDKShareKit -framework CoreLocation -framework GoogleAppUtilities -framework GoogleAuthUtilities -framework GoogleNetworkingUtilities -framework GoogleSignIn -framework GoogleSymbolUtilities -framework GoogleUtilities -weak_framework AddressBook -weak_framework CoreText -weak_framework SafariServices -weak_framework Security -weak_framework SystemConfiguration -weak-lz -weak-lz -weak_framework WebKit -weak_framework Social -weak_framework MessageUI -Xlinker -dependency_info -Xlinker /Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp_dependency_info.dat -o /Applications/IonicApps/BabyName/platforms/ios/build/emulator/MyApp.app/MyApp
duplicate symbol _OBJC_CLASS_$_CDVLogger in:
/Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/CDVLogger.o
/Applications/IonicApps/BabyName/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
duplicate symbol _OBJC_METACLASS_$_CDVLogger in:
/Users/eupherntechnology/Library/Developer/Xcode/DerivedData/MyApp-gddohggkprehdkdqznpxmbtrwfzt/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/CDVLogger.o
/Applications/IonicApps/BabyName/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

* BUILD FAILED *

The following build commands failed:
Ld build/emulator/MyApp.app/MyApp normal x86_64
(1 failure)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Applications/IonicApps/BabyName/platforms/ios/cordova/build-debug.xcconfig,-workspace,MyApp.xcworkspace,-scheme,MyApp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone SE,build,CONFIGURATION_BUILD_DIR=/Applications/IonicApps/BabyName/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Applications/IonicApps/BabyName/platforms/ios/build/sharedpch

Environment

cli packages: (/Applications/IonicApps/BabyName/node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0 
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

Cordova Platforms : ios 4.5.4
Ionic Framework   : ionic1 1.3.3

System:

ios-deploy : 1.9.1 
ios-sim    : 6.1.2 
Node       : v6.10.3
npm        : 2.15.12 
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b

Environment Variables:

ANDROID_HOME : /Users/saikrishna/Softwares/android-sdks

Misc:

backend : pro

@surajitdeveloper -

Are you sure you are not installing the console plugin?
Did you remove everything and re-install from scratch?

If your repo is online, provide a link and I can take a quick look. In general, though, this is not an Ionic Framework issue but an issue with the use of incompatible plugins.

@kensodemann is right, it is all due to plugins being either old or incompatible.

For me, it turned out to be the cordova-plugin-inappbrowser. In my config.xml, there was still a reference to a git repo that didn't exist anymore. I first didn't take notice in the build process, but all of a sudden, I noticed that the build was complaining about not finding the repo for the plugin. The solution was quite simple: put the line in the config.xml in comment, and reinstall the plugin. And iOS was building again :)

So, if it may help, check you build log after you run ionic cordova build ios - it may contain errors about plugins. And check all of your plugins: simply reinstalling them might not help, you may have to update versions too.

Solution from @nuno works for me, just run:
cordova plugin rm cordova-plugin-console
cordova platform rm ios
cordova platform add ios
cordova build ios
I'm using cordova-ios version 4.5.4.

Hi all,

I had same problem and I have tried to execute solution posted by @didinj and not works because after this I get an error for scripts when execute rm platform and then build ios, I add again app-scripts but the problem was this : npm install @ionic / app-scripts@latest --save-dev because install 3.1.7 version of scripts and this generate the same main error then I execute and again app-scripts but with a less version for app-scripts and now works fine with 3.0.0 : npm install @ionic / [email protected] --save-dev

I'm using too cordova-ios version 4.5.4 and the all latest versions of all in macOS High Sierra 10.13.2 with Xcode 9.2

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.2
Node       : v8.0.0
npm        : 5.0.0
OS         : macOS High Sierra
Xcode      : Xcode 9.2 Build version 9C40b

I hope that with this I can help other users.

Thanks to all.

works for me! thanks @kensodemann ! 😃

As per https://github.com/apache/cordova-plugin-console

This plugin is no longer being worked on as the functionality provided by this plugin is now included in cordova-ios 4.5.0 or greater, and support is already built in to cordova-windows > 5.0.0. You should remove this plugin from your applications.

does anybody still have this problem ? from a gresh new app I'm not able to use this plugin...

Solution from @nuno works for me as well.

ionic cordova plugin remove cordova-plugin-console

  • Hit the above command to get ios build success.

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alan-agius4 picture alan-agius4  ·  3Comments

alexbainbridge picture alexbainbridge  ·  3Comments

Nick-The-Uncharted picture Nick-The-Uncharted  ·  3Comments

danbucholtz picture danbucholtz  ·  3Comments

gio82 picture gio82  ·  3Comments