Wednesday, 13 August 2014 05:30

Useful Plugins for Xcode

What’s this all about? This is just a short collection of some useful Xcode 4/5 plugins I use. Most of us Cocoa developers, I guess, are looking about for making our development environment a more friendly and “warm” place with features enriching the development experience. This list is far off being complete and will be extended permanently. So if you like it you should take a look at it from time to time. UncrustifyX Xcode plugin to uncrustify the source code opened in the editor.The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier. XCFixins This project includes plugins (known as fixins) that extend Xcode and fix some of its annoying behaviors. Xcode_beginning_of_line XCode 4 plugin to make HOME key jump to the first non-whitespace line of code. Dash Plugin for Xcode This plugin allows you to use Dash (I think, this is a Must-Have!) instead of Xcode’s own documentation viewer when using option-click (or the equivalent keyboard shortcut) to view the documentation for the selected symbol. Exterminator A magic button in Xcode to exterminate the current project’s DerivedData directories. KSImageNamed Xcode plug-in that provides autocomplete for imageNamed: calls. ColorSense Plugin for Xcode to make working with colors more visual. Every time when place the cursor on a UIColor/NSColor code fragment it will show the current color of this code as an overlay. By clicking this color overlay you can edit the value just with the standard OS X color picker. Mini Xcode This is a plugin that makes it easier to run Xcode without the main toolbar. It adds keyboard shortcuts for selecting the active scheme and device, and a compact popup menu in the window title bar that shows the currently selected run configuration. Lin Xcode4 plugin showing completion for NSLocalizedString andlocalizedStringForKey:value:table:. XVim XVim is a Vim plugin for Xcode. The plugin intends to offer a compelling Vim experience without the need to give up any Xcode features. Fuzzy Autocomplete for Xcode A Xcode 5 plugin that adds more flexible autocompletion rather than just prefix-matching.Please read also this very interesting article of the developer of this plugin about the way of reverse engineering Xcode with dtrace. XToDo A plugin to collect and list the TODO, FIXME, ???, !!! ClangFormat An Xcode plug-in to to use clang-format from in Xcode. With clang-format you can use Clang to format your code to styles such as LLVM, Google, Chromium, Mozilla, WebKit, or your own configuration. VVDocumenter Xcode plug-in which helps you write Javadoc style documents easier.I use this plugin constantly! KFCocoaPodsPlugin Xcode plug-in for CocoaPods with pod commands/console output, user notifications & code completion. Alcatraz Alcatraz is an open-source package manager for Xcode 5. It lets you discover and install plugins, templates and color schemes without the need for manually cloning or copying files. It installs itself as a part of Xcode and it feels like home. SCXcodeMiniMap SCXcodeMiniMap is a plugin that adds a source editor MiniMap to Xcode. Conclusion As we’ve illustrated above, some of the must have plugins and most popular. By sharing experiences we gained happiness, we hope to help improve apps built by our readers. There’s a lot more we’d like to share in future posts. If you have any thoughts or questions regarding plugins, don’t hesitate to contact us at This email address is being protected from spambots. You need JavaScript enabled to view it.
Published in Blog Post
Saturday, 29 March 2014 05:30

Android: Fragments within Fragments

I was building out the settings stuff first (the app needs credentials to work so I kinda had to start there), which was relatively easy. I wanted to create a setup flow, whereby when you start the app it checks if you have credentials that are valid and if not walks through the setup procedure. I was using fragments to do this, each setup page being a different fragment rendered within the whole window in the main activity. IUpon realising that I had already built a PreferenceFragment for the config settings a user had to setup at the beginning (they were easy to logically group this way) I thought I would just include that in one of the setup flow fragments and my config options would be all set up themselves. This worked rather nicely, until I got a rather nasty exception when I ran through the flow for a second time: 10-07 13:28:02.663: E/AndroidRuntime(1809): FATAL EXCEPTION: main 10-07 13:28:02.663: E/AndroidRuntime(1809): java.lang.RuntimeException: Unable to destroy activity {com.example.app/com.example.app.Base}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3273) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3291) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread.access$1200(ActivityThread.java:130) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.os.Handler.dispatchMessage(Handler.java:99) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.os.Looper.loop(Looper.java:137) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread.main(ActivityThread.java:4745) 10-07 13:28:02.663: E/AndroidRuntime(1809): at java.lang.reflect.Method.invokeNative(Native Method) 10-07 13:28:02.663: E/AndroidRuntime(1809): at java.lang.reflect.Method.invoke(Method.java:511) 10-07 13:28:02.663: E/AndroidRuntime(1809): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-07 13:28:02.663: E/AndroidRuntime(1809): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-07 13:28:02.663: E/AndroidRuntime(1809): at dalvik.system.NativeStart.main(Native Method) 10-07 13:28:02.663: E/AndroidRuntime(1809): Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1280) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1291) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.BackStackRecord.commitInternal(BackStackRecord.java:548) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.BackStackRecord.commit(BackStackRecord.java:532) 10-07 13:28:02.663: E/AndroidRuntime(1809): at com.kodhus.tropics.setup.SetupCredsFragment.onDestroy(SetupCredsFragment.java:24) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:983) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1017) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1826) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.Activity.performDestroy(Activity.java:5171) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1109) 10-07 13:28:02.663: E/AndroidRuntime(1809): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3260) 10-07 13:28:02.663: E/AndroidRuntime(1809): ... 11 more I had a Google and was surprised to find endless Stack Overflow posts saying “Fragments in fragments can’t be done”. Well I may be new to this version of Android development but that seemed a little foolish and also acted like a red flag to a bull. So I had a hunt around and it turns out it is possible to do fragments within fragments, but you just have to clean up after yourself – activities only clean up the top level fragments in them when they are closed or transitioned etc. Thus I had a half hour of playing around trying to find the right settings, and this is the code I came up with. It goes in the onDestroy method of the middle fragment, i.e. the one that is within the activity and has another fragment within it. Note that you need to know the ID of the inner fragment for this to work. @Override public void onDestroy() { Fragment fragment = getFragmentManager().findFragmentById(R.id.innerfragment); if (fragment.isResumed()) { getFragmentManager().beginTransaction().remove(fragment).commit(); } super.onDestroy(); }
Published in Blog Post