how to see NSLog in my SDK project under iOS 10 - ios

I have a SDK project which will compile and build a framework. Inside this project, I have my person NSLog shown there. I have another framework test app to using this framework to do my task. After upgrading to iOS 10 and Xcode 8, I notice all the NSLog are gone. I cannot find it anywhere.
I search and find this answer: iOS 10 doesn't print NSLogs, I gave a try for both my SDK project and my framework test app, adding OS_ACTIVITY_MODE "disabled", however, it is still not showing NSLog.
Update: I still have one device which is iOS 9, I gave a try on that one, NSLogs are still shown in device console. Using Mac's console app I can also see my own logs.
This is a MFI project so I cannot directly debug this project, because the lighting cable is always connected with my hardware. I can only use log to see what happened.

OS_ACTIVITY_MODE set as disable remove OS activity state which is printed during the when project is runs. OS_ACTIVITY_MODE is only printed only in the x-Code 8.0 but when you upgrade your x-codefrom 8.0 to 8.1 you can found that it does not print any console for OS. But in overall procedure I have found that NSLog is working properly.
For your confirmation i just update my old project and run it into x-code 8.1. Output as below images
Environment variable
Nslog Code
console print
Suggestion
I have checked your problem in multiple style with multiple project but I didn't found any problem. So I just suggest you
To update your x-code
or
Re-install x-code after removing previous x-code completely.
Because If it is x-code bug them i also have to face the same in my every experiment.
If you still have any query you can ask.

Apple did some changes the way NSLog works and I probably you might not be able to get them.
My recommendation is that you change your NSLog to something that prints to the output console without using NSLog.
I'm the co-founder of a product called Bugfender that might help you, what we do is that we provide a BFLog function that will print the logs to the console and also upload them to our servers, so you can always check the logs without any need to connect the device to your computer.
The only problem our product has is that it's not in real time, but usually there's a delay of a few seconds. Some of our customers are using it to debug the app instead of using the XCode console.

If you set this,you can not see any log in your device ,but you can see that in simulator.

Related

Firebase Crashlytics won't activate

I have run my app on a device and in simulator with no success of updating the Firebase Crashlytics system.
I am not getting any errors, and I know that it's installed because it says the version number (4.5.0) in console.
Also Firebase Analytics is working.
I have followed the install guide to a T and also tried to force crash it by creating a SwiftUI button and using
fatalError()
Which seems to not fully crash the app, but more freeze the app.
I am wondering how I can trace this issue with SwiftUI and Firebase.
In addition of doing what the accepted answer recommends and I believe this is something new from Xcode 12.+. You need to uncheck the two checkboxes below the script window (at least once - you may tick them back up once registered with firebase). This (as stated) forces the script to run and therefore to communicate with firebase... the checkboxes unticked
As outlined here, if you're going to use the Xcode Simulator, you must detach the Xcode debugger at runtime by launching the app directly from the Simulator and not Xcode. Xcode automatically attaches its debugger if you launch from Xcode to a Simulator, blocking Crashlytics from being able to see exceptions/crashes.

How to debug an app run from the iOS simulator directly? (not from xcode run)

we all know that if we build and run an app from XCode, we can see all the debugging, but what if we want to debug an app preinstalled on iPhone Simulator, I can't seem to find a way to do this, is this possible? how?
I tried iOS Console, but it doesn't seem to even work, the beta has expired.
thanks
If you just want to see the log output (e.g. NSLog()), see the following answer explaining where to find the simulator's system.log file.
https://stackoverflow.com/a/10165649
Note that if you are using Swift, "print" statements will not be written to the log file; they will only be displayed in Xcode's console.
the best way for me was
tail -f /Users/userName/Library/Logs/CoreSimulator/appID/system.log
it prints all data into mac terminal even though if you are not running the app from XCode or something, I wish I knew that before...

Internal API error

Since few days, every time I try to run my app on my iPhone, I get get this error message "There was an internal API error".
I'm getting this error just with one application only on my iPhone. In fact, there's no problem with the same app on simulator or on my iPad. No problem too with other apps on my iPhone...
I've tried many things mentioned in those threads:
"There was an internal API error." while running an app on any iPhone/iPod-touch device
Xcode 4.4 - There was an internal API error
like remove/re-run the app, reboot iPhone/mac, clear cache, check plist, check profiles, check build settings, restore iPhone.
I'm using xCode 7.1.1 and iOS 7.1.2
Can someone point me on what I forget to check please ?
As per my work and research I got a solution. Since I was preparing the build in manual way from product. In that case my appname.app was copying in folder from which I have to create a build, that app was not copied properly and I prepared the build and installed in my device, in that case I got this error.
I again clean the Xcode prepare the build properly and installed it, it works.
When I rename my project and delete the special character "ç", xCode success to run the app on my iPhone. It might be related to xCode 7, before there was no problem for compiling.
I also had this problem. The way I solved it was by removing the special characters from the Product Name (in Build Settings) - I had an 'æ'. Indeed, it looks related to Xcode 7, because it used to work on previous versions of Xcode.

How to debug iOS 8 extensions with NSLog?

- (void)viewDidLoad
{
NSLog(#"%s", __func__);
// ...
}
in viewDidLoad of an iOS 8 extension. the NSLog outputs nothing in Xcode. NSLog works as usual in the container app though.
How can I get output from debug messages from an extension?
Debugging works for app extensions.
It works on simulator too.
If your app ext crashes in the simulator, you may find it is not easy to restart your app ext. Restarting your simulator is a quick solution.
Steps to debug an app extension:
Run the container app. In this step, Xcode uploads the container app and app extension to the device or simulator.
Stop the container app. This step is important when you debug in simulator. If you don't do it, Xcode will tell you the simulator is in use.
In Xcode, press menu Debug -> Attach to Process -> By Process Identifer (PID) or Name..., input the app ext's identifier, e.g. com.abc.ContainerApp.MyExtension, to start debugging. Don't forget to set break points. (Update on Aug 25, 2014: you can input MyExtension(your extension's name) directly.)
In the device or simulator, open your app extension.
Updates on Aug 23, 2014:
I found the debugging steps above do not work well on Xcode 6 beta 6 with iOS 8 SDK beta 5 on the simulator.
Solution:
Run your extension in the simulator.
Xcode menu Debug -> Attach to Process -> Choose "MyExtension(your extension's name)" in System section in the menu.
The breakpoints work. But I don't know why logs do not show in the output window.
I'm having this problem too. It works for me if you go in your Simulator under the menu Debug -> Open System Log...
From here you can see all the logs of the iPhone Simulator (included your extension's logs).
NSLog is working perfectly.
You just don't see what is being logged in the debug area of Xcode because the Xcode debugger isn't attached to your extension. Extensions are nearly completely independent from their containing app. They have separate bundle identifiers, for example, and they also are separate processes on the OS.
I have had varied success in getting Xcode to attach to extensions. Supposedly it seems it would attach automatically, and it appears in the debug navigator as "Waiting to attach", but never attaches.
Sometimes, I am able to run my extension target in Xcode:
And then have the option to choose what application to run my extension in. In this case, I would choose its recommendation of "today", which is notification center.
And then it would sometimes attach the debugger to my extension. Note this method only works on physical devices, it seems.
If it doesn't attach you can use the manual attachment method in #VinceYaun's answer,
I have also had varied success using other methods of attachment. Most have been unsuccessful, and it seems they are just bugs that will be fixed at a later date.
To view your log messages you go to Window -> Devices in the top bar and select your device. You can bring up the device log from the bottom of that window. If you are testing on a simulator, you can use #BalestraPatrick's answer.
Some of the bugs have been fixed in Beta 2, and my guess is that eventually the debugger will attach automagically when launching the extension.
Update: In the iOS 8 Beta 4 release notes:
Extensions
Fixed in beta 4
Extensions sometimes fail to launch when debugging from Xcode.
When Extension with UI is killed, it relaunches and is not dismissed.
Sometimes your Sharing or Action extension can hang.
Redeploying an extension may disable it in Notification Center.
I'm having this problem too. Xcode never attaches my debugger to the extension or displays NSLog messages. If you attach your Xcode debugger manually to your extension process, at least breakpoints work like a charm:
Debug->Attach to process->Your extension name (mine was "com.example.MyExtensionApp.MyExtension")
Create scheme for your extension
Run scheme
In a dialog choose container app
Enjoy
It works for me :)
Xcode 8 is able to debug extensions:
Choose the extension scheme in the combo next to the stop button and run it.
Select the parent application in the dialog that appears.
Result: breakpoints and log work as usual.
What finally allowed me to see the log in the debugging area, based on Michael's suggestion and Apple's documentation, is:
Build & Run the app extension in the simulator and, when prompted for a host app, choose the specific app that you're going to call the extension from. In my case I was launching my Action extension from Safari by pulling up a share sheet on a PDF.
What wasn't working before was following other people's suggestions of using Today as the host but then leaving that app and going over to Safari to call my extension. I no longer even need to run my containing app first before running the extension.
From Apple's Documentation:
In your extension scheme’s Run phase, you specify a host app as the executable. Upon accessing the extension through that specified host’s UI, the Xcode debugger attaches to the extension.
I actually got the logs to run quite simply in Xcode 6.3. Firstly, build and run the containing app. Once the containing app is running on the device, build and run the app extension by changing the scheme to the app extension.
Apple has documentation directly related to debugging, profiling and testing your app extension.
A trick which works for me (although it is quite an ugly one) is to place a dummy UILabel somewhere in the bottom corner of my extension. I usually call it logLabel. It is then possible to update the text of this label with any log statement that you want to get logged. Such approach is not very good if you need to log statements from instances of different classes. And, obviously, it clutters your UI.
However, if you have a fairly simple widget and you don't mind about slight cluttering of the UI this does the trick. I have tried all other solutions outlined in this discussion and, sadly, none of them worked for me.
The only way debugging works for me is by selecting Debug->Attach To Process By PID or Name
Then enter the PID not the extension name.
You can find the PID by running the extension on a device, go to Window->Devices. Find your device and viewing the console. When you see the name of your extension, its followed by 5 digit number. That is the PID
I also put a bunch of NSLog's in the extension in order to find the PID as well.
This is on xCode 7
Encounter the same problem about extension for NSLog, and break points. I have fought it with many days.
Device log can be found as following image. It is at XCode -> Window -> Devices and Simulators.
After enter the Open Console, there is a search field at the top-right of dialog. I can apply filter rule in there. For example, a process name contains Notification key word, or process name must equal to the name of extension target, ex: equal to MyNotificationServiceExtension process name.
Clearly something is broken in Xcode6-B5.
If I try to run a Photo extension on the Simulator I cannot see any Photos.app as an option for the extension attaching process.
The same, running on a real device, give me the correct behaviour.
In the first case any breakpoint is not honorated. In the latter case, breakpoints work like a charm.
You should know that the container app and extension are totally two difference process in iOS while the LLVM debugs only a thread a time, so when you are debugging, the console never log the extension and never stop at breakpoint.
You can solve most of the problems by #Vince Yuan's method.
However, my problem is that Xcode debugger hardly hook on my keyboard extension on both iOS Simulator and devices, like 1 time in 7-8 runs, It's totally a matter of probability. #Vince Yuan's method also work for just sometimes.
My little experience is that when you run you debug scheme, if the debug Session in the left panel showing that 'No Debug Session', there is no need to open your extension and test it, the debugger didn't hook on, just run again for lucky.
but when you see com.xxx.xxx.xxx is waiting to Attach, the extension can definitely get debugged.
This is a little trick for whom cannot debug iOS extension, especially keyboard extension.
As of Xcode 6 Beta 5, I've been able to use an actual device running iOS8 to debug my extension. Try running it on a device and select Safari to launch into
To overcome all the states caused by ever changing IDE, I'm using iOS Console by lemonjar.com – it displays a console window for any connected iOS device rendering syslog messages regardless the process ID. You can see both app and extension debug log messages at once here.
I could debug my extension with the way I describe below:
Xcode : Debug -> Attach to process by PID or Name. Your extension scheme name.
Then select your main app target and run.
I hope it also works for you guys.

Crashlytics is not sending Crash report from iPhone

I've setup the Crashlytics in my one iOS application and installed the application on a real device. My Crashlytics Dashboard is displaying that, I've successfully added the app. However, it's not sending crash report. My internet speed is not so good. But I can check my emails from this device. Can anybody guess, where is the problem?
Xcode debugger does NOT allow Crashlytics to process crash reports. Yeah, that seem weird even to me when I read that first time but it is a fact (Source). That's is the reason we never see crash report When:
- running app in Simulator
- running app on iDevice by directly build and run from Xcode with debugger on.
To make sure a crash is reported during your testing (copied from Crashlytics support site):
1. Launch simulator
2. Press stop
3. Launch your app and force a crash
4. Relaunch the app from simulator
5. See the crash report in the web dashboard.
EDIT:
Added a reference; Crashlytics also provides a short article on a quick way to force a crash.
My be it's late but work 100%
Make some changes in project build settings like in below image
and follow these instructions.
The primary reason any crash reporter won't work on iOS is due to interference from different crash reporters. However, with Crashlytics specifically there could be something specific to them causing the crash report not getting reported.
Xcode debugger does NOT allow Any Crash Reporter to process crash reports. This is because XCode overrides any hooks into the crash handling call backs. This only happens when:
running app in Simulator (with debugger on)
running app on iDevice by directly build and run from Xcode with debugger on.
To make sure a crash is reported during your testing (http://support.crashlytics.com/knowledgebase/articles/92523-why-can-t-i-have-xcode-connected-):
Launch simulator
Press stop
Launch your app and force a crash
Relaunch the app from simulator
See the crash report in the web dashboard.
While a super old video it's still relevant, here's a video of the steps above (example from Crittercism): https://www.youtube.com/watch?v=sU6Su3PBFH4
For me, the problem was that the device was connected to my Mac :)
From this source:
Also, if you have your device connected to your Mac, XCode's debugger
will step in as well. So just disconnect the device before testing :)
I found solution using following steps
1. Go to Edit Scheme
2. Run -> Info
3. Change Build Configuration to release.
Now run the app crash it. You will receive mail.
We recently ran into this issue and I found that somewhere along the way the build script was removed. Adding it back in with the following fixed the issue for us:
./Crashlytics.framework/run <your_api_key> <build_secret>
Note : When using Cocoapods you will want to us the following instead of the above (source):
./Pods/CrashlyticsFramework/Crashlytics.framework/run
Adding a build script:
To add a Run Script Build Phase in Xcode 6, select your application target in your project, then select "Build Phases".
Click the small "plus" icon and select "New Run Script Build Phase".
You should now see a Run Script section in the middle of your Build Phase options, as shown above.
Inside the body of the Run Script Build Phase, paste in the script.`
The above quote comes from Crashlytics's visual tutorial, referenced in this post.
Note: I originally posted this answer verbatim for Crashlytics error code: 202 when Submitting files.
From the RayWenderlich site:
You won’t get any crash reports if Xcode intercepts the crash event!
To make all the examples below work, you have to build and run the
application, then click the stop button on Xcode. This way you will
have the latest version installed on the the device. Once that is
done, you can launch the app on the device itself, and then crash it
all you want! All the crashes on your iOS device will be caught and
sent to the server component of the service that you have integrated
into the app. Crash reports are usually sent to the server the next
time you start the app, so the steps to follow to generate a crash
report on the server are as follows: Build and run on Xcode. Press the
stop button. Run the app on your iOS device. Make the app crash. Run
the app again.
Crashlytics works for me until now.
I don't know why but now it doesn't work.
You should turn debug-mode on by
[Crashlytics sharedInstance].debugMode = YES;
My problem is here Crashlytics error code: 202 when Submitting files :(
Make sure you are not forcing the crash too early.
Set [Crashlytics sharedInstance].debugMode to YES;
Watch for
Crashlytics] Settings loaded
on the Xcode console logs.
Then force the crash and restart the app, and the crash will be reported now.
I ran into a similar problem when trying the test crash code.
Crashlytics.sharedInstance().crash()
I was running my app from a device, without Xcode, and the crash wouldn't show up on Crashlytics Dashboard. What worked for me was the following tip from Crashlytics website:
Make sure to launch the app after crashing it, so that the crash can
be uploaded
I commented out the above crash() call, and re-ran the app. Then the crash showed up in the Dashboard.
This is for xcode 9, from crashlytics 3.4.0
After doing this, be patient and wait for a few minutes.
Have you tried running [[Crashlytics sharedInstance] crash] on a device and seeing if that gets reported? There are a few reasons why Crashlytics might not work including other crash reporters etc.
If you don't upload the dSYM file, Crashlytics will not show your crash even though the report successfully uploaded.
You could run into this problem, if you have set up your build-script to only run on your CI server. Then if you have copied your app to your phone via xcode and you run it without being attached to the debugger, the report will be uploaded but ignored, because of the missing dSYM file.
Sometimes, it takes some time for the logs to show up. I am able to find them after 15-20 mins
One of the issue I feel that in the Run Script Phase, it should be a separate Run Script Phase for CrashLytics. When had the run script
./Fabric.framework/run
With some of my other script, everything was ok, CrashLytics log show report submitted, but nothing was in the web interface.
When I add another Run script phase only with Fabric run, it appears like a magic :)
My first try was with cocoapods, but that did not work.
When I manually add all the framework and a separate run script phase that worked.
This worked for me,
If you're testing on iDevice, just unplug iDevice with your Xcode and run your app.
Now, If crashed it will be updated on dashboard.
I solved by deselecting "Run Script only when installing" option in Run script (one for Fabric(crashlytics))

Resources