简体   繁体   中英

Swift import statement failing

UPDATED with answer at bottom

I am using the TwitterKit framework as installed with Twitter's new Fabric platform. This code in ViewController.swift works just fine:

//
//  ViewController.swift
//  Following
//
//  Created by David Aragon on 12/4/14.
//  Copyright (c) 2014 David Aragon. All rights reserved.
//

import UIKit
import TwitterKit

But this code in a custom Swift file I made called TwitterAdapter.swift fails:

//
//  TwitterAdapter.swift
//  Following
//
//  Created by David Aragon on 12/10/14.
//  Copyright (c) 2014 David Aragon. All rights reserved.
//

import Foundation
import TwitterKit // Error: No such module 'TwitterKit'

I made sure to add TwitterAdapter.swift to all my targets when I created it. Here are some screen shots to illuminate the directory hierarchy:

在此处输入图片说明在此处输入图片说明

UPDATE:

Solved with the latter portion of Kampai's answer. Here is the part that got it all working:

Again right click on the project name and click on Add files to "project-name" >> Select TwitterKit.framework bundle and click on Add button will add a reference of that framework to project.

I had a same error with Xcode 7

Helped to uncheck and then check again a checkbox field standing for linking the broken framework in the target membership section 在此处输入图片说明

Here I have tried to add this framework in application and its perfectly working. From this it is clear that issue is related to linking with the module you have added.

Relink / Reference again with the module will resolve this issue:

Points need to be highlight:

  1. Copy the framework to project application folder.

For example:

Go to finder of its location >> From Xcode right click on project name >> Show in finder will open project location folder. Here you must have to copy TwitterKit.framework bundle.

在此处输入图片说明

  1. Again right click on the project name and click on Add files to "project-name" >> Select TwitterKit.framework bundle and click on Add button will add a reference of that framework to project.

I was facing the same problem. My project was swift based and there were no objective C code. I wanted to add 3rd party framework and on import facing same error "no such module". I solved it by adding a bridging-header file in swift and just import framework there. It works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM