Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17867] iOS: NSLog Fails on iOS simulators

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2020-01-30T09:23:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterIngo Muschenetz
AssigneeMuhammad Dadu
Created2014-10-15T17:37:20.000+0000
Updated2020-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

Comments

  1. Chris Barber 2014-10-15

    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:
       git clone https://github.com/appcelerator/ioslib.git
       cd ioslib/test/TestApp
       xcodebuild clean build -configuration Debug -sdk iphonesimulator8.0 VALID_ARCHS="i386" ARCHS="i386" GCC_PREPROCESSOR_DEFINITIONS="TEST_BASIC_LOGGING"
       ../../lib/ios-sim launch build/Debug-iphonesimulator/TestApp.app --xcode-dir /Application/Xcode.app/Contents/Developer --udid <udid from ti info>
       
    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):
       [[notification object] readInBackgroundAndNotify];
       
    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.
  2. Andrew McElroy 2014-10-23

    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.
  3. Ingo Muschenetz 2014-10-23

    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?
  4. Andrew McElroy 2014-10-23

    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
        Debug-iphonesimulator git:(master) ✗ pwd
       /Users/andrewmcelroy/Desktop/ioslib/test/TestApp/build/Debug-iphonesimulator
       /Users/andrewmcelroy/Desktop/ioslibz/phonegap-ioslib/build/Release/ios-sim launch TestApp.app
       2014-10-23 10:55:52.198 TestApp[11931:250282] [INFO] info test
       
       2014-10-23 10:55:52.199 TestApp[11931:250282] [DEBUG] debug test
       2014-10-23 10:55:52.199 TestApp[11931:250282] [DEBUG] line 1 test
       [DEBUG] line 2 test
       
       2014-10-23 10:55:52.199 TestApp[11931:250282] [DEBUG] AUTO_EXIT
       
    one thing to note, I made one modification to Chris' example app -- I removed the ifdef on TEST_BASIC_LOGGING
  5. Ingo Muschenetz 2014-10-23

    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.
  6. Chris Barber 2020-01-30

    We no longer use ios-sim to relay log messages.
  7. Sohail Saddique 2020-01-31

    Ticket closed.

JSON Source