如何使用 xcrun 编译成 AppleTV?

How to use xcrun to compile to AppleTV?

我正在使用 xcrun 编译我想在 AppleTV 应用程序中使用的动态库。

使用此命令,我可以编译我的 dylib 并在 OS X:

中使用
➜  logger git:(master) ✗ ls
main.swift
➜  logger git:(master) ✗ xcrun swiftc -emit-library main.swift
➜  logger git:(master) ✗ ls
libmain.dylib main.swift
➜  logger git:(master) ✗ file libmain.dylib 
libmain.dylib: Mach-O 64-bit dynamically linked shared library x86_64

但是,我无法在 AppleTV 模拟器中使用它。 dlopen 命令 return nil.

然后,我尝试了一些参数,比如波纹管,但无法正常工作

➜  logger git:(master) ✗ xcrun swiftc -emit-library -sdk $(xcrun --show-sdk-path --sdk appletvsimulator10.1) main.swift
<unknown>:0: warning: using sysroot for 'AppleTVSimulator' but targeting 'MacOSX'
ld: warning: URGENT: building for OSX, but linking against dylib (/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator10.1.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation) built for tvOS. Note: This will be an error in the future.
ld: warning: URGENT: building for OSX, but linking against dylib (/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator10.1.sdk/usr/lib/libobjc.dylib) built for tvOS. Note: This will be an error in the future.
ld: warning: URGENT: building for OSX, but linking against dylib (/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator10.1.sdk/usr/lib/libSystem.dylib) built for tvOS. Note: This will be an error in the future.

如何将我的 Swift 代码编译为动态库以便在 AppleTV 中使用?

对于模拟器:

xcrun swiftc -emit-library -sdk $(xcrun --show-sdk-path --sdk appletvsimulator10.2) main.swift

对于物理设备:

xcrun swiftc -emit-library -sdk $(xcrun --show-sdk-path --sdk appletvos10.2) main.swift