I am trying to install this library without using Pods. In their git, they explain that it's possible to do it by dragging the .xcodeproj file on the user project:
Yes you can copy it the classes like before. However it's more
comfortable to drag the xcodeproj to the project. It's not recommended
to drag the sources themselves, as this will make updating Chrats in
your project more difficult.
By dragging the project I get an error When I try to import the module:
No such module 'Charts'
I also selected my project -> Build Phases -> Link Binary With Libraries and added the Charts.framework. That didn't solved the problem.
I think to use any of the cocoa pods you have to build a header file as maybe the code that you are going to use might be in objective C and you might be using swift.
Simply create briding header file with named
"projectname-bridging-header.h" at root of your project.
Now got to build setting of project and in that do below changes:
Install objective-c compatibility header : YES
objective-C briding header : set path of your bridging header like
"projectname/briding header file name.h"
once its done import all your objective c file of pods which u want
use in swift app.
Note : if required then set the path as a recursive in the resource headers and Swift compiler search section.
let me know if any issues :)
Related
Currently we are developing a custom framework which need to use InsiderMobile cocoapods. According to this guideline, we will need o create Bridging-Header File to use InsiderMobile. However, Bridging-Header or Umbrella file did not work inside our framework so we have to use MapModule with Build Settings/Import Paths method, then the framework compile just fine.
The actual problem occur when we try to apply our framework to an application. The framework recognize all other pods except InsiderMobile. Here our current settings:
We got both our custom framework and InsiderMobile in Pods folder,
Our custom framework is Embed,
MapModule with Build Settings/Import Paths method is also apply,
Here is some methods that we've already tried:
pod install again, delete derived data, clean and rebuild project,
Manually edit custom framework -umbrella file, but bump into new error: "Include of non-modular header inside framework module ", also try to set Allow Non-modular Includes In Framework Modules in Build Settings to Yes
Also Embed InsiderMobile framework,
None of these above methods solve the problem. Is there anyway to allow our custom framework to import InsiderMobile? Thanks in advance.
In case it's helpful, i have found a way to temporary solve this issue. Not the best but help us unstuck the developing process. Basically, i have been trying to work with .modulemap method the whole time, you can find the docs here. Then i found this topic, and there this guys repo. I just follow the repo with a little change on the .modulemap file and everything work fine for me. Here's my .modulemap file:
module InsiderMobile [system] {
// Framework complier
// header "../../../../Pods/InsiderMobile/InsiderMobile.framework/Headers/Insider.h"
//App complier
header "../../../../../../Pods/InsiderMobile/InsiderMobile.framework/Headers/Insider.h"
export *
}
Cause .modulemap file directory might change when it go remote, so i have to change to suitable path before deploy it. I know it inconvenience but it work for now.
I am facing issues in actually using the libraries contained within the dependancies. I followed the procedure up to the letter but yet xcode gives me errors when i try to import the kit i need to use. Heres what i have done:
create pod file at the project directory
install the pod file with dependancies
open .xcworkspace file created
create a bridging header in objective c
enter path of the bridging header to the build settings
After doing all of this, when i write the import statement (eg. import IMFData) xcode shows that it doesnt exist/ cant be found.
Could somebody shed some light on the what i am missing?
Try adding use_frameworks! to your pod file and then run pod install again. You won't need to use a bridging header then and will be able todo import IMFData alternatively if you aren't using Frameworks when you use the bridging header you don't need to use the import IMFData just access the classes within your swift class.
As a beginner in ObjectiveC I need some help.
I'm working on a phonegap plugin for IOS (so, written with objective C). I use some open source code but I got an error with an .h import.
My architecture look like:
myFmk.framework/
myFmk.framework/ABCDE/myFmk.h <== in a sub folder
myFmk.framework/myFmk <=== this is a file
myPlugin.h
myPlugin.m
In myPlugin.h I have #import and in "myFmk.framework/myFmk" file I have only one line "ABCDE/".
I thought that this file do a redirection of the absolute import (with brackets) but my complier told me that "myFmk/myFmk.h" is not found.
I tried to find some documentation about this feature but I wasn't able to find its name... do you have this documentation or the feature name?
Thks.
Is the framework added using a cocoapod? If not, did you follow the instructions properly for adding it to your project? It would probably help if you posted the framework you are experiencing problems with.
If this is a framework that is added to your project properly and you are unable to import there are a few things you should check. First, go to your project settings (click on the project at the very top of your file tree in the left column) and then look for "linked libraries". See if the library is listed there. If not click the + and try to add it.
If this framework was added via cocoapods another thing to check is search your file structure for libPods.a. If it is red, I find sometimes it is helpful to delete it, close the project and run pod install again.
Also if you installed the project via cocoapods remember to open the workspace and not the old xcode project file.
I have also experienced this problem when my header search paths and other linker flag paths were wrong. Linker Flags should be $inherited if this is a cocoapod. In my projects most Header search paths are $inherited too.
If none of this is helpful please provide more information such as how this framework was added to your project and what the framework is. Also let us know if you get any error messages.
I added pod 'CrittercismSDK' to my Podfile and ran pod install, it finished with no error, all good.
Using import Crittercism gives No such module error. I looked into the Pods/ directory, there source code is there; however, the Pods project doesn't have a target called Pods-MyProject-Crittercism (but it does have targets for each dependency).
Build keeps failing because the import isn't found. What am I doing wrong?
PS: I'm using use_frameworks! directive in my Podfile, and I have another obj-c library that works fine, so I don't know why this one isn't working.
While this is not a general answer, I have found that:
Not using #use_frameworks
Using a Bridging-Header.h containing #import "Crittercism.h"
Not importing CrittercismSDK in the Swift class, but merely executing Crittercism.enableWithAppID("appId") does the trick.
See if below steps helps in your case. What version of pod/Xcode in use? It will be great if you can share your pod file, thanks.
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
I want to include an Objective-C project (https://github.com/soffes/ssziparchive) into my Swift Project so that I can include the SSZipArchive into my project. I need this so I can unzip a file. As included in the instructions on the Github, I included the folder minizip, SSZipArchive.h, and SSZipArchive.m into my project. I have also created a bridging header where I included the following import into my project #import "SSZipArchive.h". However, when I try to type SSZipArchive on Xcode, the autocomplete doesn't occur, leading me to believe that SSZipArchive isn't included properly in my project. Any ideas on how to do so? I have already looked at numerous links on how to include Objective-C projects into Swift and I have found that I simply need to include the corresponding header files for my project to work.
I guess that you haven't set bridging header path properly. It's a very common problem, but easy one to fix.
Go to the Project Settings -> Build Settings -> Search, and search for bridg, and under Objective-C Bridging Header set the path of your bridging header file (carefully inspect it's path in Finder first, since it may be in some sub-directory of your project).
Also make sure that all your included header files have target of your application. To check if they have, click on the header file, open up Utilities from the right side and under Target Membership, make sure the first target is checked.