Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am i getting this clang error: _fwrite$UNIX2003 on simulator with iOS 8

I have downloaded the new iOS 8 into both my phone and the latest Xcode onto my Mac. It all works fine but after loading up and trying the new iPhone 6 plus simulator when I try the iPhone 4s or 5 simulators (it works with 5s) I get the following error:

Undefined symbols for architecture i386:
  "_fwrite$UNIX2003", referenced from:
      leveldb::(anonymous namespace)::PosixEnv::~PosixEnv() in Firebase(env_posix.o)
      leveldb::(anonymous namespace)::PosixEnv::~PosixEnv() in Firebase(env_posix.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems very odd to me that I have been using the iPhone 4 simulator all morning but it is only after I try the iPhone 6 plus simulator that it breaks and I can't get its usage back

like image 686
sam_smith Avatar asked Sep 22 '14 04:09

sam_smith


2 Answers

Answer provided in this link worked fine for me.

As per above link , In order to remove all of these error you have to create a *.c file (doesn't need a specific name) and copy paste the bellow code:

#include <stdio.h> 
#include <unistd.h> 
#include <string.h>
#include <stdlib.h>

FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
    return fopen(filename, mode);
}

int fputs$UNIX2003(const char *res1, FILE *res2){
    return fputs(res1,res2);
}

int nanosleep$UNIX2003(int val){
    return usleep(val);
}

char* strerror$UNIX2003(int errornum){
    return strerror(errornum);
}

double strtod$UNIX2003(const char *nptr, char **endptr){
    return strtod(nptr, endptr);
}

size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
    return fwrite(a, b, c, d);
}

normally everything should be ok.

like image 158
Nithin Michael Avatar answered Nov 19 '22 00:11

Nithin Michael


fwrite$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 (env_posix.o or a libsomething.a that contains env_posix.o) 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 env_posix.o against the iOS Simulator SDK.

like image 5
Jeremy Huddleston Sequoia Avatar answered Nov 18 '22 23:11

Jeremy Huddleston Sequoia