I read about the Runtime Sanitization in the Apple docs in the new Xcode 7, so I looked for it, and found that it's disabled. I'm using Xcode 7 GM seed.
When I go into the Run action of the scheme > Diagnostics tab, the Enable Address Sanitizer option is disabled:
There is some explanation about how other options are disbled, but no mention of why the sanitization option would be disabled:
Some diagnostic tools can be used in combination with others; the options available on the Diagnostics pane are enabled and disabled as different options are chosen to help you select option combinations. For example, enable the address sanitizer and other, incompatible tools are disabled and cannot be chosen
Looking at the Clang 3.8 documentation for Addresssanitizer, it looks like it can also be enabled, by adding a flag: -fsanitize=address. But where this flag should be used in the build settings is a mystery, and questionable since it also exists as a checkbox option in the scheme.
Also found this SO answer, but it is rather complex, and probably outdated, since it was back in 2013.
You can't currently use Guard Malloc and Address Sanitizer together. Selecting the Enable Guard Malloc checkbox disables the Enable Address Sanitizer checkbox. Deselect the Enable Guard Malloc checkbox if you want to use Address Sanitizer.
You also need to be sure you have a Mac/iOS/TV simulator selected, not a device. Watch simulator is not supported. (As of Xcode 9)
Related
I'm building a macOS app via Xcode. Every time I build, I get the log output:
Metal API Validation Enabled
To my knowledge my app is not using any Metal features. I'm not using hardware-accelerated 3D graphics or shaders or video game features or anything like that.
Why is Xcode printing Metal API log output?
Is Metal being used in my app? Can I or should I disable it?
How can I disable this "Metal API Validation Enabled" log message?
Toggle Metal API Validation via your Xcode Scheme:
Scheme > Edit Scheme... > Run > Diagnostics > Metal API Validation.
It's a checkbox, so the possible options are Enabled or Disabled.
Disabling sets the key enableGPUValidationMode = 1 in your .xcscheme file.
After disabling, Xcode no longer logs the "Metal API Validation Enabled" log message.
Note: In Xcode 11 and below, the option appears in the "Options" tab of the Scheme Editor (instead of the "Diagnostics" tab).
How to disable the message:
Select your scheme at the top of the window. Click Edit Scheme in the drop-down, go to Diagnostics and untick the Metal API Validation checkbox.
Is Metal being used in my app?
Yes, even if your code isn't interacting directly with the GPU, many high-level frameworks do -- specifically Core Image, SpriteKit, and SceneKit. For example, I narrowed the pesky "Metal API Validation Enabled" message in my app down to this line:
layer.backgroundColor = NSColor(patternImage: image).cgColor
Should I disable Metal API validation?
Enabling validation makes every Metal API call be checked, which causes a "small, but measurable, impact on CPU performance." The purpose of this validation is to
check for code that calls the Metal API incorrectly, including errors in resource creation, encoding Metal commands, and other common tasks.
There's a very low chance that Apple frameworks like Core Image are using the Metal API incorrectly, so if your app only uses those high-level Apple frameworks, then I'd say you should feel safe to disable API validation. Getting rid of that damn output message is worth the risk.
I had the exact same message.
I had a .onDelete(perform: deleteLocations) at the end of a scrollview closure.
I changed the scrollview to a list and the message went away.
I recently started to work for an update to my macos app.
It worked well without errors but then i added a storyboard file from an older xcode project and when i fire .loadWindow() i saw these on my log:
"Metal API Validation Enabled"
"fopen failed for data file: errno = 2 (No such file or directory)"
Then i looked at the interface builder and one of my labels was in a weird position.
So i centered that label and run app again and the "fopen failed for data file: errno = 2 (No such file or directory)" warning gone.
It still says "Metal API Validation Enabled" whenever i load that window from that .storyboard file but that doesn't bother me.
So i think this is something about how operating system is drawing windows and views or maybe something about interface builder version difference.
This warning started to appear on Xcode 10 Beta 6.
I perfectly understand its meaning, yet I wish to disable it. Any way to do that?
I managed to get rid of the warning by turning off "Missing Localizability" in the build settings.
This prevents the warning from reappearing if you turn off base internationalization.
To remove the initial warning i had to restart xcode with base internationalization turned on. Once the warning is gone you can disable base internationalization again. And be happy because there is one less warning in your project. (or very happy if there are none)
The warning will go away if you edit your project.pbxproj (inside of your xcodeproj) with an editor and add Base to the knownRegions key.
Not sure if it has any side effects though.
knownRegions = (
en,
nl,
Base,
);
You need to open all XIB or storyboard. Check localization table. If it is a space, you need to choose a localization language.
In ios apps the default behaviour appears to be to fail for Test Compilation.
Why would I want that to be default? Surely, at worst, I would want Debug to have it enabled? What changes does Enabling Testability actually make?
I happened upon this while tracking down another issue. But perhaps I can give provide a scenario. Why would you ever not want to enable testability?
-fvisibility=hidden.
If you want to use the GCC_SYMBOLS_PRIVATE_EXTERN (aka Symbols Hidden By Default), enable testability has higher precedence and will override this.
In my case, I have a configuration which is copied from Debug and hence has Enable Testability == YES. I have an external static library which was built with -fvisibility=hidden which is used to build one of my own static libs (built with Xcode). However when building my debug builds, I get errors such as (I redacted the function names and paths)
Showing All Messages : Direct access in function ... means the weak
symbol cannot be overridden at runtime. This was likely caused by
different translation units being compiled with different visibility
settings.
From the Apple doc here:
https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/04-writing_tests.html
When you set the Enable Testability build setting to Yes, which is
true by default for test builds in new projects, Xcode includes the
-enable-testing flag during compilation. This makes the Swift entities declared in the compiled module eligible for a higher level of access.
It would seem that it is also there for Swift accessibility. So if you are not using Xcode's testing and Swift, it would also seem like you could do without this.
At certain point I used Accessibility Inspector (from Xcode -> Open developer tool -> Accessibility Inspector) while running my app in simulator, and ever since the Xcode console is cluttered with accessibility logs, no matter if Inspector is launched or not:
objc[33601]: Class ___MKPlaceBusinessInfoItemAccessibility_super is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/AccessibilityBundles/VectorKit.axbundle/VectorKit (0x11f4817b0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/AccessibilityBundles/MapKit.axbundle/MapKit (0x11ff15f00). One of the two will be used. Which one is undefined.
And there are hundreds of lines of this for all different classes, so it's very hard to find some useful output.
I've tried adding OS_ACTIVITY_MODE with disable value in Product>>Scheme>>Edit Scheme...>>Run as Environment variable, but that doesn't help.
Anyone knows how to turn it off?
Since my latest update to the Instruments 6.1 I can't find "Show Obj-C only" checkbox anymore. Does somebody know if it has been removed completely or where one can find it?
Please, see attached images.
old Instruments checkBoxes:
new Instruments checkBoxes:
Looking through the Instruments User Guide by Apple you stumble upon many screenshots of the UI. All of them are missing the "show obj-c only" section. They definitely removed the feature from instruments.
One of the reasons may be that according to the Xcode release notes instruments supports swift (Instruments supports Swift, displaying Swift symbols in stack traces) and therefore they would have to either change the title of the feature or add a similar feature for swift. They apparently choose to remove it entirely since almost all of its functionality can be achieved by using the "Hide System Libraries" option and "Data Mining" section.
#Aaron Brager asked about the topic in the apple developer forum as well and received pretty much the same answer.
=> Apple felt like its functionality was redundant and it could/should be removed! Therefore they acted accordingly.
P.S.: as the answerer in the dev forum asks: if you have a use case that got more difficult, feel free to file a bug report.
I've also noticed this and while it's not exactly the same, I use the following toggle in the new interface builder to focus on my personal code:
Toggle Off:
Toggle On: