No such module 'TTTabBarItem' using CocoaPods - ios

I'm trying to extend TTTabBar. When I had the lib in my project, it worked fine but I wanted to keep it as a pod (for maintenance and version management) and extend it as needed.
Since then, I can't import it without errors. Other similar answers (and there is a lot!) didn't help.
My Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target 'Octoly' do
pod 'RealmSwift', '~> 0.98'
pod 'Mixpanel', '~> 2.9'
pod 'SwiftHTTP', '~> 1.0'
pod 'TTTabBar', '~> 1.1'
end
Here is the code where I try to import it and you also can see that I opened the workspace and TTTabBar is installed:
I have tried lots of things:
Clean / Rebuild
Remove pods and reinstall
Close / Reopen XCode
Add the frameworks to my building settings
Combinations of the previous steps
Here is the Binaries linked where I added TTTabBar:
It is good to know that it works fine for RealmSwift and import TTTabBar works but then it doesn't know what TTTabBarItem is in class TabBarItem: TTTabBarItem {}.
Notice that I've started iOS development 2 days ago so there might be obvious things that I am missing.

You are facing those issues because you are not supposed to import TTTabBarItem (the class you intend to use), but the whole library, in your case import TTTabBar. I think the linker is clever enough to only include the referenced files you use in your code.
So again, use import TTTabBar instead.
More importantly, the developer of the library made a fundamental mistake:
If you take a look at the source files, you can see this:
class TTTabBar: UIViewController { // rest of the code... }
He specified no public access modifier, which basically means that you cannot access it outside of the internal target of the library (you can basically only reference it within the source project/target itself, which is useless to any developer integrating this library).
You have an option though:
Due to the size of the library, you can just go ahead and copy the files into your project (any modifications you would add would always be overwritten if you just used the pod on subsequent pod install calls, so your initial intent to modify the library also doesn't seem to be a viable option).

The problem is actually in the TTTabBar module itself. The TTTabBar and TTTabBarItem classes and its method are not declared as public. So you don't get those classes in your app. The creator of that module should have made those classes and functions public
The solution is to change the local copy if your TTTabBar* files to include public access specifier in the classes and some of its methods and build your project.
E.g.
public class TTTabBar: UIViewController and public class TTTabBarItem: UIButton
You also have to mark 3 other methods as public as well.
In TTTabBar file viewDidLoad
in TTTabBarItem drawRect and init?

Related

Using React Native iOS dependency in Objective-c

I currently have the following dependency in a ReactNative project's package.json:
"vital-health-react-native": "file:../packages/vital-health-react-native"
This package has a .podspec with the following dependency:
s.dependency "VitalHealthKit", "~> 0.7.7"
Because I am dealing with HealthKit and background delivery, I need to be able to call a method from this dependency inside the AppDelegate.mm.
I have tried everything to import VitalHealthKit in the .mm and even in the .h, but the dependency is never found. The spec for VitalHealthKit can be found here.
What am I missing?
I’ve not done sub-dependency imports myself but I think one would need to add the pod to the app project’s Podfile like so
pod 'VitalHealthKitRN', path: "#{path_to_packages} /packages/vital-health-react-native/VitalHealthRN.podspec"
Having done that, if one still can’t import VitalHealthKit in the app, it might be necessary to reference VitalHealthKit native pod in the Podfile directly, either in a usual way (that might create a conflict of dependency versions with the RN pod) or using a local relative path, similar to the above. Might also have to use_frameworks! if you don’t already to avoid double-linking vital health kit. Hope this helps.

Objective-C class can't import swift pod defined at top level

Here's my Podfile:
platform :ios, '9.0'
use_frameworks!
target :Test_Swift_Import do
pod 'BFKit-Swift', '1.5.1' //Just a swift pod to provide some methods to test
pod 'SwiftySwift', '1.0.1' //and another
end
In my AppDelegate class I try to use a simple method from BFKit
BOOL isEmail = [#"not an email" isEmail];
My AppDelegate is an objective-c class, not Swift
In order to make this work I try to import the BFKit Swift module
First I try the well-known way:
//Basic <Product_Name-Swift.h>
#import <Test_Swift_Import-Swift.h>
But this SO post and this one too both say to use <ProjectName/ModuleName-Swift.h>. Because the code is in a module, this makes sense to me.
So I try #import <Test_Swift_Import/BFKit-Swift.h>
No deal...
I rename my project to TestSwiftImport in case underscores are a problem
No deal...
I try importing the module directly
<BFKit/BFKit.h>
Alas...
Relevant Xcode Build Settings
defines modules : Yes
Product Module name: TestSwiftImport
Enable Modules: Yes
Link Frameworks Automatically: Yes
Objective-C Generated Interface Header Name: TestSwiftImport-Swift.h
Objective-C Bridging Header: TestSwiftImport/TestSwiftImport-Bridging-Header.h
Drastic Things I've Tried
I've done all manner of cleaning project and build folder, wiping derived data, resetting simulator, quitting simulator, quitting Xcode and restarting machine, all to no avail. It's sad that these are even things I think of doing and that they sometimes work... But not in this case.
Github Demo Project Displaying Problem
...is here
Any ideas? There are even more failed attempts that you can see if you open the project. This can't be this hard...
I see that is problem of CocoaPods.
Now If I try drag file straight to xcode it will work normal. If you really need it. You can drag all file to project. Not use cocoa-pods now.
You can reference to this question: Question
Hope this help!

iOS 8 extension dependencies issues. Importing one project file to extension view controller

I am working on iOS 8 extension. I read many manuals and all of them just show how simple add extension to your app, and seems that's enough.
But here are many pitfalls:
After adding your extension you will need to import some of your classes to view controller that were created when you added new extension target. The big use here that you will need add all of them and if you have huge project it's not a simple task. Solution can be select extension target then in Build Phases -> Compile Sources press plus button and add all .m files to your target using hot key CMD+A.
After adding all files you can see that some of method wont work, and you can see this error: 'sharedApplication' is unavailable: not available on iOS (App Extension) so the solution can be a macros that check ifndef Extension then we can invoke sharedApplication code.
#import <Foundation/Foundation.h> vs #import <UIKit/UIKit.h>. So I have not figured out with this issue but when I replaced Foundation with UIKit it works for me and all related issues go away.
CocoaPods. All of us are using CocoaPods so if your extension need to use some part of your project code and that code use CocoaPods library then you need to add link_with 'ProjectTarged', 'ExtensionTarget' to Pod file and make pod install again to bind your libraries with new extension target.
So this is a main points I faced with. Maybe someone can suggest how to solve that issue, as I said I just import one needed file to extension view controller. The imported file contain some libraries like AFNetworking, RestKit and other nested classes from the main project. I need this class to invoke few methods with passing data from extension to my backend server. So one file but many issues.
you can use this in your Podfile to prevent "Require only App-Extension-Safe API". Just put it to the end of your Podfile.
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
1) You only need to add files to the extension target that you actually intend on using. I would recommend only pulling over what you need by finding the files and in the File Inspector, adding them to both targets.
2) Yep that's right. You'll need to update libraries that check that for you or fork them and fix them yourself.
3) I think you're referring to the default templates when creating one of the app extensions. Yes, you need to use UIKit not Foundation. Foundation will work for iOS or OS X, but clearly isn't enough if you are making a UIKit application.
4) The link_with command will make all pods in your Podfile link to all of the targets listed. If that's what you need, then, fine, do that. If you just need a small subset of pods for your extension, use the following:
target 'whateverTarget', :exclusive => true do
pod 'SomePod'
end
To remove sharedApplication issue from CocoaPods Libraries you just need to change Build Options within Build Settings for your pod.
Just type to search Require Only App-Extension-Safe API and then change the value to NO as it is on the image below:
Propably you will need to do this for every of your pods.

Missing required module 'CocoaLumberjack' in iOS 8 app / framework

I'm having a problem with integrating a cocoa pod (CocoaLumberjack in this case) into an iOS app and my own frameworks.
The Podfile looks like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.0"
target "CommonModule" do
use_frameworks!
# CocoaLumberjack wasn't officially released with Swift support yet
# pod 'CocoaLumberjack'
pod 'CocoaLumberjack', :git => 'git#github.com:CocoaLumberjack/CocoaLumberjack.git', :commit => '6882fb5f03696247e394e8e75551c0fa8a035328'
xcodeproj 'CommonModule/CommonModule.xcodeproj'
end
I have a hierarchy of modules (dynamic frameworks) like this:
CommonModule
ModelsModule (has a dependency CommonModule)
And finally, the main app:
MySwiftApp (dependency both ModelsModule and CommonModule)
Now, CocoaLumberjack is used in several files in CommonModule and works as expected. However, every time I do import CommonModule in any file in ModelsModule, I get the following compile error:
~/Developer/ModelsModule/ModelsModule/SomeFile.swift:2:8: error: missing required module 'CocoaLumberjack'
import CommonModule
^
Any idea how to solve this issue?
UPDATE: Some people Recommend to use Carthage. I would like to avoid that, if possible.
You'll also need to ensure that CommonModule.framework and CocoaLumberjack.framework (and any other frameworks) are listed in the Embedded Binaries section of your application target.
All the new iOS 8-style dynamic frameworks must be embedded within your app—even those that you aren't using directly, but that are dependencies of your dependencies—so you might end up seeing references to items you don't recognize.
Incidentally, there is a new Swift-based logging engine called CleanroomLogger that might make things easier if you're having trouble interacting with CocoaLumberjack from Swift.
I am assuming that CommonModule is swift and that your also using CocoaPods 0.36 as I see your calling use_frameworks!. I'm also assuming that you're using the Obj-C version of CocoaLumberjack, and trying to use it with Swift. That use_frameworks! flag tells CocoaPods to generate frameworks of the pods for linking in your Xcode project. So you need to say at the top of your class
import CocoaLumberjack
instead of using the Swift-Bridging-Header
Here is the blog post on cocoapods.org where they talk about the how to author a pod for the new use_frameworks! flag. Scroll down to the part Common Header Pitfalls
It could also be that your podspec creates a dependency to use CocoaLumberjack, and when linked to your project CocoaLumberjack and CommonModules, but Common Module is not referencing it correctly in the library. To get past that you need to refer to it as a framework when you import it into your Objective-C library
#import <CocoaLumberjack/CocoaLumberjack.h>

Xcode is not seeing addition to cocoapod

Added a new class and methods to the existing code in an imported pod.
I checked everything I could in the Utilities for this new class.
Location of .h and .m file is selected as 'Relative to project' like all other files in this pod
actual files are in the same path as the other file of this pod
target membership is same as pod.
Xcode is not seeing the addition of the new class (h file in an import statement in the project using the pod).
Not sure why it doesn’t work for you, but aside from that you should not modify the Pods.xcodeproj. CocoaPods assumes it has control over it and will wipe out your changes on the next pod install or pod update. (Maybe that’s the problem your seeing?)
Either add the custom class to your own project, extend the library with categories in your own project, or have a fork of the library where you push your changes to (possibly by using the :local directive in your Podfile).

Resources