Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having -ObjC linker flag on Universal Architecture project results in Mach-O Linker error?

Previously, I am able to build and run my Unity output Xcode project with no problems. But now that Apple requires 64-bit support for iOS apps, I am forced to do the following changes in Unity:

Build settings -> Player settings -> Other settings -> Scripting backend -> IL2CPP
Build settings -> Player settings -> Other settings -> Architecture -> Universal

The problem now is that I cannot successfully build and run my Xcode project on my device. I am getting this Apple Mach-O linker error which I wasn't getting before.

Here's the error that I got from Xcode:

ld: warning: directory not found for option '-F-F/Users/user/Desktop/qwer/Frameworks/Plugins/IOS'
ld: warning: directory not found for option '-F"/Users/user/Desktop/qwer/../../Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK"'
duplicate symbol l082 in:
    /Users/user/Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK/VungleSDK.framework/VungleSDK(FMDatabase.o)
    /Users/user/Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK/VungleSDK.framework/VungleSDK(VungleAdViewController.o)
duplicate symbol l084 in:
    /Users/user/Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK/VungleSDK.framework/VungleSDK(VungleVideoPlayer.o)
    /Users/user/Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK/VungleSDK.framework/VungleSDK(VungleAdViewController.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

From what I've observed, seems to be something with the VungleSDK location? Which is strange to me because I made no changes other than the one I mentioned above.

Does anyone know how to fix this issue?

Also side note: Is anyone experiencing slow compile time when switching to IL2CPP and Universal Architecture? I have already switch my Xcode build to Release (as someone suggested online) and it's still like that. It takes a very long while for my code to compile. It only took like less than 10seconds before I switched to IL2CPP and Universal

UPDATE: I need to mention that I'm using Chartboost, AdColony, and Vungle in my app. I did some experimenting and found out that removing the -ObjC and -fobjc-arc linker flags from my Xcode project fixed the Mach-O linker error and I'm able to build and run successfully again. The warning: directory not found for option I was getting was still there though, but it still did compile and run successfully and all functions of Chartboost and Vungle was fully working in my app.

I had those linker flags in the first place because the AdColony SDK requires them. But removing them made AdColony to stop functioning in my app. So it's not a clean solution either.

This leads me to believe either 2 things: the AdColony unity plugin may have problems with supporting Universal/ARM64 architecture OR the -ObjC linker flag is not compatible for building to Universal/ARM64 architecture.

I'd appreciate if anyone can shed some light on this confusing issue.

Thanks

like image 400
aresz Avatar asked Jul 03 '15 12:07

aresz


1 Answers

I think you are having multiple Vungle SDKs imported referenced inside your project. All you have to do is remove one of them. If you think one of them is older and the other is newer and don't which one is which, then remove both of them and then reimport the latest Vungle SDK.

Also, I found another possible issue from the logs you posted

ld: warning: directory not found for option '-F"/Users/user/Desktop/qwer/../../Documents/Unity Projects/Unity 5.0.0 projects/MyGame/Assets/Editor/Vungle/VungleSDK"'

It seems like that path to your Vungle SDK is enclosed in ""(inverted Commas) in your 'FrameWork Search Paths'. Check your path it should look like as in reference image below.

Note that the path $(SRCROOT)/../../Assets/Editor/Vungle/VungleSDK is not enclosed in ""(inverted commas).

Update 1 Most of these Issues occur when path are not entered correctly inside your Framework Search Path. In my case I had multiple plugins and had to check not only the Framework Search Paths but also the Header Search Paths and Library Search Paths. I also had "" in my Library Search Paths and removed them as well (be careful while removing "" - one wrong removal and you will have to create a new xcode project). I have attached my other Search Paths images

Header Search Paths enter image description here

Library Search Paths enter image description here

like image 195
Anas iqbal Avatar answered Nov 13 '22 21:11

Anas iqbal