xcode


How to identify if Swift was compiled with Optimization


As some of you may be aware when running in fully Debug-Mode swift can be terribly slow. Is there a way i can print out a message in code or to the GUI to let me know if I somehow forgot to compile it correctly. I'm running in mixed mode so if somebody can give me Objc and Swift code that would be super awesome.
Thanks!
I don't think you can detect this at runtime, but you can use the DEBUG preprocessor macro (in Objective-C) that is defined in the Debug configuration by default:
#ifdef DEBUG
NSLog(#"I'm in debug mode!");
#endif
This assumes that you don't compile without optimizations in the Release configuration :-)
If you want to check that in Swift, you need to define a Build Configuration by adding -D DEBUG to "Other Swift Flags" for the Debug configuration only in the Build settings. Then you can check for that configuration if #if:
#if DEBUG
println("I'm in debug mode!")
#endif
You can use Xcode's schemes to add a flag as an argument or in the environment variables - you can then check for it using NSProcessInfo - either -arguments or -environment.
In Xcode, go to Product > Scheme > Edit Scheme in the menu bar, select Run and under the Arguments tab, add either the argument or environment variable.

Related Links

Move a pixel through screen with swift
In Xcode 6.2 how do you add a Run Script build phase that runs a Swift script?
log filtering in xcode possible?
Swift UIView.animateWithDuration disregards animation code at times
Swift 2.0: Could not find overload. Need Explanation
How to dynamically adjust the height of Today Extension
Bamboo and xCode Bot solution
Calling heightForRowAtIndexPath manually
Objects of “Main.storyboard” dissapered when updated xcode 6.3.1
How to protect a view in XCode 6 against touches?
Archive submission to App Store failed in Xcode 7.0 for Test Flight
Changing title of navigation bar from a file
Cannot save and query data with parse local datastore
Setting a Variable “as” a Class
Swift / Playground - Assertions not working in Xcode 6.3.2?
Swift had fatal errors constructing the ast context for this module

Categories

HOME
events
extjs
eclipse-plugin
seedstack
couchdb
visual-studio-2010
iptables
ontology
turbojpeg
port
roku
sonata
dma
playframework-2.0
psql
wsf
adminlte
libgit2
dashdb
hdl
perfino
ratio
function-points
react-dnd
pyspark-sql
amazon-cloudtrail
docx4j
progid
delayed-job
advanced-filter
apptentive
pdfnet
bluemixtools
task-parallel-library
utf
access-denied
optionaldataexception
nomad
audio-converter
realstudio
intellij-lombok-plugin
tinyioc
roracle
lightning-workbench
aurelia-fetch-client
pen
lvalue
emf-compare
business-rules
sidewaffle
google-shopping-api
cocoa-bindings
yui3
thread-exceptions
node-glob
jemdoc
polymerfire
accessibilityservice
flush
teensy
largenumber
openshift-cartridge
fantom
phonegap-facebook-plugin
hp-idol-ondemand
encryption-symmetric
vs-unit-testing-framework
mobile-country-code
webmethod
oxygene
iosched
vlab
indesign-server
sly-scroller
delphi-xe4
icenium
zotonic
fbml
litespeed
play2-mini
upshot
dip
urchin
reliability
firephp
powergui
data-retrieval

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App