• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Can I set build configurations in Swift code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can I set build configurations in Swift code?


  • Subject: Can I set build configurations in Swift code?
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Tue, 08 Jul 2014 10:50:39 +0700

In Objective-C I like to do things like:

#if DEBUG
	#define SOME_FLAG
	//#define OTHER_FLAG
#endif

[...]

#ifdef SOME_FLAG
	[...]
#endif

[...]

#ifdef OTHER_FLAG
	[...]
#endif


In Swift I am doing:

#if DEBUG
	let SOME_FLAG = true
	let OTHER_FLAG = false
#endif

#if DEBUG
	if SOME_FLAG
	{
		[...]
	}
#endif

Works fine.

But: I get lots of warnings "Will never be executed" for all OTHER_FLAGs.
I do NOT want to switch off this warning, as it probably is rather useful.
But I do much prefer to have code which compiles without warnings.

So: is there a way to define build configurations in code (other than in the Build Settings of Xcode) ?

Or: how else to handle conditionally compiled code in Swift?

Gerriet.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Can I set build configurations in Swift code?
      • From: Chris Lattner <email@hidden>
  • Prev by Date: Re: Swift crash in dispatch_apply
  • Next by Date: Re: Swift crash in dispatch_apply
  • Previous by thread: Re: App icon is being mangled when built
  • Next by thread: Re: Can I set build configurations in Swift code?
  • Index(es):
    • Date
    • Thread