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

Set Initial Screen Image for Xcode Tab Bar App
How do you add a breakpoint in Xcode?
In Xcode how do I add a breakpoint inside a block?
xcode/iOS: Autoresize to fill a view - explicit frame size is essential?
Is xcode 4.2 is compatible with mac os 10.6.3?
Xcode keeps searching dylib at wrong path
How can I get UDID using liblockdown.dylib?
Insert into different tables in SQlite
In Xcode 4, setting User Header Search path breaks code sense
Tools to document Core Data Models?
iPod won't sleep when connected to debugger
How can I install the OSX 10.4u SDK to support backwards compatible OSX builds?
Building a universal app for iOS 3.1, iOS 3.2 using iOS SDK 4.2
xcode4: Where are the User Scripts?
Do I still need an Entitlements.plist file for an ad-hoc build?
How do you use Compile Sources in Xcode 4.0?

Categories

HOME
azure-functions
concurrency
code-formatting
filesize
ios-simulator
histogram
celery
consul
lvm
material-components
capistrano
stored-procedures
wagtail
hspi
log4j2
siesta
nexus3
smooks
google-awareness
max-msp-jitter
rest-assured
pfobject
tableview
acl
chronicle-queue
quartz.net
jstree
web-config-transform
hdmi
macromedia
splunk-query
netbios
reporting
john-the-ripper
microsoft-certifications
textmate2
keyboard-layout
newtons-method
apache-toree
vesta
rightnow-crm
dredd
.net-micro-framework
lightning-workbench
karabiner
entropy
datediff
http-basic-authentication
always-on-top
system.net.mail
ftp-client
nsdata
right-to-left
simian
taco
m4
phpquery
boost-proto
opencyc
astropy
unhandled
azure-xplat-cli
prism-4
tidyr
html-escape-characters
operands
image-rotation
adwords-apiv201402
loginview
full-text-indexing
maven-central
rails-api
visual-c++-2005
mousemotionlistener
acitree
apportable
flv
contextswitchdeadlock
playorm
nsmutablestring
kaazing
image-scanner
java.lang.class
will-paginate
representation
azure-acs
jquery-1.4
bass
mongrel
autobench
motif
synthesizer
parentid

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App