1

I have read this solution, but I still cannot get the difference between a bridging header and an umbrella file. I get the same error when I'm using Objective-C library. StackOverflow question

However, I just need to use this .swift code from github. Gzip-NSdata

But I get the same error: using bridging headers with framework targets is unsupported.

I need to use it in a framework I'm developing(not an application). But I don't know where I should add objective-c header. I follow the instruction to add an objective-c bridging header under build settings and add "#import " to this file. I also add libz.dylib library to my linked framework and libraries and with status "required". I don't find any "umbrella file" in my Xcode, so I cannot solve this problem. Can any one help me? Thank you very much. Sorry for I'm very new to iOS development.

Alex Zavatone
  • 4,106
  • 36
  • 54
James Fu
  • 444
  • 1
  • 8
  • 21

2 Answers2

0

It's really strange for me. I reproduce my issue, but I cannot get the same error again, and I build successfully. My steps are as follow:

  1. add header(.h) to my target by File> New> File...> iOS> Source> Header File
  2. add NSData+GZIP.swift(which using libz.dylib) into my target
  3. add libz.dylib to my Linked Framework and Libraries which is under Target> general(a tab) (click + button to add libz.dylib)
  4. tell Xcode where is the header file in Target> Build Settings> Swift Compilier- Code Generation> Objective-C Bridging Header(note it should be the path from your root directory)

And...it builds successfully this time!! Note: if you have to use in another target(ex. unittest), you should follow the steps again.

James Fu
  • 444
  • 1
  • 8
  • 21
-1

First remove all your bridge-header files,

Try to create Obj-c file [New File->Source->Obj-C file] and by default it will ask you to create header file.

You should confirm that and it will create yourfilename.m & yourfilename.h files. Now you should import your Obj-c Library to yourfilename.h file

Example:

#import <Parse/Parse.h>

You can remove yourfilename.m file after all.

Özgür Ersil
  • 6,909
  • 3
  • 19
  • 29
  • I follow your step, but it show .m file only.... It didn't create .h file for me... Can I add .h file by myself? – James Fu May 21 '15 at 04:08
  • In XCode 6.3 and newer versions, if you choose file category it will create a new h file. Here is the screenshot [link] https://dl.dropboxusercontent.com/u/53894534/Screen%20Shot%202015-05-21%20at%2009.56.56.png – Özgür Ersil May 21 '15 at 07:01
  • I follow your steps and choose category. It indeed create 2 files for me- .h and .m. But I it still build fail and cannot find any code for zlib.h. My .h file is: `#import #include @interface NSObject (headers) @end` This gonna make me crazy...Can you use Gzip-NSdata in your framework? – James Fu May 22 '15 at 02:10