Swift导入语句失败 [英] Swift import statement failing
问题描述
在底部回答更新
我正在使用Twitter的新Fabric架构安装的TwitterKit框架。 ViewController.swift
中的此代码可以正常工作:
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
但我在自定义Swift文件中的代码名为 TwitterAdapter.swift
失败:
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'
我确保在创建时为所有目标添加 TwitterAdapter.swift
。以下是一些照亮目录层次结构的屏幕截图:
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:
更新:
解决了Kampai回答的后半部分。以下是完成所有工作的部分:
Solved with the latter portion of Kampai's answer. Here is the part that got it all working:
再次右键单击项目名称,然后单击将文件添加到
project-name>>选择TwitterKit.framework包并单击Add
按钮将该项框架的引用添加到项目中。
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.
推荐答案
在这里,我尝试在应用程序中添加此框架,并且完美地工作。由此可见,问题与您添加的模块的链接有关。
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:
需要突出显示点数:
- 将框架复制到项目申请文件夹。
例如:
转到其位置的查找器>>从Xcode右键单击项目名称>> 在Finder中显示将打开项目位置文件夹。在这里你必须要复制 TwitterKit.framework
包。
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.
- 再次右键单击项目名称并单击将文件添加到项目名称 >>选择
TwitterKit.framework
包并单击添加按钮会将该框架的引用添加到项目中。
- 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.
这篇关于Swift导入语句失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!