No Such Module error in objective-c framework inside Swift - ios

I implement a API to my project. However, class doesn't see the library inside a swift class. (I was using the same api with same project before but now I created a new project but now It isn't working).
First I implement the class in build Phase then create "New copy file phase" but didn't work. I also create bridging header file.
]4

I delete framework from build settings etc.. then moved it to the project directory and It worked!

Related

How to create SDK for iOS in Swift?

I have my own Xcode project which contains some controllers. I want to make its SDK, for use it in another application. In parent application it works as child. Parent app will share some data with my controller and my controller works on it and gives back some result. So kindly guide for me. Examples are - Payment Gateway SDK's. I am looking for the same.
I can see you add tag for swift. In Swift, static libraries are not supported, so you must exclusively use a framework (aka dynamic library) when linking an app to a library. Framework is similar to sdk.
Here are the steps:
1)Create the Framework using New > Project under IOS > Framework & Library, select Cocoa Touch Framework
2)To avoid the "ld: warning: directory not found for option..." goto Library Search Paths in Build Settings for your target and delete the paths.
3)You can't mix Objective-C with Swift so don't even consider adding the Swift-Header bridge file in your code.
4)There are some cases in swift where you need to import code from unexposed Frameworks. I've successfully used the module-map inside the framework to deal with these case.
5)I also select CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES in the Build Settings to solve 'include of non-modular header inside framework module'. That seems to work
6)I make sure that the header file that gets generated is marked as Public (not Project). Click on the file and you'll see the selection in the inspector under 'Target Membership'
Link
Also you can follow this tutorial. Since you have already created project.
Create a framework target, make all source code files a member of the new target, add the new target as target to the podfile. For everything else the tutorial should work. It should help you in understanding the steps.
Build framework

filename.h file not found error in Xcode 8 while creating framework

I'm trying to create a framework using this steps https://www.raywenderlich.com/65964/create-a-framework-for-ios
I've imported the framework file into project and I can able to create object for the framework file and access the methods. But when I build the project it is telling that file is not found.
Make sure your .h file is in public section of 'Copy Headers' as shown in snap shot
Just add you framework's bundle to embedded libraries as

Is it possible to create a standalone distributed Swift Framework?

I have a scenario where I need to package some common code into a Swift only framework. I have found many tutorials on how to do this but all involve creating a framework within an iOS app. My goal is to:
Create a seperate Framework project
Build and produce a .framework file
Copy that single file(without all the source files) into some iOS app project, add it under "Linked Libraries" and use it.
Question: Is this possible or do I have to include all of the Classes that are part of the framework?
I have added a framework project to an iOS app and had success using it because all the source code was in the Framework project. I tried to copy that .framework file alone to a new project and use it but when trying to access the classes or instantiate the contents of the framework I couldn't even-though whatever needed to be declared as public was.
Appreciate any help...

Adding sub-project in swift

I have 2 projects in a workspaces, both are built using Swift.
I want to use one of the project as a sub-project of the other one and the classes, which are in the sub-project, in the parent project.
My sub-project is using bridging-header.
I have tried to add one project as a reference to another and imported the class, which is in sub-project, but it didn't work.
Showing me Error: "No such module "
Please help me achieving this?
Fixed the issue, thing i did was:
Removed bridging header file, which was bridging my objective-C and
swift code from my framework and deleted the bridging header file from Build Settings.
Created a file named "Framework-name.h" and copied all the header files, which were there in my bridging header file, into "Framework-name.h" file.
import "Framework-name.h" inside "Framework-name.h" file (this is vey important, it will keep the file at the root level of the framework).
Made "Framework-name.h" and files that were included in Framework-name.h" file public.
Created an aggregate target for my framework. https://medium.com/#syshen/create-an-ios-universal-framework-148eb130a46c
Built the framework.
Drag and drop the created framework into the root level of another sample project.
Test the framework, writing import Framework-name in swift class of the sample project.
Build the project.
Bingo!!!

Swift Migration - Setting up existing framework to work with swift

In my project i have following setup
Library Project - which builds to OSX framework
Main Project - OSX application
So library project is build into the framework, and main project uses that private framework.
Headers on library are all in project group, application uses header_search_paths setting to find the headers.
Now I'm trying to make the lib work nicely with swift (get the suggestions), and to do that I need to make the framework build into the module.
So I am moving the header files from project to public group. But problem now is that the headers are shipped with app, but I would like them to be not visible (as it's private framework).
Is there way to make the headers private when i ship the app, but have the module build so that i get the suggestions from swift ?
Try creating a top most header file (for example yourProject.h) which is visible and import all your header files that you want hidden into it. Then bridge that header file in your Swift project-Bridging-Header.h.

Resources