shmim
shmim

Reputation: 749

Objective-C class can't import swift pod defined at top level

Here's my Podfile:

platform :ios, '9.0'
use_frameworks!

target :Test_Swift_Import do
  pod 'BFKit-Swift', '1.5.1' //Just a swift pod to provide some methods to test
  pod 'SwiftySwift', '1.0.1' //and another
end

In my AppDelegate class I try to use a simple method from BFKit

BOOL isEmail = [@"not an email" isEmail]; 

My AppDelegate is an objective-c class, not Swift

In order to make this work I try to import the BFKit Swift module

First I try the well-known way:

//Basic <Product_Name-Swift.h>
#import <Test_Swift_Import-Swift.h>

But this SO post and this one too both say to use <ProjectName/ModuleName-Swift.h>. Because the code is in a module, this makes sense to me.

So I try #import <Test_Swift_Import/BFKit-Swift.h>

No deal...

I rename my project to TestSwiftImport in case underscores are a problem

No deal...

I try importing the module directly

<BFKit/BFKit.h>

Alas...

Relevant Xcode Build Settings

defines modules : Yes
Product Module name: TestSwiftImport 
Enable Modules: Yes
Link Frameworks Automatically: Yes
Objective-C Generated Interface Header Name: TestSwiftImport-Swift.h
Objective-C Bridging Header: TestSwiftImport/TestSwiftImport-Bridging-Header.h

Drastic Things I've Tried

I've done all manner of cleaning project and build folder, wiping derived data, resetting simulator, quitting simulator, quitting Xcode and restarting machine, all to no avail. It's sad that these are even things I think of doing and that they sometimes work... But not in this case.

Github Demo Project Displaying Problem

...is here

Any ideas? There are even more failed attempts that you can see if you open the project. This can't be this hard...

Upvotes: 2

Views: 1713

Answers (1)

vien vu
vien vu

Reputation: 4337

I see that is problem of CocoaPods.

Now If I try drag file straight to xcode it will work normal. If you really need it. You can drag all file to project. Not use cocoa-pods now.

enter image description here

You can reference to this question: Question

Hope this help!

Upvotes: 1

Related Questions