Unity build to xcode with gives error: Apple Mach-O Linker - xcode

I tried to google for the solution. I tried to delete the DerivedData folder but it still doesn't work... Why is this still happening? I am using Xcode version 6.2. Thanks.
Edit: Under the one error has 70 different errors saying various things. There is a warning saying
ld: warning: ignoring file /Users/Kevin Chen/Desktop/Parking Director/Libraries/libiPhone-lib.a, missing required architecture arm64 in file /Users/Mushrooms4Eva/Desktop/Parking Director/Libraries/libiPhone-lib.a (2 slices)
All of the following links and solutions did not work for me:
https://teamtreehouse.com/forum/apple-macho-linker-error-xcode-61
Apple Mach-O Linker Error when compiling for device

Sounds like your library libiPhone-lib.a is not compiled for arm64, but your project is set to be compiled for this architecture.
I think all the errors are triggered by this "warning" as the library is ignored, and therefore you may have a lot of missing references.
Your options:
Get a version of the lib compiled for arm64, or do it yourself, if you have the code
Remove arm64 architecture from your project (which I don't recommend, as you'll need to provide an 64bit build for the App Store, but that's another story)
How to make 64bit builds (available from Unity 4.6.2+)
iOS platform
Other Settings
Scripting Backend => IL2CPP
Architecture => Universal (to target both 32 and 64 bit)
How to build for simulator
Player Settings
iOS platform
SDK Version => Simulator SDK

Related

xcode not building arm64/apple silicon universal dylib

I am on xcode 12.4 macOS catalina, Intel x64 machine. There is a project which is C/C++ project and outputs a dylib. In the xcode 12.4 the build setting "Architectures" is Apple Silicon & Intel.
Build active architecture Only is No.
The dylib builds fine but when I check if it is a Universal library or not using lipo then it shows on x64 and not arm.
I signed up just to post an answer, cause I spend couple of hours myself with the same problem.
There's a setting 'Allow Multi-Platform Builds' under 'Build Options', that should be turned on. It did the trick for me and now it compiles a 'fat' dylib.
Confusing thing is that for the bundles, it compiles the universal binary with this setting turned to off, but not for the dylib's.
I've just chased down my problem with a similar scenario, but with an application target. I had copied an FCPX project (created on Xcode v10.*) to a new project intended to support 'arm64' and
x86_64'. Since I was using *.xcconfig settings, I did not expect any problems - but, sure enough, arm64 was NOT built because of a "stray" setting for VALID_ARCHS that restricted the target to x86_64. But Xcode 12.2 no longer displays the "Valid Architectures" setting in the ui (this was the root of my confusion). At any rate, I fixed my issue first by adding a VALID_ARCHS setting (which included arm64) to the *.xcconfig file. The final solution was editing the project.pbxproj file, and discarding the VALID_ARCHS setting.

Xcode 12 build target in wrong order for simulator?

My project always runs correctly on all devices using Xcode 11, but after I installed Xcode 12 beta 4, it is failing to build on the simulator.
I compared the build logs of Xcode 11 and Xcode 12 and it seems in Xcode 12 that my main target is being built before the cocoa pods target, and so the link will fail because the cocoapods library will not be found.
How to fix the order of the build target?
In Xcode 11, everything is fine. My own target is built after the cocoapods target .
In Xcode 12, the build is out of order My own target is built before the cocoapods target .
OK, i got a solution to make the build work (this way to fix problem is not correct , the right way to fix is added in my update):
1 you need to add the Pods project to your main project as a external project
2 add all the cocodpods target as dependency explicitly in your main project 's build phase
But i still think may be the new beta version of xcode 12 will fix this. because it seem a bug of xcode 12 (my project work perfect in xcode 11 and xcode 12 + ios device , failed in xcode 12 + simulator only)
###2020-08-17 update###
i found a more exactly reason to reproduce this problem , it seems my project file open in xcode 12 will auto generate a VALID_ARCHS macro in User-Defines , and this macro will make the build failed
And i found that ,with this macro , During in the LINK of building,the link target type will be a unknown type
'arm64-apple-ios11.0-simulator'
which cause the build faild and the problem that all the targets build in wrong order seems will only happen when this macro is being added
XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios11.0-simulator
after i delete this VALID_ARCHS macro, the link target type will be 'x86_64-apple-ios11.0-simulator' , and everything goes well
XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios11.0-simulator
####2020-09-11 add Add Apple's Feedback about this macro####
update Apple's Feedback on VALID_ARCHS
After reviewing your feedback, we have some additional information
for you:
Xcode does not add VALID_ARCHS to your project. Indeed, we recommend
against using VALID_ARCHS. Maybe some CocoaPod is setting it in your
project for some reason? CocoaPods are not part of Xcode so, we don’t
have any control over what they do.
One thing to note is that in Xcode 11 VALID_ARCHS showed up under the
architectures section. Since we are strongly recommending against
using it, it no longer shows up there and now appears in the User
Defined section if it is defined at all.
Xcode 11 used to automatically translate building for arm64 for the
simulator into building for x86_64, but now that arm64 is a valid
simulator architecture (it’s the Apple Silicon architecture), that
translation no longer occurs.
So, we suspect what you should do is delete VALID_ARCHS from your
project altogether, and make sure Architectures (ARCHS) is set to
Standard Architectures (ARCHS_STANDARD) and not to something specific
(unless you really know exactly why you’re not using ARCHS_STANDARD).
####Feedback end####
####2020-10-10 added####
the build may still not working after deleting the VALID_ARCHS macro for some guys , you may check the answer of Apple's feedback added and #Andrei Herford's answer below:
make sure Architectures (ARCHS) is set to Standard Architectures
(ARCHS_STANDARD)
and then delete the macro ,hope these two steps works for all:)
####2020-10-10 added end####
I was able to solve the problem both in simulator and on device by using $(ARCHS_STANDARD) not only for ARCHS in the Architecture settings but also in VALID_ARCHS as well. I am not sure what possible side effect changing the archs in this way might have but so far I have not experiencend any new problems.
Details:
The excellent answer by #ximmyxiao got me on the right track. However, the solution proposend by him (remove VALID_ARCHS) did not work for me. This led to a new problem when compiling the Pod targets (Command PhaseScriptExecution failed with a nonzero exit code and ARCHS[#]: unbound variable in Pods script).
Instead replacing arm64 with x86_64in VALID_ARCHS solved the problem when building for simulator. It seems that arm64 was never a correct platform and was translated to x86 by Xcode. As Apple has announced their shift to ARM processors, this translation is not correct anymore and thus one has to use the the correct platform x86_64 instead.
Regarding to Apple VALID_ARCHS should not be used any more. However, this fix did not work when building for devices. Eventually using $(ARCHS_STANDARD) instead (both for simulator and device) did the trick in both cases.
Good look to others who encounter this kind of problems. Never gets boring working with Xcode....
** For XCode 12.4 **
I have Apple MB Pro with M1 and the project with Moya POD and lot of others.
App builds perfectly in old intel-based macbook with the same version of XCode (12.4).
But for M1 it won't compile says: "Moya not found". What??
It said: "Could not find module 'Moya' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator".
No suggestions worked for me. So what helped me is:
(not sure whether this is necessary): reinstall all pods by pod install
clear build data
launch via Rosette (check this in XCode app properties cmd+i)
in App's Project:
"Architectures": add x86_64
"Build Active Architecture Only": YES
in "Pods" project, conflicting pod section (Moya in my case):
"Build Active Architecture Only": YES
Then rebuild. Probably next rebuild also required.
For Xcode Version 12.1
If you can't find VALID_ARCHS
Adding **$(ARCHS_STANDARD) x86_64 i386 all three in Architectures will solve the issue for running on simulators and Devices , archiving . also suggestedly add Build Active Architecture Only to 'Yes'.
Here's what worked for me.
Removed VALID_ARCHS from user defined settings
Set the ARCHS to $(ARCHS_STANDARD)
Created a new .xcconfig file for my project. (If you already have one, then you may skip this)
Added these to my .xcconfig file
EXCLUDED_ARCHS[sdk=iphoneos*] = x86_64
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64
After that, I'm able to build both for simulator & device. The idea here is to exclude arm64 when building on simulators and x86_64 on devices.

ld: library not found for (on Simulator only)

Suddenly began getting this error when running my app on iOS 7 Simulator.
ld: library not found for -lacmobileshim
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
On Device this problem doesn't happen and the app runs OK.
Have already searched for this library inside SDK but couldn't find it. Have no idea what's going on cause it was running OK both on Simulator and Devices before and haven't added any additional library to my project.
Is there a way to set Library Search Path in Build Settings just for this library?
Should reinstall SDK be a workaround?
These are the libraries i'm including in my project:
After get the same headache as updated to Xcode 6/iOS 8 sdk, just found a simple way to solve this issue with libacmobileshim.dylib and also other dynamic libraries that were causing the same problem when building the app on simulator. Just delete the dynamic libraries from Build Phases settings and the app is running perfectly again on simulator. Hope it may help someone with the same problem.
libacmobileshim.dylib is in the iOS Device SDK, but it is not in the simulator SDK. External developers should have no need for this library, so I'm confused as to why you're linking against it.
Looking at that list of libraries that you're linking against, I suspect a bunch of them aren't even needed by your project. You should audit that list and eliminate unnecessary linkage.

Undefined symbols for architecture armv7 - Static Library

I'm from Argentina and my English is very limited. Sorry about that.
I tell them about my problem:
I downloaded the SDK for iOS Hikvision cameras from this link: http://www.hikvision.com/en/download_more.asp?id=1207
This includes static library file called "libPlayCtrl.a" and two headers "ApplePlayM4.h" & "PlayM4.h"
The problem is that to include the library in my project, I get the error:
"Undefined symbols for architecture armv7"
I followed the suggestions in this link: Undefined symbols for architecture armv7 and I could not compile the project in any way.
Has anyone worked with this program and can help me?
Thank you.
This question was posted awhile ago. I recently attempted to integrate the HikVision iOS Player SDK for a project as well. I ran into similar errors, symbols not defined for armv7 architecture, as well as a few others. The HikVision documentation for the sdk does not give you the dependent libraries for clean and easy integration. I have included the following libraries, CoreAudio, CoreVideo, AudioToolbox, and OpenAL, as well as the libstdc++.6.0.0.dylib. With all these included in a test project within my environment using XCode 7 with iOS 9 via swift. I created a bridging header (because of swift), imported the ApplePlayM4.h and was able to call the PlayM4_GetPort method. Please note the HikVision library is only compiled for device architectures, amrv7/armv64 and not i386 that is why it won't work in the simulator and only on a physical device.

XCode linking error when targeting armv7

I've already spent countless hours puzzling over this, utilizing Google searches and other Stack Overflow questions to no avail.
I have an iPhone/iPad universal application, which seems to compile fine when the target is armv6. However, when the device is iPad, I get this warning:
warning: building for SDK 'Device - iPhone OS 3.2' requires an armv7 architecture.
Oddly enough, the app still runs great on iPad in spite of this warning. However, I do want to do things the "right way" what ever that means in this case. When I switch the target architecture to armv7, I get linking errors:
"___restore_vfp_d8_d15_regs", referenced from:
*redacted*
"___save_vfp_d8_d15_regs", referenced from:
*redacted*
ld: symbol(s) not found
collect2: ld returned 1 exit status
The "redacted" portions of the errors are references to the static library to which I'm trying to link.
Here's what I've tried from the many suggestions online. Each of these were suggested more than once without any explanation, which leads me to believe nobody quite understands this problem:
"Never use the drop down menu in the upper left of the XCode window to choose the target. Instead, set this to Base SDK and then the Base SDK to iPhone OS 3.0 in the target configuration. Set the target device to your preferred target (iPad, iPhone OS 3.2 in my situation.)"
This yields the error "Library not found for -lcrt1.3.1.o"
"Make sure that GCC isn't linking against the wrong version of the standard library. (You'll have to make sure the LIBRARY_SEARCH_PATH doesn't have the wrong path in it.)"
My LIBRARY_SEARCH_PATH is already empty, so this doesn't seem relevant.
"Try compiling with GCC 4.0 rather than GCC 4.2."
I get a syntax error inside a UIKit header file. The error is "Syntax error before 'AT_NAME' token." The line is "UIKIT_EXTERN #interface UILocalizedIndexedCollation : NSObject."
Another project compiles just fine with the same target settings, which is really making me question my sanity. Could I be dealing with a corrupt XCode project?
If anyone knows what's actually happening and has a reference or doesn't mind explaining it, I would be so very grateful.
Cheers!
VFP between ARMv7 and ARMv6 differs in various ways. In ARMv7 its usually preferable to use NEON. The problem is your static library depends on VFP in ARMv6 - you either need to compile the library at ARMv7 or keep the whole application at ARMv6.
Reverting back to GCC 4.0 is silly - ARMv7 support was basically nonexistent back then unless Apple backported it.
I had the same errors except it was for armv6. I fixed them by unchecking "Compile for Thumb" in the project settings for the static library and the main project.
try do like this http://groups.google.com/group/three20/browse_thread/thread/31ddbc047aa1b9ae/c4c5827ab0c7a76f
As far as AT_NAME error is concerned one of the possiblity is
Check if you miss the #end in a class.
To know more about AT_NAME error visit the following link
http://iosdevelopertips.com/xcode/error-syntax-error-before-at_name-token.html

Resources