I'm trying to integrate CocoaLumberjack into an existing project (so that I can get better logging on a customer's machine who is reporting a bug I can't duplicate). I've successfully built a sample project and got it to work in that, but it seems to do nothing in my own app.
I've copied the Lumberjack directory to my project directory and added that to the project. I've added the following to my 'Prefix.pch' file:
#import "DDLog.h"
#import "DDASLLogger.h"
#import "DDTTYLogger.h"
#import "DDFileLogger.h"
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
I've placed the following in -applicationDidFinishLaunching:
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
Finally I have the following in -awakeFromNib
NSLog(#"%#", #(ddLogLevel));
NSLog(#"%#", #(LOG_LEVEL_VERBOSE));
NSLog(#"%#", #"About to DDLog");
DDLogError(#"This is an error.");
DDLogWarn(#"This is a warning.");
DDLogInfo(#"This is just a message.");
DDLogVerbose(#"This is a verbose message.");
NSLog(#"%#", #"Done with DDLog");
The console shows:
2014-05-26 14:57:13.530 [21943:303] 31
2014-05-26 14:57:13.530 [21943:303] 31
2014-05-26 14:57:13.530 [21943:303] About to DDLog
2014-05-26 14:57:13.531 [21943:303] Done with DDLog
I've tried stepping through the library's source code, but it's honestly above my head. Any assistance in figuring out what I'm doing wrong would be greatly appreciated.
Related
I am having a bit of trouble. I am attempting to install Google Analytics into an app and am consistently getting the use of unresolved identifier GGLContext and GAI error. I receive the same error whether I am using CocoaPods or not. The location of the error is in the AppDelegate.swift here:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
// Optional: configure GAI options.
let gai = GAI.sharedInstance()
gai.trackUncaughtExceptions = true // report uncaught exceptions
return true
}
Nothing additional is able to be imported into the AppDelegate.swift(such as Google), just the standard UIKit.
I have been through many tutorials and other SO questions, all to no avail. I figure that there is some small thing I am missing, but cannot find it.
What I've done:
I have the .h files in my project, along with libGoogleAnalyticsServices.a, libsqlite3.0.tbd, libz.tbd, libsqlite3.tbd (all of which have been linked to library as well as CoreData and SystemConfiguration).
You can see the layout of all these files here:
and here:
I have created the -Bridging-Header.h and included these .h imports in it.
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
The -Bridging-Header.h is linked in the Build Settings and I receive no errors with that. That is the main solution that I have found during my research, which hasn't helped me in this situation.
I have tried to start over from scratch twice with CocoaPods and without (I made a copy of my project before starting) and I received the same error each time.
Any help would certainly be appreciated. Thanks in advance.
Well, it looks like I was able to get it squared away.
There were several problems with all attempts on this.
Cocoapods had not installed correctly. I reinstalled and then had better success importing the correct files.
Doing it manually, as I posted above is not the best option.
After the Cocoapods re-install and starting over from a fresh copy of my project, I was able to import Google into my AppDelegate.swift.
Key points for those who may end up in the same boat I was in:
Be sure to add the correct directory for your -Bridging-Header.h. You can find this under Project - Build Settings - Swift Compiler Code Generation. Use this to easily target your header file $(SWIFT_MODULE_NAME)-Bridging-Header.h
In your -Bridging-Header.h, do not #import <Google/Analytics.h>, instead import the files individually. Here is an image of the files available to be imported.
When in doubt, reinstall Cocoapods
Do not trust Google tutorials to provide the most effective instruction and utilize the many SO posts on the topic.
I really hope this helps someone not spend 10 hours on the problem as I have.
Swift 4.0 and xcode 9.0.1 finally I resolved.
For me after 2 days I resolved.. Don't follow Google's old documentation says #import <Google/Analytics.h>
Go to Terminal type pod init
Reopen project as workspace obvious after pod workspace is created, open podfile. write pod 'GoogleAnalytics' in your pod file before target 'GoogleAnalytics' do
Go back to Terminal pod install you will find frameworks GAI.h and other files will be there under pods folder
Create Header.h file to your root. Don't add #import <Google/Analytics.h> instead import following individually in bridging header file
e.g. in bridging header file remove #import <Google/Analytics.h>
#import GAI.h
#import "GAITracker.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
Point your bridge under Build Settings for target Swift Compiler - General -> Objective-C Bridging Header. write Header.h of your bridging file name
Add code from google for swift to didFinishLaunchingWithOptions Don't forget to replace your tracking id from Google Analytics page
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
gai.logger.logLevel = .verbose;
Tada.... Run your project...
My error was use of unresolved identifier when i was using the singleton GAI.sharedInstance().
My steps to bring this to work were:
add pod 'Google/Analytics'
pod install
restart xcode
create a objc class in my project to get a bridging header
added #import "GAI.h" in to the bridging header file
everything works perfectly.
This works for swift 2.3, swift 3.0 and swift 4:
add the GoogleService-Info.plist file to the root of your project
add this to the podfile:
pod 'Google/Analytics'
quit Xcode, run "pod install" in terminal and open Xcode again
create a header file in the project root, named Bridging-Header.h, under build settings make sure the bridging header is defined like in the picture
make sure your Bridging-Header.h looks like this:
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import <Google/Analytics.h>
#endif /* Bridging_Header_h */
add to AppDelegate:
import Google
add this code to AppDelegate in the didFinishLaunchingWithOptions method:
// Configure tracker from GoogleService-Info.plist.
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services:\(configureError)")
// Optional: configure GAI options.
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.trackUncaughtExceptions = true // report uncaught exceptions
gai.logger.logLevel = GAILogLevel.Verbose // remove before app release
If there are errors, deleting DerivedData and cleaning the project can help.
The only way to make it work for me was downgrade Google Analytics pod version to 2.0.4.
pod 'Google/Analytics', '~> 2.0.4'
So I'm using skobbler/scoutmaps version 2.3 and I'm trying to include skmaps with SKMaps like so:
#import <SKMaps.h>
But I'm getting a SKMaps.h file not found error. In my pod I see that file and I've tried changing my header search paths but it's not working. Any help or ideas as to why this is happening would be appreciated. The other header files from skobbler and the other pods seem to work fine.
So I figured out it's supposed to be #import in case anyone else ran into the same issue.
Hi I am using EmailcomposerWithAttachments Plugin from phonegap plugins. I am using Phonegap-2.3.0 and ios6 Simulator and latest Xcode.
I have placed the .m, .h files in Plugins folder of project and Js file in WWW folder and calling the plugin using
window.plugins.emailComposer.showEmailComposer("Look at this photo","Take a look at <b>this<b/>:",["the.das#gmail.com", "dasthe#gmail.com"],[],[],true,[]);
js code as given in readme.md file. https://github.com/phonegap/phonegap-plugins/tree/master/iOS/EmailComposerWithAttachments
when i run it i am getting below error in Log.
-[CDVCommandQueue executePending] [Line 103] FAILED pluginJSON = ["INVALID","EmailComposer","showEmailComposer",[{"subject":"Look at this photo","bIsHTML":true,"ccRecipients":[],"attachments":[],"bccRecipients":[],"toRecipients":["the.das#gmail.com","dasthe#gmail.com"],"body":"Take a look at <b>this<b/>:"}]]
Please Let me know where I am doing Wrong.
In config.xml File <plugin name="EmailComposer" value="EmailComposer" /> I add this in plugIn
Thanks.
It seems that your plugin has been added correctly,but some error occur in plugin file. I think you may create another project in xcode and compile to check if bugs exist in the plugin.
Try to use "" instead of [] like this
window.plugins.emailComposer.showEmailComposer(
"Look at this photo", // subject
"Take a look at <b>this<b/>:", // body
"the.das#gmail.com,dasthe#gmail.com", // toRecipients
"", // toRecipients
"", // bccRecipients
true, // bIsHTML
);
in code, we expect string for separate then by #","
...
[picker setToRecipients:[ toRecipientsString componentsSeparatedByString:#","]];
...
I hope this helps
I know these questions have been asked before but everything suggest using GNUStep. Is there a way to use Foundation without GNUStep? This is also a learning question for me (like if it's possible to do by linking files or something)
I have Cygwin and gcc installed. I got all the Libraries from CocoaTron as in here: http://code.google.com/p/cocotron/source/browse/
I added the library folder to the OBJC_INCLUDE_PATH and the C_INCLUDE_PATH and it doesn't complain about not being able to find Foundation.h anymore.
But I get other errors like:
$ gcc intro.m -o intro
In file included from /cocoa/CoreFoundation/CFBase.h:144,
from /cocoa/CoreFoundation/CFAttributedString.h:8,
from /cocoa/CoreFoundation/CoreFoundation.h:42,
from /cocoa/Foundation/Foundation.h:37,
from car.h:1,
from intro.m:2:
/cocoa/CoreFoundation/CFString.h:88: error: parse error before "va_list"
In file included from /cocoa/Foundation/NSAffineTransform.h:9,
from /cocoa/Foundation/Foundation.h:41,
from car.h:1,
from intro.m:2:
/cocoa/Foundation/NSGeometry.h:9:32: Foundation/NSObject.h: No such file or directory
In file included from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/NSAffineTransform.h:9,
from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/Foundation.h:41,
from car.h:1,
from intro.m:2:
I'm sorry for the novice question, I was just interested in running a few test and didn't want to install GNUStep.
I mean, a really simple example like:
//car.h
#import <Foundation/Foundation.h>
#interface Car : NSObject{
}
- (void)addGas;
#end
#include <stdio.h>
#import "car.h"
int main(int argc, const char * argv[]){
printf("Hello");
return 0;
}
Yes, I know this example doesn't need objC ;) I was just trying to follow along with a tutorial.
Thanks for the help!
Looking at the Cocotron's requirements page and general information page, it seems that it only supports development on the Mac. What it provides is the ability to build a Windows- or Linux-compatible product… on your Mac.
So, as far as I can tell, at this time, you can't use Cocotron to develop on Windows. You'll still have to use GNUstep.
I'm fairly new to Compass, but I have been trying to use Compass in a project to generate my icon sprites. See this tutorial:
http://beta.compass-style.org/help/tutorials/spriting/
IMO, the tutorial isn't exactly clear. To start, the tutorial never tells you to create the "_icons.scss" file that contains the "all-icon-sprites" mixin.
#import "icon/*.png";
#include all-icon-sprites;
The result of this is an error:
"Syntax error: Undefined mixin 'all-icon-sprites'."
So I added the "_icons.scss" file to my project, and changed the code to:
#import "icon/*.png";
#import "_icons";
#include all-icon-sprites;
Now, I get this error:
Syntax error: Invalid CSS after " $delete-position": expected ")", was ": $icon-delete-..."
on line 28 of /path/to/_icons.scss
Can anyone explain to me what I'm doing wrong? Or is the problem actually with the "_icons.scss" file?
The tutorial doesn't tell you to import the _icons.scss, because it is not required. You either import the png files or the generated file -- not both. They are the same, except if you import the png files, you end up importing a generated stylesheet that is kept up to date automatically as the png files change (renames, added, removed, etc).
do you have any png files in the <images>/icon directory?
To be honest, this error is one I would expect to see if the compass version that is processing the stylesheet isn't the one you're using on the command line. Are you compiling with rails or the CLI?