Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Swift Cookbook

You're reading from   Swift Cookbook Over 50 hands-on recipes to help you create apps, solve problems, and build your portfolio of projects in Swift

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784391379
Length 392 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Xcode and Swift FREE CHAPTER 2. Standard Library and Collections 3. Using Structs and Generics 4. Design Patterns with Swift 5. Multitasking 6. Playground 7. Swift Debugging with Xcode 8. Integrating with Objective-C 9. Dealing with Other Languages 10. Data Access 11. Miscellaneous Index

Using Swift project options

Xcode projects comes with lots of options. Here, we will know some of them, mainly the Swift-specific ones.

Getting ready

To do this recipe, just create a new project, as shown in the previous recipe.

How to do it...

Follow these steps for changing some Swift options:

  1. Once you've created a project, click on the navigator project icon or press command + 1 if you prefer a keyboard shortcut, then click on your project icon (the first icon). Now, click on Build Settings.
    How to do it...
  2. Look for Embedded content contains swift code; In this case, we will select NO, but of course, if you know that there is any extra content created with Swift, you should select YES.
    How to do it...
  3. Go to the General tab and scroll down; you can see where you can add the embedded binaries.
    How to do it...
  4. Now, look for Optimization Level. Here is where you tell the compiler how much time it should expend trying to make your code faster or compressing it. Usually, when we are developing (debug mode), we set for no optimization (-O0); however, when we are going to create the final product (release mode), we will usually set an optimization level such as-Os, which means fastest and smallest.

    Note

    Sometimes, with Objective-C, when you used to set a high level of optimization, the debugger used to loose some of the variable values. I haven't seen this phenomenon with Swift yet, but it's good to have it in mind.

  5. Another important option is Import paths. This tells Swift where it should look for Swift modules. If you are linking your project with external libraries, you may need to specify where the module.map file is. If you have more than one path to search, you need to set them one per line. If you have different paths for debug and release, you can still use variables such as $(CONFIGURATION) or $(TARGET).

Tip

You can use absolute or relative paths, but I would give preference to the relative ones.

How it works...

Changing settings is something that you have to do mainly when your project starts growing. There are some options that you set differently for debug and release configurations.

There's more...

Xcode has a lot of configuration settings; showing all of them would be out of the scope of this book. I recommend that you at least look at some of them, mainly if you want to work with big projects. My main recommendation here is: do not change your settings without synchronizing with the other members of your team (mainly with the project manager). If you cause a conflict with the VCS, it could be hard work to fix it.

You have been reading a chapter from
Swift Cookbook
Published in: Apr 2015
Publisher:
ISBN-13: 9781784391379
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image