为什么链接器将静态库与错误链接?的iOS [英] Why linker link static libraries with errors? iOS
问题描述
将我的混合语言框架链接到项目时遇到问题.
1)我创建了一个包含Swift和Objective-C类的框架. 2)主要逻辑存储在Swift文件中.例如,该类具有调用NSLog("Swift log was created")的方法.
3)Objective-C文件具有一个类,该类具有一个方法,在该方法中,我创建了Swift类的实例并调用Swift-log方法.
4)我将此框架链接到我的Objective-C项目,可以调用该项目中需要的所有内容,但是当我要构建该项目时,会收到错误" linker command failed with exit code 1 (use -v to see invocation)
"
和警告:
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
我还看到了导入空Swift文件的解决方案,但是必须创建一个没有任何垃圾的项目.
I have a problem with linking my mixed language framework to a project.
1) I create a framework with Swift and Objective-C classes.
2) The main logic was stored in the Swift file. For example the class with a method that calls NSLog("Swift log was called").
3) Objective-C file has a class that has a method in which I create an instance of Swift class and call Swift-log method.
4) I link this framework with my Objective-C project, I can call all that I need in this project, but when I want to build this project I receive error "linker command failed with exit code 1 (use -v to see invocation)
"
And warnings:
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
I also saw the solution with importing empty Swift-file, but it necessary to make a project without any trash.
推荐答案
- 在Xcode中打开ios/YourAppName.xcodeproj
- 在左侧的项目导航器中右键单击您的应用程序名称,然后单击新建文件".
- 为项目创建一个空的Swift文件(添加时请确保选择了您的应用名称"目标)
- 当Xcode询问时,请按Create Bridging Header,然后不要删除Swift文件. 重新运行您的构建.
- Open ios/YourAppName.xcodeproj in Xcode
- Right-click on Your App Name in the Project Navigator on the left, and click New File…
- Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding)
- when Xcode asks, press Create Bridging Header and do not remove Swift file then. re-run your build.
这应该可以解决问题
这篇关于为什么链接器将静态库与错误链接?的iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!