为什么我的静态库会出现 iOS 链接器错误? [英] Why do I get iOS linker errors with my static libraries?

查看:35
本文介绍了为什么我的静态库会出现 iOS 链接器错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

解决方案

  1. Open ios/YourAppName.xcodeproj in Xcode
  2. Right-click on Your App Name in the Project Navigator on the left, and click New File…
  3. Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding)
  4. when Xcode asks, press Create Bridging Header and do not remove Swift file then. re-run your build.

This should fix the problem

这篇关于为什么我的静态库会出现 iOS 链接器错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆