What happened to XCode Build and Analyze results? - iphone

This is similar to another question that wasn't really answered: Xcode 3.2: Build & Analyze never finds any issues
I used XCode's Build and Analyze for the first time on a large project and came up with a number of analyzer warnings. I corrected a few and wanted to verify my changes were being 'accepted' by the analyzer. I didn't even look at warnings in a number of files. But when I re-run Build and Analyze, all the warnings are gone.
I have tried: changing my compiler to LVVC GCC 4.2, switching from a debug to a release build, cleaning all (repeatedly), and quitting and reopening XCode. I just can't get the old warnings back.

Build and analyze only analyzes your modified files.
Go to your project settings -> build tab. And check 'Run Static Analyzer'. This runs a full check on all files on each build.

It is how XCode built with. Whenever, you build the project (even using build & analyze), it will build only those files which are modified before the last build. So if you want to have your old warning & analysis result back, do clean all targets from build menu & again build.

I had a similar issue some days ago. I had plenty of warnings, and after some changes in the code the analyzer warnings disappeared. Even a clean build could not bring them back.
By a coincidence I changed the message filter in the build log from Issues Only to All messages.
And there were plenty of messages related to the disappear of analyzer results. The analyzer complained that he could not analyze my files. I'm sorry I don't remember the correct message.
As far as I remember I put some code into the .pch which confused the analyzer completely. After I changed a lot of stuff analyzer was happy again. Magically. I still don't know why that happened and I can't reproduce it.

For whatever reason, none of the solutions above worked for me. The only way I could get the warnings back was to open the project with XCode 4 and analyze it there. I am taking screenshots so I don't lose these warnings. I hope the analyzer works better in XCode 4 in the future.

Related

Xcode 10 not building latest swift file

I have updated from xcode 9 to xcode 10, after doing so when I try to change the code in one swift file the changes are not reflected when being built. I have tried the following with no success:
(1) Delete Derived Data
(2) Delete the file and re link
(3) Touch the file via terminal
I have tried dozens of solutions with no result. This issue as far as I can tell is only affecting one file. Any help will be greatly appreciated.
Xcode10 has incremental compilation mode for the debug builds. This might be affecting it. Check below link
https://shashikantjagtap.net/wwdc18-modern-tips-for-optimising-swift-build-time-in-xcode-10/
There's apparently an issue with the new build system, see related issue for details. One way around this is to switch to the legacy build system in File > Workspace Settings….

Why XCode Clean and Build fix EXC_BAD_ACCESS?

I've seen lots of people (including me) facing the crash with EXC_BAD_ACCESS with unknown reason. A lot of answers with the solution clean and build the project marked as correct.
I'm curious why this happens and how clean and re-build fixed it, but it seems people just don't care and go on with clean-build solution.
Here's an example of those EXC_BAD_ACCESS with clean-build solution.
In my case, I'm facing something as ridiculous as this:
func viewDidLoad() {
super.viewDidLoad()
self.childVC.delegate = self // => Crashed EXC_BAD_ACCESS here. Fixed after clean and build
}
As far as I know, this happened in Swift a lot more usually than Objective-C. Could it be Swift's features?
These are my thoughts:
Once run, if project is not already built then Xcode generates the required build files in:
~/Library/Developer/Xcode/DerivedData/
If the project is not cleaned, either manually or automatically, then the same build files are reused in running apps to reduce consequent build time.
You may have already noticed that Xcode sometimes automatically cleans the build after any major code change. For example, on:
changing static variables
changing objective-c code in the swift project
But Xcode still has it's flaws, and sometimes does not clean itself when needed making it possible to run with the, let's say, "broken" build files that eventually give rise to such EXC_BAD_ACCESS errors.
Cleaning it will clear the old build files and new builds don't have the same problem.

Xcode 8 does full project rebuild

Having updated Swift + ObjC project to Xcode 8 (Swift 2.3) I found 50% or more of the time Xcode does a full rebuild of the project instead of an incremental build.
The changes made are adding simple print statements. There seems to be no logic as to when it performs a full rebuild.
It appears in the "Check dependencies" phase it decides this. On Xcode 7 this did not seem to be a problem.
Has anyone else encountered this?
I have found this works consistently, it will however compile swift files if you modify a header included in the bridging header. It will also do full compile if you switch git branches back and forth.
Firstly make sure optimization level for debug is set to None (Not whole module optimization)
Then, according to https://forums.developer.apple.com/thread/62737 Apple Staff (ddunbar):
We believe that setting:
HEADERMAP_USES_VFS = YES
to true in your project (or for all your targets) may be an effective workaround > for many people. This is not guaranteed to work (which is the reason it isn't > already on by default), but it should work for most projects.
This should be added through "Add user-defined setting" under your target Build Settings.
.
Ok, here's an answer to why it's happening, but I don't know the solution. If you use the "Other Swift Flag" -driver-show-incremental Xcode will output what it decides it needs to compile based upon it's dependancies. You'll see things like:
Queuing EditProfileViewController.swift because of dependencies discovered later
Queuing ChangePasswordViewController.swift because of dependencies discovered later
Queuing JoinViewController.swift because of dependencies discovered later
Queuing JoinProfileViewController.swift because of dependencies discovered later
Queuing FormViewBuildable.swift because of dependencies discovered later
Queuing RadioTextFormView.swift because of dependencies discovered later
Queuing TextFieldFormView.swift because of dependencies discovered later
Queuing AccountProfileViewController.swift because of dependencies discovered later
I'm wondering if this is a swift 3 problem, because I wasn't having this issue before converting. I made a little example project where
FileA inclues a thing from FileB includes a thing from FileC
and even adding a file private change to FileC that's not used anywhere causes FileA, FileB, and FileC to be queued for compilation due to dependencies. I'm going to be testing this example in Xcode 7 later today to see what happens.
So it looks like swift 3's dependency resolution isn't working very well. I've tested this on 2 other swift 3 projects at work, and the same holds true. Make any change in any file, and every file gets compiled. It doesn't feel slow until you start getting to projects with about 15,000 lines of code or so, which may be why nobody is talking much about this. Unless you have a somewhat medium sized swift 3 app, you probably won't even notice that incremental complication isn't working quite right. I'll update if I learn anything more.
Apple released new beta version of Xcode yesterday (Nov 14)
Xcode 8.2 beta 2
And this issue has been marked as resolved in the release note.
Build System
• Xcode will not rebuild an entire target when only small
changes have occurred. (28892475)
It is working for me. The build speed came back as usual.
Everybody who is facing this issue, should give it a try!
https://developer.apple.com/download/
Unchecking "Find Implicit Dependencies" in Edit Scheme > "Scheme" > Build tab fixed it for me for project files. "Copy swift standard libraries" still takes forever..

Xcode won't build to device

This problem has been KILLING me. I've been working on this app for 8 Months, and I am so close to finishing, I just can't seem to build for device. Building for the simulator works fine, but device always gives me the SAME 2 errors.
The 1st Error:
"Instruction requires a CPU feature not currently enabled"
From googling, I've found this probably means I'm not linking a binary I should be, but I'm not sure.
The 2nd Error:
If you can't read it, it says: Generating JWFNS.app.dSYM ... error: unable to open executable '/Users/ajr1188/Library/Developer/Xcode/DerivedData/JWFNS-azshgysfabycfagnebotitpcyaww/Build/Products/Debug-iphoneos/JWFNS.app/JWFNS'
This is the big one. I cannot seem to build the .app.dSYM file properly. I went in and deleted the build folder, I looked at EVERY stackoverflow question I could find and tried changing any random thing mentioned in another question, but all of it is to no avail. I'm so suck right now. AHH. PLEASE. Any help would be so appreciated!
Maybe your project has become hopelessly corrupted. One thing to try is to start a brand new project and copy/import all your sources/assets into the new project to see if that fixes the problem.
Another less nuclear (but perhaps more time consuming) approach is to binary search the build. Exclude absolutely everything except main.m and see if that fixes the problem. If it does, include half your sources, and buid again....repeat, trying to narrow in on the problem spot. Maybe a file or group of files has received special build settings that don't belong there.
I've had very similar problems, I cant remember the exact error message but it was very similar. Are you able to make a new project that will run on your device?
if so (and I know this sounds bad but it's worth a try) Create a new project and simply copy all the code and resources across and see if it still works. If it doesn't then there is something wrong with you code and you can continue trying to isolate the problem from there.
Hope this is helpful.
check the frameworks you link to. there's a chance that you linked a framework (say quartz) of osx, instead of ios.
Answering in detail is probably going to take looking at your target settings. But it looks like you may be building for the wrong architecture. (It doesn't link, so there is no .dSYM symbol file.) For example, if you have only recently built for device, you probably created your project under an older Xcode, and it may not have the arm6/arm7 settings right.
To check, show the Build Settings for your target (not the project), and filter on Architecture.
Make sure that in build settings the architectures are armv6 and armv7. Also make sure that in .plist file, the "Application requires iPhone environment" is TRUE. Delete "Required device capabilities" in the .plist if present.

Xcode Project Code Changes Not Updating 100% After Save-Build-Run

When I make code changes to my iPhone game project in Xcode, and then do CMD-B + Enter, I expect the project to be saved, build and run on the simulator with the latest. What is happening though, sometimes, is that it doesn't pick up a small change I make unless I clean the project and then build.
I'm a long time Java person and newish to C-based languages and it's compiler. Can someone explain to me what is cached after each build that does this and how to change my project settings to avoid having to clean every time? Or tell me the bad news that this is part of C development? Not trying to bash it - I get compiled JSPs stuck in the working cache often in Java, too. :P
UPDATE: Does this have to do with the location of my builds at all? That's the only thing I can think of that's changed from a build config perspective.
Had a similar problem, I reset content and settings in the iPhone simulator
Seems odd to me, because I never get this problem in XCode. It's not a common issue with C or anything. The tools for C-based languages usually do this just as well as the Java ones.
Go to Product Menu and choose Clean and then choose Build. Thats it.
In the Xcode Build Preferences make sure that "Unsaved Files" is set to "Always Save". If not, Xcode will not autosave files before building and will use the last version saved to disk.
In case anyone still comes across this (as I was having this issue today on Xcode 5.1), all I had to do was open a new tab and close out the tab I was working in. Some sort of tab bug in Xcode.
I am not sure about this, But in case if you are using git, go to xcode preferences -> Source control -> General
Uncheck Refresh local status automatically
Uncheck Fetch and refresh server status automatically
Uncheck Add and remove files automatically
Uncheck Select files to commit automatically