[TIMOB-17867] iOS: NSLog Fails on iOS simulators
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2020-01-30T09:23:34.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Ingo Muschenetz |
Assignee | Muhammad Dadu |
Created | 2014-10-15T17:37:20.000+0000 |
Updated | 2020-01-31T10:45:14.000+0000 |
Description
After the recent updates to support Xcode 6, NSLog no longer works with ios-sim. The output of logging information is crucial for projects like tiO2 which require log output to see the results of testing.
This used to work in iOS 7, but we removed some functionality in this commit (https://github.com/appcelerator/ios-sim/commit/1c01fceb33428259308321989704bd1c790c2cca) because it was causing CPU spikes in iOS 8. Removing this (readInBackgroundAndNotify) fixed the CPU spikes, but it also removed the NSLog functionality on iOS 7. It never appeared to work on iOS 8 simulators.
We need to reproduce the CPU spikes and logging failures, and then see what code is required to make NSLog work again.
This application can help with testing the functionality: https://github.com/appcelerator/ioslib/tree/master/test/TestApp
To verify and fix this issue, you first must be able to reproduce the problem. You need Xcode 6, a native iOS app that does an NSLog(), and a simulator's udid. Run
ti info -t ios
to find iOS Simulator udids. You will want an iOS 8 simulator. I recommend an iPhone 6 simulator. Next, build the sample app from https://github.com/appcelerator/ioslib/tree/master/test/TestApp:This will launch the iOS Simulator and start the TestApp. The app will call NSLog() but there is no output, hence the bug. What worked for iOS 7 and older is adding the following to the stdioDataIsAvailable() function in ios-sim (https://github.com/appcelerator/ios-sim/blob/master/Source/iPhoneSimulator.m#L337-L351):
This line fixes NSLog() for iOS 7, but breaks in iOS 8. There is no logging in iOS 8 and the CPU spikes until the app is quit.
This might be saying the obvious, but NSLog with Xcode 6 in Obj-C on a iPhone 6 simulator works fine from Xcode. This is really looking like an AppC issue. steps to reproduce: create a new single page ObjC iOS app in Xcode. use the following code: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. NSLog(@"Logging in iOS8 simulators work. Your move Appc"); return YES; } Observe that it shows up in console in Xcode.
I believe the ticket illustrates the fact that the issue is with ios-sim, which unfortunately has to rely on a private, undocumented framework. Do you have a helpful suggestion as to how to fix ios-sim so that it may work again?
I just created a new titanium app (3.4.0.GA) using Xcode 6 with iOS8 simulator on OSX 10.9.5 ( 6 plus and 4s) and in titanium console.log will print to the console. I also just tried to reproduce Chris Barber's steps and I see how that fails. However, the phonegap fork of ios-sim does not have this problem. aka if you take Chris' test app and use the phonegap fork, you get logging back. https://github.com/phonegap/ios-sim
one thing to note, I made one modification to Chris' example app -- I removed the ifdef on TEST_BASIC_LOGGING
Is that perhaps related to commit https://github.com/phonegap/ios-sim/commit/aa583e9fefb6b8b8139da2327c6c3996a0fc6e83? Note that they also removed Xcode 5 support, which we can't just yet.
We no longer use ios-sim to relay log messages.
Ticket closed.