如何调用适用于iOS的Swift REPL?我尝试了命令行参数,swift -sdk ...
并通过swift -h
其他调用参数查看,但没有一个跳出来.
$ swift
Welcome to Swift! Type :help for assistance.
1> import UIKit
<REPL>:1:8: error: no such module 'UIKit'
import UIKit
^
Run Code Online (Sandbox Code Playgroud)
Swift REPL在Mac上以"iOS"模式运行在Playground中; 只是希望从命令行获得相同的信息.
我可以用iOS SDK运行Swift REPL吗?
我想UIKit
在REPL中导入和使用,但没有成功.
$ xcrun --sdk iphonesimulator8.1 --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
$ xcrun --sdk iphonesimulator8.1 swift
Welcome to Swift! Type :help for assistance.
1> import UIKit
/var/folders/kb/xgglxb597sv6h8b744d5vft00000gn/T/lldb/92014/repl1.swift:2:8: error: no such module 'UIKit'
import UIKit
^
$ swift -sdk `xcrun --sdk iphonesimulator8.1 --show-sdk-path`
Welcome to Swift! Type :help for assistance.
1> import UIKit
/var/folders/kb/xgglxb597sv6h8b744d5vft00000gn/T/lldb/91881/repl1.swift:2:8: error: no such module 'UIKit'
import UIKit
^
1> import Cocoa
2>
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode版本6.1(6A1052d)
我想.swiftmodule
从 iOS 框架检查文件的公共内容。
在这里(https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160111/000827.html)我找到了一个使用建议swift-ide-test
:
您可以使用 swift-ide-test 工具来转储模块的公共接口,但命令行界面没有它应有的漂亮:
swift-ide-test -print-module -source-filename=dummy.swift -module-to-print=MyApp
...加上查找模块及其所有依赖项所需的任何 -I 或 -F 路径。如果您使用的是 Mac,则需要在开头插入“xcrun -sdk macosx”或“xcrun -sdk iphoneos”以查找系统标头。
不幸的是,当我尝试xcrun -sdk iphoneos swift-ide-test
使用 Xcode 10.1运行时,出现以下错误:
$ xcrun -sdk iphoneos swift-ide-test
xcrun: error: unable to find utility "swift-ide-test", not a developer tool or in PATH
Run Code Online (Sandbox Code Playgroud)
似乎此工具已从 Xcode 中删除。
关于如何打开.swiftmodule
文件的任何其他想法?