gpt4 book ai didi

swift - 如何使用xcrun编译到AppleTV?

转载 作者:行者123 更新时间:2023-11-30 12:34:40 24 4
gpt4 key购买 nike

我正在使用 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 命令返回 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

关于swift - 如何使用xcrun编译到AppleTV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43018954/

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