Error: linker command failed - Unity 2017.3.0f3 + Unity Ads 2.2.0 (694695)

Hi to all,

I have issue with iOS build + Unity Ads package, when I try to build very simple test application of Unity Ads with Xcode I’m always getting these linker error:

duplicate symbol _UnityAdsCopyString in:

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-6D362980BD529555.o

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-5A58B2CEE8B214AA.o

duplicate symbol _OBJC_CLASS_$_UnityAdsUnityWrapperDelegate in:

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-6D362980BD529555.o

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-5A58B2CEE8B214AA.o

duplicate symbol _OBJC_METACLASS_$_UnityAdsUnityWrapperDelegate in:

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-6D362980BD529555.o

    /Users/petak/Library/Developer/Xcode/DerivedData/Unity-iPhone-aflmhnsuschfxpenpatmdnypjbax/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/UnityAdsUnityWrapper-5A58B2CEE8B214AA.o

ld: 3 duplicate symbols for architecture arm64

I’m using Unity 2017.3.0f3 + Unity Ads 2.2.0 + Xcode 9.2.
Do you have any ideas how to solved this error ?

Thank you for any tips or advice.

Hi,

Thanks for bringing this up!

Do you by chance have Unity Ads integrated from the Asset Store and also the Services window?

Please disable the Ads integration from the Services window and let me know if it helps.

4 Likes

Hi,

Alternatively try to clean Library and obj folders for your project. We have our own example game released on App Store using almost identical setup: 2017.3.1f1, Ads SDK 2.2.0 and Xcode 9.2

So have tested and verified an almost similar configuration as yours.

Let us know if you still need help. You can also see if you can repro using our example project at https://github.com/Unity-Technologies/unity-ads-assetstore-test

/Rasmus

Hi mikaisomma,

thank you for your quick and correct answer, after I tried disable Unity Ads from Unity Editor Services Panel, my Xcode Test project doesn’t have any build linker error.

So thank you so much! And sorry for my late answer.

Ps.: I make my own fix with Editor API and Xcode API, which is great for future…
https://bitbucket.org/Unity-Technologies/xcodeapi

but your solution is so sharp and clean :wink:

using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;

public static class RemoveUnityAdsXcode
{
   [PostProcessBuild]
   public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
   {
      if (buildTarget != BuildTarget.iOS)
         return;

     
      string[] filesToRemove = {
         "Classes/UnityAds/UnityAdsUnityWrapper.mm"
      };

      string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
      PBXProject proj = new PBXProject();
      proj.ReadFromString(File.ReadAllText(pbxprojPath));

      foreach(string name in filesToRemove)
      {
         string fileGuid = proj.FindFileGuidByProjectPath(name);
         if (fileGuid != null)
         {
            Debug.Log ("Removing " + name + " from xcode project");
            proj.RemoveFile(fileGuid);
         }
      }

      File.WriteAllText(pbxprojPath, proj.WriteToString());
   }
}

So how do we get Unity ads to run properly if it’s dissabled in Services, do we delete the assets? Thank you very much, I have the same problem

Since this is an old thread, it might be helpful to start a new thread (or support ticket) and provide as much detail as possible for your issue. Specifically, we would need:

  • Are you building your game with Unity, XCode, or Android Studio?
  • If Unity, which version are you using?
  • Which version of the Ads SDK are you using?
  • Can you share the code you are using to integrate Unity Ads?
  • Can you provide a device log from your app when Unity Ads is initialized?
  • Are you using mediation? If so, which version of the mediation SDK and adapter are you using?
  • How pervasive is this problem? Is it reproducible 100% of the time or do you have metrics on how often it happens?