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

3

8

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

Macready answered 3/7, 2015 at 12:18 Comment(5)
it seems like some symbols are duplicated inside the vungle sdk. make sure you're using a sdk that supports 64 bits, which seems like you are and try to clean the project and then do a new buildThyroid
@hades2510 Thanks for the comment. I did a clean on the project and compiled again but I receive the same error. Though I'm not entirely sure if the latest VungleSDK supports 64bits. But with no ignoring comments on the error, I think it does support 64.Macready
How to fix the duplicated symbols?Macready
did you try updating Unity to the latest version? depending on your flavour it should be 5.1.1 or 4.6.7Thyroid
Yes, I tried updating to the latest version. Result is still the same though.Macready
R
3

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

Rosemari answered 5/7, 2015 at 16:17 Comment(7)
Thanks for the detailed answer. I tried deleting all my framework search paths and re-added the Vungle framework to be sure. I also made sure that there were no "" in the paths. Unfortunately, I still get the Mach-O linker error.Macready
I have updated the answer. I also had this issue of getting Mach-O linker error even after fixing the Vungle issue but in my case I had multiple plugins inside my unity project e.g. Flurry and Chartboost. Have a look this may solve your problem.Rosemari
Hmm...By any chance, are you building for the Universal (ARMv7 and ARM64) architecture? I think the problem might be related to the AdColonySDK. It's because it requires me to put -ObjC linker flag for it to be able to work. Now, with that linker flag, I get the Mach-O linker error. When I remove that linker flag, I am able to build and run successfully to my device and everything runs well. The consequence is that AdColony stops working in my app... I've added updated details to my question since I found this.Macready
By any chance, are you building for the Universal (ARMv7 and ARM64) architecture? And do any of your plugins require you to put the -ObjC linker flag in your Xcode project? I think I may have narrowed down the possible culprits for this issue if that's the case.Macready
Yes all of my builds are for the Universal architecture (as this the requirement now). But none of my plugins require me to add a -ObjC linker flag.Rosemari
There is also an other way of adding a flag to your project. i.e In your 'Build Phases' tab search for the files that require the -ObjC flag (in your case the search term may by AdColony - or whatever the correct spelling and caps are) select all those files under 'Compile Sources' section; double click under the 'Compiler Flags' heading (on the right side of the selected files) and the box that opened type -ObjC. NOTE: This may not necessarily work as this is compiler flag not linker flag but this trick has helped me in most cases.Rosemari
e.g. I used a third party in-app purchase script and had to add -fobjc-arc flag to it.Rosemari
A
0

I don't have experience with Unity but when i get weird linker errors on my app I just have to run a clean to fix them.

Aery answered 3/7, 2015 at 17:13 Comment(1)
Thanks for the answer. I have tried cleaning the project already and cleaning project folder. But still no luck, I still get the same error.Macready
M
0

I guess you can fix the warning: directory not found for option issue by making Search Paths of your SDKs as Recursive.

Manuelmanuela answered 8/7, 2015 at 8:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.