Restkit, Stop Logging? - ios

I am wondering..
Restkit keeps showing reachability information, request information as i use it. Will this automatically stop in production version or do i need to do something to stop them from displaying like setting RKLog level?
thanks

To turn everything off add this to your app delegate.
RKLogConfigureByName("*", RKLogLevelOff);
Note: At least in RestKit v0.20.x you will still see a "RestKit logging initialized..." message in dev builds.

To suppress just the Reachability messages, use this:
RKLogConfigureByName("RestKit/Network/Reachability", RKLogLevelCritical);
Look in lcl_config_components.h for the complete list:
"restkit" "RestKit"
"restkit.network" "RestKit/Network"
"restkit.network.cache" "RestKit/Network/Cache"
"restkit.network.queue" "RestKit/Network/Queue"
"restkit.network.reachability" "RestKit/Network/Reachability"
"restkit.object_mapping" "RestKit/ObjectMapping"
"restkit.core_data" "RestKit/CoreData"
"restkit.core_data.cache" "RestKit/CoreData/Cache"
"restkit.core_data.search_engine" "RestKit/CoreData/SearchEngine"
"restkit.support" "RestKit/Support"
"restkit.support.parsers" "RestKit/Support/Parsers"
"restkit.three20" "RestKit/Three20"
"restkit.ui" "RestKit/UI"
"restkit.testing" "RestKit/Testing"
"app" "App"

The logging messages in a RestKit app are controlled by the RKLog calls. For example:
RKLogConfigureByName("RestKit", RKLogLevelWarning);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
RKLog is implemented with Aren Harren's lcl_log (see http://0xc0.de/LibComponentLogging) library. I just briefly looked through the code for lcl and I didn't see any code that would prevent it from printing in a production version, so I would ensure that my RKLog code does not appear in production code.

RestKit is configured to show info messages and above in DEBUG builds. In non-DEBUG builds, only warnings, errors, and critical messages are logged. This is defined via RKLogLevelDefault in RKLog.h.
If you want to change the log level for one of RestKit's log components, you can call RKLogConfigureByName(component, level) with the component name and RKLogLevel log level. RKLogConfigureByName("*", RKLogLevelOff) can be used to disable logging for all components. Ensure that RKLogInitialize() was called before, because RKLogInitialize() overwrites the log level settings for RestKit's components on the first call.
If you want to remove all logging code from your production build, you can simply add the preprocessor define _LCL_NO_LOGGING to your build settings. See http://0xc0.de/LibComponentLogging for details.

Kyle's solution is correct. The Swift version is a little bit different:
RKlcl_configure_by_name("*", RKlcl_vOff.rawValue)

Related

Mixpanel integrated in iOS SDK is not sending events

​I have an iOS SDK project with lots of modules (in Objective-C).
I want to start tracking events to see how my clients use our SDK but I can't see anything in the insights tab. What am I doing wrong?
 
In the point of entry to the SDK I have added this (just following the docs):
[Mixpanel sharedInstanceWithToken:#"myTOKEN"];
self.mixpanel.serverURL = #"https://api-eu.mixpanel.com";
[self.mixpanel track:#"Video play" properties:#{
#"genre": #"hip-hop",
#"duration in seconds": #42,
}];
I can see with breakpoints that the code it’s executed, however my insights are completely empty.
I also tried adding events with the codeless tracking, and while it looks like it’s working and I can connect to the app, the events aren’t appearing in the insights tab.
 
​
I think you need to assign the shared instance to your local property if that hasn't been done outside of the code you've posted.
[Mixpanel sharedInstanceWithToken:#"myTOKEN"];
self.mixpanel = [Mixpanel sharedInstance]; // assign here
self.mixpanel.serverURL = #"https://api-eu.mixpanel.com";
[self.mixpanel track:#"Video play" properties:#{
#"genre": #"hip-hop",
#"duration in seconds": #42,
}];

Network extension view print statements

I am implementing a NEPacketTunnelProvider and loading it from my view controller using:
var vpnManager: NETunnelProviderManager = NETunnelProviderManager()
...
let providerProtocol = NETunnelProviderProtocol()
providerProtocol.providerBundleIdentifier = "AA.BB.CC"
providerProtocol.serverAddress = "<something>"
...
self.vpnManager.localizedDescription = "My app"
self.vpnManager.protocolConfiguration = providerProtocol
self.vpnManager.isEnabled = true
self.vpnManager.connection.startVPNTunnel()
Parts marked with "..." seemed irrelevant.
My understanding (although it's really not clear in the documentation) is that when I do this, and I have a target that was created as type "NetworkExtension" with BundleId AA.BB.CC, that the extension would be loaded and executed properly. So, my understanding is that startTunnel (from NEPacketTunnelProvider) will implicitly be called from the code block above.
I put a NSLog("STARTING TUNNEL!!!!!") right at the top of the startTunnel method, but am not sure where to see that. So far, I have viewed the logs in:
Console
Window > Devices and simulators > View device logs
None of these appear to show the logs from within the extension. The problem is that the extension seems to crash before I can attach to the running process, so I have the feeling I'm just "missing" that log because I can't attach quickly enough.
Short question
How can I attach to a running network extension quickly enough so that I don't miss an NSLog that is run immediately?
The logs from Network extensions do not go to Xcode console. to see the logs from Network extension you have to follow the bellow steps.
Open the console application.
Select your iOS device running the network extension you will see all the logs from your device.
Filter the logs by Network extension target name now you will see the logs only from your network extension.
How can I attach to a running network extension quickly enough?
What I have been doing to solve this problem was, put the thread on sleep right before log statement.
sleep(60)
It will give you enough time to attach the Network Extension process for debug.

For plug in running on iOS

What I want to implement is as follow:
A-app (calling app) : request the return value of a-string sent as parameter : request(a-string) -> b-string.
B-app (plug-in installed separately by me or others, it plays the role of dictionary or database ) : search a-string from database and return the result (b-string).
With successful experiences of plug-in on android and with Apple's confident rhetoric of plug-in, I thought plug-in, of course, run on iOS. After a lot of hard work, however, I finally found out:
* Note : The creation and use of loadable bundles is not supported in iOS.*
Nonetheless, not giving up, I finally made it with custom URl and pasteboard:
A-app : write a-string and false state to pasteboard & call B-app via custom URL.
B-app : viewDidLoad runs following func and thereafter exit program ; func { read pasteboard and search from database & write the result(b-string) and true state to pasteboard }
A-app : while-loop detects whether state is false or true. if true, catch b-string from pasteboard.
Anyway it works but it's too long thus almost useless. Do you have any idea for better solutions? Why doesn't Apple allow plug-in for iOS? Any responses are welcome. Thank you.
I can't answer why Apple doesn't allow plug-ins, but I can offer some advice on what you're trying to achieve.
The common pattern for sending data back to your application is to implement a callback url, so the A-app would also implement a custom URI and add that to the uri sent to B-app.
B-app would then process the uri as you have already implemented, but then instead of exiting, it simply sends the data you requested in the uri passed to it.
See http://x-callback-url.com for more details and example implementations.

How does phoneGap (Cordova) work internally, iOS specific

I have started developing html applications for mutliple platforms. I recently heard about Cordova 2.0(PhoneGap) and ever since I have been curious to know how the bridge works.
After lot of code walking, i saw that the Exec.js is the code where call from JS -> Native happens
execXhr = execXhr || new XMLHttpRequest();
// Changeing this to a GET will make the XHR reach the URIProtocol on 4.2.
// For some reason it still doesn't work though...
execXhr.open('HEAD', "file:///!gap_exec", true);
execXhr.setRequestHeader('vc', cordova.iOSVCAddr);
if (shouldBundleCommandJson()) {
execXhr.setRequestHeader('cmds', nativecomm());
}
execXhr.send(null);
} else {
execIframe = execIframe || createExecIframe();
execIframe.src = "gap://ready";
But want to understand how that works, what is the concept here, what does file:///!gap_exec or gap://ready do? and how does the call propgate to the lower layers (native code layers)
thanks a bunch in advance.
The trick is easy:
There is a webview. This displays your app. The webview will handle all navigation events.
If the browser navigates to:
file:///!gap_exec
or
gap://
the webview will cancel the navigation. Everything behind these strings is re-used as an identifier, to get the concrete plugin/plugin-method and parameter:
pseudo-url example:
gap://echoplugin/echothistext?Hello World
This will cause phonegap to look for an echoplugin and call the echothistext method to send the text "Hello World" to the (native) plugin.
update
The way back from native to javascript is (or may be) loading a javascript: url into the webview.
The concrete implementation is a little bit more complex, because the javascript has to send a callback-id to native code. There could be more than one native call are running at the same time. But in fact this is no magic at all. Just a number to get the correct JSON to the right javascript-callback.
There are different ways to communicate between the platform and javascript. For Android there are three or four different bridges.
I am trying to figure this out in more detail, too. Basically there are 2 Methods on the iOS side that can help ...
- webView:shouldStartLoadWithRequest:navigationType: and
- stringByEvaluatingJavaScriptFromString:script
From the sources it seems cordova sends a "READY" message using webView:shouldStartLoadWithRequest:... and then picks up results with the second message, but I am not sure.
Cordova Sources iOSExec
There is much to learn there.

xtaskcreate-getting error

Hello I am working on EZ430-RF2560T target board attached to debugging interface (attached to USB of PC) for the Tux Racer game application (MSP430BT5190 target board ). I am working on the accelerometer application code. After the bluetooth is turned On it gives the message "unable to create task " for the function
xTaskCreate((pdTASK_CODE) user_task_routine,
(const signed portCHAR *)USER_TASK_NAME,
USER_TASK_STACK_SIZE, (unsigned portLONG *)NULL,
(unsigned portBASE_TYPE)USER_TASK_PRIORITY,
(xTaskHandle *) NULL);
Please let me know what could be done.........
Thankyou
Ashwin
Hard to say without more info or code. Looks like the task create line is straight from some dummy documentation or sample. Have you defined all the relevant parts such as USER_TASK_NAME, USER_TASK_STACK_SIZE, USER_TASK_PRIORITY, and especially the function user_task_routine?
Were there any compiler errors in this module?
The name "user task" sounds rather generic, maybe you might consider a descriptive name :)
Are other demo tasks running on the board? You might compare your task to them and see how they are started.
Could you simply be running out of memory? Try disabling some of the other tasks and starting only your task.
There is also a support community at freertos.org that tends to provide helpful responses.

Resources