I'm trying to use swift in an Objective-C based project. It seems that ProjectName-Swift.h needs to be imported in every .m file which doesn't sound good. Can it be imported in the ProjectName-Prefix.pch like UIKit/UIKit.h so that I only need to type once in the project?
I've tried this way, but .pch cannot find the header file. Is there an alternative attempt?
Related
I have a CocoaPod written in Swift 4. Now I need to add some new features to this pod. To be able to do it I need to use a static framework written in Objective-C.
I supposed I need to use a bridging header, but I don't know how should I modify my .podspec in such case. When I am trying to add a header file with this line of code:
#import <MyObjectiveCFramework/MyObjectiveCFramework.h>
to s.source_files I see this error: Include of non-modular header inside framework module.
Also, I found out that I can use a special module.modulemap file, but what data should I add to that file and how can I refer to the module.modulemap in my .podspec file?
I added a swift class in my existing Objective-C project and was trying to import bridging header file of the form #import <ProductName/ProductModuleName-Swift.h> in some existing obj-c classes. But I got error that the header file is not found. I have put the correct Product name and Product Module Name but still I have no clue what exactly I am doing wrong. Also, I got this error: Umbrella header 'ProductName-umbrella.h' not found.
I am responsible for converting an application from Objective-C to Swift. One of the objective c files called 'database' imports file called sqlite3.h. Now I did not convert database.h and database.m to Swift. Instead I created an Objective-C bridging header that exposed the database code to the Swift files. However the database header file imports a file called sqlite3.h. So first I linked a library to my project called libsqlite3.dylib as I believed this library contains the sqlite3.h file. But I cannot view any header files the library contains.
So do I just need to include the libsqlite3.dylib in my objective-c bridging header file, and if so whats the syntax? Or do i need to download the sqlite3.h header file, and if so where can I get the code from or download it from?
Libraries do not contain header files (i.e. there is no header inside a dylib file).
In database.h (or .m), there is a line that looks like this:
#import <sqlite3.h>
Right-click on it and choose "Jump to definition" -- it should take you to the file. If not, something is wrong with your header paths.
You can install the sqlite3 using cocopods:
pod 'sqlite3'
Or if you want the swift version:
https://github.com/stephencelis/SQLite.swift
The bridging file is added, but keeps showing the error.
My Bridging Header File is correctly setup because the other imports are successful.
I would advise you to use CocoaPods to handle external frameworks. Here is SlackTextViewController. If you still want to use copied version, make sure you add the files to your project. Try copying the files to your project folder using Finder and then use Xcode File -> Add files to "YOUR_PROJECT"
I've got some source code (.h and .m files) that being developed by someone else.
I need to add it to my project as a (static) library Or even to add it as a source files that to be used by my own source files..
When I copy and past the folder containing the .m and .h files into my project I got a link error.
How to do that?
Maybe this tutorial will help you:
Using static libraries with Xcode