gpt4 book ai didi

xcode - 在没有 xcode 的情况下编译 swift 模块/框架/库

转载 作者:搜寻专家 更新时间:2023-10-31 22:50:21 24 4
gpt4 key购买 nike

写一个 Swift 框架,我想知道,我可以不使用 Xcode 来编译它吗?我用 -module 选项尝试了“swift”,但无论我做什么,“swift”命令似乎都没有产生任何输出。带有-parse-as-library 的“swiftc”给出了“ undefined symbol _main”错误

那么,如何在没有 Xcode 的情况下编译 swift 库?

最佳答案

从 Swift 2.2 开始,您可以使用 swiftc 直接从命令行使用 -emit-module 标志编译 swiftmodule 像这样:

$ swiftc -emit-module MyClass.swift
$ ls
MyClass.swift
MyClass.swiftdoc
MyClass.swiftmodule

使用 --help 标志查看完整的选项列表。另见 Creation of pure Swift module博客文章以获得更完整的教程。


Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9

关于xcode - 在没有 xcode 的情况下编译 swift 模块/框架/库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30166922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com