Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift frameworks do not work with build configurations named other than 'Debug' or 'Release': No such module

Whenever I try to use a build configuration named other than 'Debug' or 'Release', Xcode suddenly cannot find my Swift frameworks. The configurations are the exact same other than their name (in fact, the new configuration was duplicated from the working 'Debug' configuration).

Build configurations screenshot

Xcode reports 'No such module'

Xcode error

This seems like a really strange bug. Surely someone has come across this before? My Google search yielded no results. Does anyone have any idea what may be causing this issue? I'm pretty sure I added the framework correctly.

I've created a short screencast to show you exactly what I'm doing: http://www.screencast.com/t/zpgZ5ZYgvH

Bottom line:

  1. Make sure project currently builds using third-party Swift frameworks
  2. Select the project in the project/file navigator
  3. Select the project above Targets in the editor left sidebar and make sure you are on the Info tab
  4. Duplicate the current configuration (likely 'Debug') by clicking the + button below the list of configurations and selecting 'Duplicate XXX Configuration'
  5. Modify your scheme to use the new configuration by going to Product (menu) > Scheme > Edit Scheme...
  6. Select Run in the left sidebar
  7. Select your new configuration under Build Configuration
  8. Attempt to build again

You can also download the sample project: http://s000.tinyupload.com/?file_id=48797763216274271820

I'm running Xcode 6.0.1 (6A317) and Yosemite 10.10 (14A361c).

like image 359
DJ Tarazona Avatar asked Sep 27 '14 09:09

DJ Tarazona


People also ask

How do I get build configuration in Swift?

Adding a ConfigurationFire up Xcode and create a new project by choosing the Single View App template from the iOS > Application section. Name the project Configurations, set Language to Swift, and make sure the checkboxes at the bottom are unchecked. Tell Xcode where you'd like to store the project and click Create.

Where are build settings in Xcode?

To find a specific build setting quickly, use the filters and Search field at the top of the Build Settings tab. Select a filter to display all settings or only the modified settings. Enter text in the search field to display settings that contain the specified string. Xcode searches all settings attributes by default.


2 Answers

Add the following Framework Search Path in the Build Settings of your target: $(SYMROOT)/Release$(EFFECTIVE_PLATFORM_NAME) and make it non-recursive

In my case this was for Alamofire, which was added to my project as a git submodule.

The framework was being built correctly which can be seen in the build logs, but I assume the default framework search path is derived from the scheme name. The Alamofire framework & dSYM file are in Release-iphoneos/ Release-iphonesimulator.

This should work work with any Swift framework as long as it's scheme names are default. If not, check the build logs and adjust the framework search path accordingly.

like image 57
James Zaghini Avatar answered Sep 23 '22 23:09

James Zaghini


I had this issue as well and fixed it by adding the same configuration names to the included Alamofire project.

My build schemes in my main project: main project configs

And the build schemes inside the Alamofire project: screenshot of schemes

Note: Also, make sure your iOS deployment target is the same in both projects.

like image 26
Antoine Avatar answered Sep 23 '22 23:09

Antoine