Bad Access at UIApplicationMain() if Keyboard's Correction is set to Default or Yes - ios

In my project, there is a simple table view and search controller. Everything loads and works fine, until I type into the text field. It then crashes at UIApplicationMain(), with a stack track of several UIKeyboardInputImpl methods. On a whim, I decided to mess with the settings in IB for the Search Bar itself—turns out, setting the option for Correction to Default or Yes causes the crash. I've never seen this happen before, and I'm tempted to call this a bug in the SDK. Can anyone confirm or provide more insight?
Xcode 4 Project:
http://db.tt/V6POWik

I've downloaded and checked your sample project for all available options of Correction and it didn't crash. You should try cleaning your build and derived data just in case and try again. If you are sure that the problem is reproducible I would love to know the steps I need to take to reproduce the error/crash.

Bug in the SDK…not much that I can do.

Related

Auto fix implement of missing method of protocol with Xcode?

I am not very familiar with Xcode,
Since I think every decent IDE should have a shortcut for auto-fix a template of implemented protocol (such as interface in java) to save some effects of the programmers to just fill in the logic and don't have to type in the method name and parameter stuff.
Such as when we meet this:
And I googled around and some guy said that there should be a fix all in scope thing in the Editor, but seems I can't make that clickable :-(
So, how to do this with xcode? Thanks.
Unfortunately Xcode is fairly behind compared to other IDE's in features for refactoring and such.
The main Xcode version: 8.x, can't do what you wish for. But some of it will be/is available in beta Xcode 9
Xcode may suggest a fix for a compiler error. You can click the errors individually to see the suggested fix(es) and select one.
Alternatively the 'Fix All In Scope' allows you to tell Xcode to select suggested fixes of the current file.

Swift sometimes calls wrong method

I noticed strange behaviour during working with Swift projects. I can't explain it other than Swift sometimes calls wrong method. It is very rare and even adding blank lines to the code could lead that this error is gone.
Let me explain in screenshots what I mean, next I use CoreData example of SwiftDDP project that can be found on Github, but such issues I was able to see in my own projects.
Here we at Todos.swift:74 where you can see breakpoint, I expect that next call should be getId() method of MeteorClient class because it was already instantiated:
After Step Into as you can see the ping() of the same instance is called:
The next two steps into lead to EXC_BAD_ACCESS exception:
In my project I saw this issue fairly often before I stopped using singletons, so it could be related to Swift static memory usage or I don't understand something that is not surprising as I have little experience with multithreading and memory management.
My environment is:
AppCode OC-145.184.11
Xcode Version 7.2.1 (7C1002)
iOS 9.2 SDK
Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)
NOTE: Here I use AppCode but the same behavior I was able see in Xcode, and even more if the same issue that reproduces in Xcode could not reproduce in AppCode and vice versa.
Would be thankful if someone can explain this strange behaviour to me.
Thanks!
This just happened on my team, using Swift 2.2. It's really incredibly strange. It's not a threading issue or an async problem, it was a very cut & dry use case. We called one instance method and another one above it got called. I deleted the method that was getting called, and then the one above THAT got called instead. Then I moved the method I was actually calling to a different location in the file, and it looked like multiple properties were getting called.
This is disturbing and worrisome, as now you feel you can't trust your code to run properly.
But we did "solve" it. We moved the method up to the code that was actually getting triggered, and after a little trial & error the right method got called. Not yet sure if this will manifest itself for other methods.
It'd be nice to be able to provide a simple project where this is happening, but it seems highly unlikely that it's possible, and I can't share a snap shot of my code base with Apple. It must be a perfect storm of something to cause a bug with Swift's run time.
I had a similar issue, I think. Couldn't see that the wrong function was being called, but breakpoints on the function that was being called were never hit, and I couldn't step into the function from where it was being called. I added a new function (I called it wtf) with the same parameter list and implementation, and that one worked as expected, so it must have been a weird linking issue in the Swift compiler.
Update: super-cleaning appeared to work (see below), but it doesn't. Looks like I'm leaving my wtf function in.
After super-cleaning the project, it looks like everything's working as expected again:
clean (cmd + shift + k)
clean build dir (cmd + opt + shift + k)
quit XCode
delete derived data (rm -rf ~/Library/Developer/Xcode/DerivedData/*)
FYI, in my case, the function I call is in a generic base class, called from a generic subclass, triggered by a specialized sub-sub-class. As we all know, the generics are still very buggy in the Swift compiler, so that's probably why I encountered this.
Do you have multiple threads running? Maybe a network thread?
I thought I had this issue too but then it turned out my one thread was doing something and because the other thread crashed it stopped the other thread at a random point. I only noticed this thread so it seemed like it crashed at a random #IBAction function.
When I switched to iPhone 6 simulator instead of iPhone 7, it seems to be working correctly now!
Our app was rejected from review because of a mysterious crash. After debugging I found that it was having this same issue - but only for the Release scheme!
So I went through every setting in Build Settings one by one to see if switching it to that of another scheme would fix the issue: changing ENABLE_TESTABILITY to true fixed it......

Xcode 7 crash every time I try to print something in the debugger console

I've searched around and can't find anything on this.
Using Swift 2 and Xcode Version 7.0.1 (7A1001). Every time I execute something in the debugger console, Xcode crashes.
The project is not very big, and has less than 10 third party frameworks.
I can't think of much more information that's relevant, but I'm sure there's more, so please do ask me if there's anything I should add to my question that would help.
I've of course cleaned build and derived data.
It's driving me insane. Thanks!
UPDATE 16/11/12
Submitted rdar://23559366.
How are you maintaining your third party frameworks? Via Carthage?
If so then this is probably your issue: https://github.com/Carthage/Carthage/issues/924
This is an issue if the location of the /Carthage/Build/iOS folder is in a different location to where it was produced (i.e if it was compiled on a different machine and the absolute file path has changed).
A temporary fix would be to run carthage build --no-use-binaries on your machine to rebuild the symbols using the current absolute file path working around the bug.
But if you wasn't using carthage then its probably not your issue so sorry
I had similar problem with Xcode whenever I hit breakpoint.
In case you see this screen right before your Xcode crashes - you are lucky and my fix might save you. All you need to do is open this window and in the Project Navigator, select any file that you want, so that instead of that white blank view you would get your code. After this you are most likely will be able to successfully stop your app at your breakpoint and perform the debug.
I am not sure why this happens, but I suspect that the reason is Debug View Hierarchy mode, which you might have triggered prior to setting you breakpoint and trying to stop at it. At least this is when it happens to me.
I have similar problem earlier.
If you try to print non-optional variable and unfortunately it holds nil value then it breaks/crash. so that make sure declare all possible variables as "Optional type".

XCode 6.3 autocomplete not working

I'm learning basics of Objective-C and using XCode for writing code.
As you all know autocomplete option is perfect for new users that don't know (or remember) name of functions.
I have a problem with using autocomplete in XCode 6.3 couse its just.. not working - it is not showing anything or showing things that are not connected.
For example I just wrote simple few lines of code gusing NSMutableArray and NSEnumerator, when I'm trying to remind myself function/message 'nextObject' of NSEnumerator, XCode is not suggesting anything.
Here is a pic to show it:
Am I doing sth wrong or there is a way to fix it?
thanks in advance!
It must be a temporary glitch. Happens to me almost all the time while Xcode is "indexing". You might be typing too fast and by the time Xcode gives indexing a break and looks for the auto-completion you might have types something for which there is no method (or something that you expected)
Also, for custom classes & method, make sure you have included the respective header files.
It seems that autocomplete does not work when there is an error in the code.
The reason for autoComplete not working can be anything. Do any one of the following to debug it
Check if there are errors and if so try to solve it and then check autoComplete. If any error is present in any of the line then autoComplete will not work for below code. Try autoComplete above the error incase you want to check.
If debugger does not throw any error then try commenting out the all lines and uncomment it from top to methods to recheck the autoComplete
Quit Xcode and Reopen it
Clear Derived data and then launch Xcode and check

Today View Extension (Widget) not working

I found several other threads with similar problems, but no one has exactly the same problems.
Besides it DID work some time! the errors now keep occurring while it was working some time before..
When Running my app, that has a build Target "Today View Extension", I get no actual result.
The Extension is shown in Notification Center, but has no body (Simulator AND device).
Also when I try to run the App (not the target extension) and attach the process manually by PID I get this error:
I also had the error that my Extension (that has a "Bundle Display Name" entry in Info.plist for a custom Name) did show the Name of the Extension-containing App, and not the string that was set in the Info.plist
Strange thing is that sometimes it worked, sometimes it doesn't, but when it does not there were like five different reasons why not.
I want to ask people who have similar/same problems to post them here to collect all the issues appearing and possibly collect workarounds / solutions for these problems.
Thank you.
For anyone having troubles now:
With beta 4 and beta SDK 4 a lot of bugs were fixed:
[self setPrefferedContentSize:]
to set the views size is now working properly (if you have troubles viewing your Extension)
If your updated Extension is not showing in Notification Center be sure to have a look at the log output, there you can see what task the debugger is attached to, if there is "no Selection" try stopping and running again, it will work after some tries!
If you have questions feel free to ask,
Happy coding
I don't exactly have a solution, but I've observed this happening when anything is "wrong" with my Today extension. For example, if I don't have a file properly targeting the widget. I'm guessing that instead of just crashing to the home screen, iOS just gives you an empty widget? I've written about my own issues here, for reference.
I had similar issues. But it seems to be alright now. Since the "Today View" is an extension and is bundled with the containing app, you should just build and run the containing app. From there, you can pull down the "Today View" and if your widget / today view is not added, add it.
You should be able to see all your updated changes without a problem with this and you won't have to attach any process.

Resources