22

Error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/usr/lib/libz.tbd is not an object file (not allowed in a library)

If I replace libz.dylib with libz.tbd, xcode shows this bug. My project is a Cocoa Touch Static Library.

Paul Zahra
  • 9,522
  • 8
  • 54
  • 76
Appfame Appfame
  • 221
  • 1
  • 2
  • 4

2 Answers2

13

I found the solution here: https://forums.developer.apple.com/thread/4572

To summarize:

  1. Remove the libz.tbd file from the Libraries and Frameworks area.
  2. Edit your build settings for Other Linker Flags add "-lz"

It isn't ideal because it bypasses the GUI for managing the linked libraries in your project, but it works.

mikepj
  • 1,256
  • 11
  • 11
11

The below steps solved the issue. Reference solution

As per this article:

  1. Delete all references to .tbd files from either your linked libraries phase, or from the copied bundle resources phase (where they sometimes will be added).
  2. Go to Build Phases >Link Binary with Librairies > + > Add other -> Add a library to your project, then click 'Add Other...' then press Shift+Command+G and type in the path '/usr/lib' - you'll find libz.dylib there.
  3. add "-lz" to the other linker flags
XIII
  • 2,036
  • 16
  • 25
Saikiran Komirishetty
  • 6,525
  • 1
  • 29
  • 36
  • 1
    You can open libz.tbd in text editor to see path to the dynamic lib it references. On Xcode 8 adding libz.tbd to BuildPhases>Link BInaryWithLibrary worked to build an iOS app. However tbd files seem to *NOT* be supported when building an iOS static library. Deleting libz.tbd & replacing with libz.1.dylib & add "-lz" link flag as suggested here did work - Thank you! The tbd files can be founded under your Xcode app. The path is /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib Also Zlib has very liberal license http://www.zlib.net/ – Ed of the Mountain Nov 11 '16 at 13:35