2

I have upgraded to XCode 8.0 and it is giving me grief. The first issue was to do with code signing. Which I fixed by selecting a provisioning profile for debug and release from the General project settings. Weird not sure why it couldn't just work as it was compiling perfectly with the previous XCode. Previously XCode would say there is not provisional profile and prompt to fix it and would fix it. Seems a step back here. Anyways, went passed that issue.

The issue I have been facing all day is this error when I compile

Undefined symbols for architecture arm64:
  "_write_ret", referenced from:
      _dwsl in libtestlib.a(testlib.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I searched for write_ret and it is only a prototype in a header file, this function isn't called anywhere at all!! (Background the static library is part of a bigger project I brought only the files/code I needed to compile the static library for iOS). This was compiling perfectly before for years. I went back to the static libary source code and to humour myself I deleted the write_ret prototype and compiled it and updated the library in the my project and rebuilt. Same error again!. What is going on here?? I confirmed it was definitely using the correct built library.

I then decided I'll just built for armv7 only as this is an enterprise app. I went back to the static library project file and got rid of armv7s and arm64 from "valid architectures". I change "architectures" to armv7. I rebuilt the library and updated the project with the new library.

I also went into the main project and change the valid architectures to build for only armv7.

This time when I built my project I get this error

ld: warning: ignoring file /Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a, 
file was built for archive which is not the architecture being linked (armv7):
 /Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a

In the terminal I ran lipo libtestlib.a -info I get this:

input file libtestlib.a is not a fat file
Non-fat file: libtestlib.a is architecture: armv7

So it is built for armv7, so what is XCode complaining about really?

I am out of ideas now. Can anyone shed some light here?

I would like to get it to work with all the architectures as it was doing before the XCode upgrade I did on Friday. But worst case atleast compile to work only for armv7. My understanding is that it will still run on anything iPhone 5s and newer anyway.

Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
rukiman
  • 597
  • 10
  • 32

1 Answers1

1

At first, As you already know, you should support arm64 in order to support 64 bit architecture following Apple's rule.

At second, let's talk about undefined symbol issue, your first question.
I am not sure exactly from your situation description but,
one thing to my mind reading the question is that your static library may depend on some dylib(dynamic or shared library) which is deprecated from Xcode 7.

The possible scenario is your dylib library was red-marked in the project from Xcode 8 update version because this was replaced with tbd instead of dylib.

So, this library is now missing status, and you did remove it in the library list and you forgot it.
That's why your _write_ret symbol in libtestlib.a cannot be linked for architecture arm64 anymore.(dylib is missing status.)

if this scenario is true, import tbd instead of dylib.(text-based stub libraries).


let's talk about your second question related to error log.

ld: warning: ignoring file /Users/rrr/Library/Developer/Xcode/DerivedData/P-       eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a, 
file was built for archive which is not the architecture being linked (armv7):
 /Users/rrr/Library/Developer/Xcode/DerivedData/P-    eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a 

This log can be about Build Active Architecture Only in Xcode build setting.
check 'Build Active Architecture Only' from Yes to No.
It error log could be generated when Build Active Architecture Only is set to YES in your build setting situation. and, if it does not work, Have you ever clean your DerivedData directory and project?

If you already tried, it could be possible that your static library is actually not in the /Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a.

so, you can move your static library output into this project and try it again.

These are just scenario for your situation as I got your question. I wish it became a little help.

Thanks.

boraseoksoon
  • 2,164
  • 1
  • 20
  • 25
  • Ok I just noticed libstdc++.6.dylib and libxml2.dlyib are red. Could be that? Let me try to readd them. Is that the right thing to do? I am confused with this "import tbd instead of dylib". – rukiman Sep 27 '16 at 06:17
  • yes, you can import libstdc++6.tbd instead of dylib OR you can keep importing dylib. let me link helpful answers : http://stackoverflow.com/questions/31420166/libsqlite3-dylib-and-libz-dylib-missing-in-xcode-7-how-do-i-use-parse – boraseoksoon Sep 27 '16 at 06:19
  • I had hope, I changed them to the .tbd equilavents but no hope. It still fails with symbol(s) not found for architecture arm64 for the _write_ret function. So perhaps I will look at the deriveddata directory – rukiman Sep 27 '16 at 06:30
  • Thanks for the hints. I got it to work. Maybe add to your answer so I can accept and will help others. I had to change to the .tbd equilavents of the libraries and also delete the derived data using rm -rf ~/Library/Developer/Xcode/DerivedData after that, it compiled and installed ok – rukiman Sep 27 '16 at 06:40