Xcode 6 simulator build missing symbol for _clock$UNIX2003 - xcode

I'm building a Unity project for an iOS8 simulator. Moving this for Xcode 6 GM for the simulator has resulted in this linker error. Not sure if I'm missing something in the build or something is broken. Any suggestions? The full error is:
Undefined symbols for architecture i386:
"_clock$UNIX2003", referenced from:
_substanceHandleSwitchHard in libiPhone-lib.a(apihandle.o)
_mainRenderProcess in libiPhone-lib.a(mainrenderprocess.o)
ld: symbol(s) not found for architecture i386
Exit with code 1

Add the following at the end of main.mm.
#include <time.h>
extern "C"
{
clock_t
clock$UNIX2003(void)
{
return clock();
}
}

clock$UNIX2003 is a symbol that is provided by OS X and is not part of the iOS Simulator runtime. iOS is always conformant and thus does not have legacy (non $UNIX2003) variants of functions (which are provided for binary compatibility with code built against older versions of the OS X SDK).
The common cause of the issue you are seeing is that you have an object file or archive (libsomething.a) that was built against the OS X SDK and are trying to link it into your iOS Simulator executable. That is not supported as the two platforms are not binary compatible at that layer.
You need to rebuild your library (the libsomething.a) against the iOS Simulator SDK.

Related

Switched Firebase Crashlytics from CocoaPods to Swift Package now Simulator won't build on a M1 Mac

Just removed Crashlytics from the podfile, then added it as a Swift Package. Built for an actual device just fine. But when I switch to the Simulator, no go (and tried deleting Derived folders etc - no change).
Another dev using Xcode 13.2.1 on an Intel Mac can build for the Simulator just fine.
Doesn't matter if I delete DerivedFolder then build first for Simulaor or for device - when I get to Simulator it always fails same errors.
The Excluded Architectures for everything are arm64, Build Active Architure=YES
Xcode 13.4.1
Mac: Monterey 13.4
ld: warning: ignoring file .../Build/Products/Debugging-iphonesimulator/FirebaseCrashlytics.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
... (12 others)
ld: warning: ignoring file .../Build/Products/Debugging-iphonesimulator/FirebaseInstallations.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FIRCrashlytics", referenced from:
objc-class-ref in <SomeFile>-8e51ce451b9a03f7582a9e76a8faf6a6.o
objc-class-ref in <SomeFile>-e71967da3e8b662633c9220e635ffc51.o
"_OBJC_CLASS_$_FIRApp", referenced from:
objc-class-ref in SSLog-8e51ce451b9a03f7582a9e76a8faf6a6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I posted to Firebase Issues but this issue didn't ring a bell. However, I did trip on an Apple TN on M1 Mac build issues, and doing what they suggested revolved the issue.
It appears that when Xcode builds Packages the rules it follows may not use the target's build settings. I believe the issue was related to Excluded Architectures.
For me the issue was fixed by making sure Xcode was running in Rosetta mode.

How to use AirWatch SDK in a Xamarin (Forms) iOS Project?

AirWatch SDK allows you to include MDM features in your iOS app. I followed the instructions from VMWare's site here.
Unfortunately, after adding the NuGet package to my iOS project, the project fails to compile and throws more than 300 compilation errors of the type
MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: AWWebsiteFilteringPayload.
The symbol '_OBJC_CLASS_$_AWWebsiteFilteringPayload' could not be found
in any of the libraries or frameworks linked with your application.
The reason for the compilation errors is the Platform (iPhone Simulator vs Device) for which the project is built and the Supported Architectures.
Changing the build option to target a real device gets past the compilation errors.
If you scroll through the build output you will see something like this
ld : warning : ignoring file /Path/To/Your/Project/MyApp.iOS/obj/iPhoneSimulator/Debug/device-builds/iphone10.4-12.1/mtouch-cache/AWSDK.a, missing required architecture x86_64 in file /Path/To/Your/Project/MyApp.iOS/obj/iPhoneSimulator/Debug/device-builds/iphone10.4-12.1/mtouch-cache/AWSDK.a (2 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AWWebsiteFilteringPayload", referenced from:
-u command line option
This Stackoverflow answer helped to discover the architectures targeted in the .a file
In a terminal window enter
lipo -info /Path/To/AWSDK.a
which returns
Architectures in the fat file: AWSDK.a are: armv7 arm64
Now right click on the iOS project and bring up the Options window. Navigate to the "iOS Build" section. The Platform dropdown says "iPhone Simulator". Check the Supported architectures dropdown. You will see i386, x86_64, i386+x86_64 which are not supported in the AWSDK.a file.
Change platform to iPhone and you will see the Armxx options.

How to organize XCode project structure with library, unit tests and iOS app?

I'd like to have code with XC tests (the tests are launched on Mac) and iOS app that uses that code. I'm having:
One workspace
Two projects
2.1. Project 1: Mac OS static library (code + tests to run on Mac)
2.2. Project 2: iOS app that uses Project 1 code
The problem is that library is build for x86_64 platform and iOS app fails to link as it's built for i386 platform (to run in iOS simulator):
ld: warning: ld: warning: ld: warning: ignoring file
/Users/asmirnov/Library/Developer/Xcode/DerivedData/iFileSystem-colswwvuefyumkclybhsyoymndun/Build/Products/Debug/libFileSystem.a
...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can i do it?
PS. Should i use "iOS static library" Project type instead?
I've solved it for me case and probably it can be useful for others.
Create 2 targets instead of default 1 target (and 2 products) for library - both Mac OS (to be used for unit tests on dev machine) and iOS (to be used in iOS app). See Base SDK in target build settings.

xcode 4.5 - symbols not found for architecture i386 (zbar)

I have a project which uses the zbar-sdk (a barcode scanning library).
After updating my machine to xcode 4.5 and ios6sdk I am having some troubles.
I was able to build to the simulator without touching anything about my project. This is using the latest zbar 1.2 library.
I then wanted to build to my ios6 device for testing, and thats when I got an error.
After some googling on the zbar developer forum, I seen that I needed to get the zbar source and build the libzbar.a for armv7 and armv7s as this has not yet been done by the zbar developer.
See - http://sourceforge.net/projects/zbar/forums/forum/1072195/topic/5728912
So I did this, re-imported the updated libzbar.a into my project. I then built for my device, and it worked! I was able to get my app onto my testing device and the zbar barcode library worked fine.
I thought that was the end of it, but unfortunately not.
I then tried to build to the simulator (ios6) again, and thats when it fails.
No matter what I cannot get this project to build for both the device and simualtor at the same time and with the same settings :(
My libzbar.a project settings when building my own libzbar.a file:
Architecture: Standard (armv7, armv7s) $(ARCHS_STANDARD_32_BIT)
Build Active Architecture Only: No
Valid Architectures: armv7 armv7s
And my project settings (for myapp) as:
Architecture: Standard (armv7, armv7s) $(ARCHS_STANDARD_32_BIT)
Build Active Architecture Only: No
Valid Architectures: armv7 armv7s
Base SDK: iOS6
iOS Deployment Target: iOS 5.0
And the error when trying to build to the simulator:
ld: warning: ignoring file /Users/blah/iOS App/myapp/ZBarSDK/libzbar.a, missing required architecture i386 in file /Users/blah/iOS App/myapp/ZBarSDK/libzbar.a (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
objc-class-ref in mycontroller.o
"_ZBarReaderControllerResults", referenced from:
-[mycontroller imagePickerController:didFinishPickingMediaWithInfo:] in mycontroller.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried tweaking the libzbar.a project settings (e.g. build active architecture set to "YES") but this just results in neither the simulator or device working.
The fact that it works on the device but not the simulator makes me thing there is some weird architecture/project setting causing this.
Any help much appreciated!
I doubt this is the right answer but it worked for me, I compiled the new libzber.a using architectures: i386 armv6 armv7 armv7s in that order you also need to specify valid architectures as the same values. Again this is what worked for me with a recent release I needed to get out A.S.A.P. Both are found in Target -> Build Settings -> Architecures.
Also note: $(ARCHS_STANDARD_32_BIT) needed to be removed from the settings.
I fixed a similar issue by setting the iOS6 simulator architecture under OTHER_LDFLAGS in Target->Build Settings.
I forgot that I had a different command line argument for separated archituctures so I had to manually state the simulator

SDL in XCode 4.3.2 SDLMain.o undefined symbols

I have started trying to use SDL in Xcode 4.3.2 so I started up a Cocoa application for Mac OS X and connected all my frameworks : OpenGL, SDL etc. I don't have SDL_Image, SDL_Mixer etc. (Do I need these?) When I try to compile the project that just has SDLmain.h and SDLmain.m I get this error:
Undefined symbols for architecture x86_64: "_SDL_main", referenced from: -[SDLMain applicationDidFinishLaunching:] in SDLMain.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I was having the same issue with SDL 1.2.15 on Xcode 4.5 and OS X 10.7, turned out the problem was that I added SDLMain.m and SDLMain.h (according to a suggestion on the libSDL website about OS X frameworks) to an existing SDL project which messed up with main. Bottom line is that you don't need those files just because you are using Cocoa -- SDL's own test apps don't use it either and run just fine on OS X.

Resources