AppCode not detecting unused imports in .h file - code-cleanup

I developed my project in xcode and in order to detect the unused imports and statements in my project I opened my project on the "AppCode". The problem which I am facing is that AppCode is only detecting unused import files in .m files of my project, while if I include any unnecessary import statement in .h file the AppCode is not detecting it and that file does not get grey in color.
Can any one please tell me that is there any way of detecting the unused imports statements in .h file of the project if we are using "AppCode" as our IDE?

No, AppCode doesn't show the unused imports in the header files intentionally. Headers might be included in other headers and it's almost impossible to detect the unused imports in the headers.
BTW including the headers in other headers is not a good style, it's always better to use predeclarations like #class or #protocol and include the actual headers in the corresponding source files. This approach will produce less dependencies and compilation of the program will be faster.

Related

Sass transformation: each file preprocessing

Problem
We are using System.Web.Optimization bundling and BundleTransformer for SASS/SCSS. Is it possible to call some preprocessing before each sass file? Not only before files included in bundle, but before files imported using #import too.
If you want to do some preprocessing before each file in bundle you can add some custom IItemTransform or IBundleTransform, but imagine this:
Main.scss:
#import '_mixin';
some styles
_mixin.scss:
some mixins
Main.scss is included in bundle and will be preprocessed, but _mixin.scss is not included in bundle, so scss compiler will get raw file from disk without any preprocessing.
Any hook into compiling process? Or some other way?
Why do we need this?
Our common static files are located in Core project. This core project static is included in other projects as virtual directory in IIS (in debug) or copied (in release). With this solution we can use '/SharedStatic/..' in any project and it's resolved always: as virtual directory in debug and as usual path in release.
So right #import to core project must be like that (works with BundleTransformer):
#import '~/SharedStatic/Styles/_mixin.scss'
But VS intellisense (or R# intellisense) and WebEssentials intellisense don't understand '~' imports at compile time. Intellisense understands only this:
#import '../../../../CoreProject/Static/_mixin.scss'
So idea is to preprocess scss files while bundling and fix imports from '../../..' to '~/'.
Nobody answered yet, so looks like there is no easy hook into building SASS.
We solved this problem other way: stopped using virtual directories in IIS and included symlinks to shared staff in each project. Now it looks like every project has its own /SharedStatic (which is really symlink to Core Static). And this solves problem with SCSS as we can use '../../SharedStatic/' both in initial file and in file before compiling, no need to change pathes from one to another.

QML error says that svg is unsupported

I've used plugins before, but after I recompiled my qt libraries, I haven't been able to successfully use .svg image files any longer. There error I get is as follows:
file:///C:/Users/RBhatia/Documents/SettingsMenu/SettingsMenu/SlicingComp.qml:41:5: QML Image:
Error decoding:
file:///C:/Users/RBhatia/Documents/SettingsMenu/SettingsMenu/img/sliceStep_slice1.svg: Unsupported image format
I have checked all my .dll files to make sure they are in 64 bit format. I also checked my environment variables, and even tried to use different librariesm but I simply cannot figure out what changed to cause this issue.
The problem is not missing header files. It's due to missing dependencies to Qt libraries as mentioned in that comment here: Comment by JamesL
To use SVG images you need to specify QtSvg, QtXml, QtGui, and QtCore to be deployed with your project.
The most probable reason I can think of is that you were missing some svg header files when you compiled your qt. If you do not add -svg to your configure, svg is treated as optional. Means if everything is there to build the svg plugin, it is build, else this feature is silently dropped.
You said, you checked your .dll files. Did you also check the plugins folder? Something like $QTDIR/plugins/imageformats. Must contains a qsvg4.dll. Or qsvg5.dll for Qt5.

Lexical or Preprocessor issues Xcode when archiving

I was about to archive for the OTA distribution with Xcode 4 when Xcode is suddenly giving me the infamous preprocessor or lexical issue. This did not happen on the build nor release configuration settings both on the device and the simulator.
I used my own static library with the angle-bracket style import. Pardon me, but Im not quite sure wether that can cause the problems.
#import <MyCommonLib/headerfile.h>
On my static library project, I put all of the header on the public section and it is placed nicely on the DerrivedData shared folder for the build result (checked), and I have put the dependencies of my main project to depend on the static library project, also I have linked the static library with my main project.
Any idea of what can cause this only to happen when I am archiving it? (it tested great with both my device and simulator).
Cheers,
This error is due to some "imported" files no longer be found / referenced by compiler ( possibly "Deleted", either delete from disk / delete reference only).
Try to change:
#import<MyCommonLib/headerfile.h>
to:
#import "MyCommonLib/headerfile.h"
Make sure the file exist as well.

XCode compiles entire project each time I run

On a new project I have started, XCode has decided that it will compile every file in the project every time I run it, rather than just compiling files that change (and files dependent on those). As there are getting to be more and more files in the project, this becomes a bigger and bigger burden in both time and battery life.
It is possible that I have changed a setting somewhere that affected this; or, maybe not. What are some project settings that I should be looking at?
If Xcode recompiles most or all of your source files whenever you do a build, that usually means that those files are all directly or indirectly dependent on some header file that has changed. Here are some things to look for:
Do your source files tend to #import some top-level header file that itself recursively imports a bunch of lower-level header files? If any file in that tree of dependent headers is modified, it will force recompilation of any .m file that imports the top-level header file. You may be able to reduce these dependencies by importing headers for lower level submodules, or better yet, for just the specific headers you need for each file. (Note: Some libraries that aren't designed to be used this way can make this approach challenging or impossible in some cases.)
Some third party development tools and static libraries run scripts that generate or modify code as part of their build process. If your source files are dependent on a header file that's generated by a script, they'll be recompiled every time the script regenerates that header file. Even if the code generated by the script doesn't change, dependent source files will be recompiled if the last-modified date of the header file changes. It may take some clever hacking to eliminate redundant compilation if this is your issue.
Don't forget to check your precompiled header (.pch) file to see what's being imported there. The contents of that file are effectively injected at the top of every .m file in your project at compile time.
Try to minimize dependencies by moving as many #import statements as possible out of your .h files and into your .m files. You can generally get away with just importing the headers for your class's superclass and any protocols your class implements in its .h file. You can use forward declarations instead of #import statements for any other classes, data types, or protocols you use in your class's #interface.
I realize this question is over a month old, but I had a similar problem in moving an old project to Xcode 4. After much hair-rending, I discovered that Xcode 4 (4.2 in my case) has a bug where, if there are any non-ASCII characters in the full path either of a source file, or in the full path of any headers the source file includes, it will be recompiled every time you build. This includes the prefix header, in which case a full compile will be triggered every time. In my case, the previous programmer had appended 'ƒ' to several folder names, and once I removed those, it worked perfectly.
Anyway, I stumbled upon this question during my (unsuccessful) attempts to Google an answer and thought I'd share my solution.

Flex: Are unused module project files included in the module swf's?

Currently optimizing an application at work. There are many files in some of the module projects that are not used by the exported (release build) Module.swf's. Are these unused files included in the swf's?
What about unused imports?
If there is no reference to them in your code the no, they will not be included in the exported swf. The compiler is smart enough to check for unused imports.
If you're using the mxmlc to compile then you can set the -link-report flag to true to get a list of dependencies and their sizes. It generates a rather ugly XML file, but see this article for more info and a nice way to view it. http://blog.iconara.net/2007/02/25/visualizing-mxmlcs-link-report/

Resources