xcode does't generate .h file for swift framework project? - swift

I created a framework writting on pure swift ,
but I cant find any .h file of public class . shouldn't Xcode generate .h file automaticly?
here is project structure
- ProjectName
-- ProjectName.h
-- publicClass.swift
the final projectname.framework does not contails the publicClass.h ,neither any "publicClass" string
Xcode Version 13.1 (13A1030d)
I searched the internet but got little about this problem

Swift doesn't use header files, you only get .swift files. If you want header file you have to use Objective-C.

After practice.
When import your framework in a project, import your framework in
a swift file, long press command then click your framework name in the file, Xcode will create a public interface file automatically, and you will see all your public classes functions.
Below is not a right answer, please ignore it.
Headers png
In TARGETS, select your framework, then in Build Phases, there is a Headers section, you could put your public swift file under Public, then command + B, in your framework folder, headers file, you will see.

Related

Sqlite for custom swift framework

I am creating a custom swift framework for managing all common data of my applications like data base or common classes.
I import the library "libsqlite3.0.tbd" in Linked Frameworks and Libraries, but when I try to put #import "sqlite3.h" in my Umbrella header file, I recite the next error:
Include of non-modular header inside framework module
Any idea?
Thank you very much
Step by Step what I did with my sqlite project for it to work, try this (keep the library added and the #import statement in the header):
First, remove the Header from Build Phases >> Headers.
Then go to Build Settings and add the path to the Header in the Objective-C Bridging Header. If you just created the Framework, didn't change the name of the .h file and your project is called Test, for example, the path will be Teste/Test.h (Xcode 7.1.1).
Hope it works.

Header file for included static library not found by swift bridging header during archive

I've run into a very vexing problem.
I've included a 3rd party static library (PDFKitten) into my project, which is a mixture of Swift and Objective-C code. I can build & test just fine in simulator and device.
However, when trying to do an Archive build ready to submit to the app store, the Swift compiler complains that the header PDFKitten/PDFKitten.h cannot be found.
Reproducing this is easy:
Create an empty Swift iOS project in Xcode.
Grab the PDF Kitten project and add it as a sub project.
Add the PDFKitten lib as a dependency
Create an objective-c source file to force the creation of the bridging header. Once the bridging header is created, you can delete the empty objective-c source file again (not the header!)
In the bridging header, add #import
An ordinary build will have no issues.
If you then try to do an archive build you'll get the error message.
Any ideas?
I had the same issue. I was able to get it to archive error-free once I added the path to the "Not Found" header file (in your case, PDFKitten.h) into the Header Search Paths portion of the app's Build Settings.

Static library .a file not updating after perform change in .m files

I have created static library project using the line script files.
Then I am manually copy .h files and .a file and created a framework. using iOS universal framework method.
But it's working fine while creating first time. but changed small modification in .m file its not reflecting in created staic library .a file. but it's working fine while using source files.
Please let me know if you have face similar type of issues.
I think this post answers your question, there is a bug in xcode, according to the signature, the post is by a developer who works on the xcode product. The reply to it shows a solution that has worked for me, which is:
explicitly set the location of the static library to "Relative to Build Products"
with a good text editor, edit the project.pbxproj inside the your project e.g. MyProject.xcodeproj/project.pbxproj and search for a line like the one below containing your library name. Verify that for the path= entry there is no path, and only the filename of your library file. It's nasty to have to do this, but I have found that xcode does not get it right 100% of the time.
{isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMyLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };
Do a clean build. The working project might be pointing at the old .a file maybe. Cleanup the project and then add the static library.
check and match the .a file creation date/time to ensure that it has been generated after you have made changes to .m file

iPhone static library creation

I have created a static library LibA.a which includes some codes and another static library LibB.a. When I use this static library LibA.a in a new project I get many errors like these:
File1.h no such file or directory.
This file File1.h and others showing error are present in LibB.a.
Edit 1: I am using XCode 4.0.1
Edit 2: Now while creating my static library, I have made the header file public whose methods the user can use in their project. My static library references another static library named XWidget.a. I have added it into my static library's "Link Binary with Libraries" and also in the direct dependency. Then created my static library. Now I am testing my library in a demo project. In Header Search Paths of demo project I have added the path of my static library's public header file.When I run it, the header files which are present in the inner static library XWidget.a are not found. Giving errors like FileA.h: no such file or directory. Should I somehow provide the path of inner static library (XWidget.a) also? If yes then how? Or what else am I missing?
You need to include the header files in the project where you want to interface with the library.
Click on the big project button in Xcode's file management tab on the sidebar, select your target, click Build Phases, and pull down the drop down menu titled "Compile Sources". Then make sure all the necessary .m, not .h, files are there.
I've run into this problem a couple times myself, I hope this helps you!

importing private frameworks in Xcode

I am a novice iPhone programmer I want to use some of the functions in the private framework
https://github.com/kennytm/iphone-private-frameworks
The function that I want to use is in 'SpringBoard'
So I downloaded 'SpringBoard' folder in that github repo.
And created a subdirectory called "Headers" in 'SpringBoard'
and put all the header files in that folder.
And renamed 'SpringBoard' to 'SpringBoard.framework' and copied it to /Developer/Platforms/(iPhoneOS_and_iPhoneSimulator)/sdks/System/library/Frameworks folder (I can't recall full path correctly sorry)
And I got back to the xcode and right click on Frameworks -> Add existing framework -> other -> I selected 'SpringBoard.framework' folder and clicked Add.
And I built the project and got an error
'ld : framework SpringBoard not found'
My imported framework does appear on the Xcode and I can see header files in it.
but when I built it I got that error.
What am I doing wrong?
Place all of your private headers in a directory like: /User/Name/Headers/ then set USER_HEADER_SEARCH_PATHS = "/User/Name/Headers/" and make sure that ALWAYS_SEARCH_USER_PATHS = YES
Also, SpringBoard.framework is not the way to do that.Simply place the folder named SpringBoard in the above Headers folder, making sure that the headers are directly inside them. For instance: SpringBoard/SBAlert.h
/* SpringBoard is not a framework. */
Notice that you wont have to add the SpringBoard folder to your project, they should appear as you start typing, as long as you set the above headers correctly.
I'm not sure if this works, but here a suggestion:
I think the spring board framework should be in the UIKit framework you already linked anyway, so just add the header file to your project and it should work.
Otherwise this could help you:
http://www.codethecode.com/projects/class-dump/