0

I've converted an app project from ObjC to Swift. It uses several ObjC frameworks that are managed with Cocoa Pods.

When I try to build it I get an error:

No such module 'Foo'

The Foo file is an ObjC header file that has no .m file. It is used to bind several other classes into one import (in ObjC). here's how the Foo.h would look:

#import <Foo/FooDefines.h>
#import <Foo/FooToken.h>
#import <Foo/FooAccount.h>
#import <Foo/FooAccountPersistenceInformation.h>
#import <Foo/FooAccountUserInformation.h>
#import <Foo/FooSettings.h>

// Authenticators
#import <Foo/FooAuthenticator.h>
#import <Foo/FooAnonymousAuthenticator.h>
#import <Foo/FooUserPasswordAuthenticator.h>

// UI
#import <Foo/FooViewController.h>
#import <Foo/RLoginDialog.h>
#import <Foo/RLogoutDialog.h>
#import <Foo/RAccountSelectionDialog.h>
#import <Foo/RVerificationDialog.h>
#import <Foo/RBuiltinLogoutActionSheet.h>

// Workflows
#import <Foo/RLoginWorkflow.h>
#import <Foo/RVerificationWorkflow.h>
#import <Foo/RLogoutWorkflow.h>

How would I be able to import this successfully in a Swift class to get beyond the compile-time error?

BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
  • You should add classes into "Bridging Header" – Jack Jun 05 '17 at 08:27
  • add all your Objective-C .h file imports in "$(PROJECT_NAME)-Bridging-Header.h " file. Refer this https://stackoverflow.com/questions/26096402/xcode-myprojectname-bridging-header-h-does-not-exist?noredirect=1&lq=1 for more info – Suhit Patil Jun 05 '17 at 08:30
  • @suhit Hmm I've added `#import ` to the bridging header file but still getting the same error (after clean). – BadmintonCat Jun 05 '17 at 08:34
  • can you add all the imports inside file in Bridging-Header file and try – Suhit Patil Jun 05 '17 at 08:57

1 Answers1

1

Try using #import <Foo/Foo.h> or #import "Foo.h"

Aravind A R
  • 2,674
  • 1
  • 15
  • 25
  • Please confirm whether you have used this inside the bridging header and cleaned project each time. – Aravind A R Jun 05 '17 at 09:09
  • Confirmed but not working! Side question: Do I need to have use_frameworks! in my pod file for the Swift target? I'm also getting a warning when using `pod install`: [!] The Podfile contains framework targets, for which the Podfile does not contain host targets (targets which embed the framework). If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target). – BadmintonCat Jun 06 '17 at 00:28
  • Another oddity: Besides Xcode I'm using AppCode and in AppCode I can CMD-click the non-imported classes in my code and it jumps to them. But the imports aren't found. – BadmintonCat Jun 06 '17 at 00:30
  • Yup you need to use "use_frameworks!" in podfile for swift target. Sorry I haven't tried AppCode yet. – Aravind A R Jun 06 '17 at 09:37