我正在一个现有的应用程序上实现一个非常基本的任务(从远程服务器下载几个文件),以使用新的Swift并发API。任务在iOS 15上完美无缺地完成:我使用TaskGroup并按照预期接收图像。由于这个应用程序已经存在,我使用@available标记来检查设备是否能够执行我的任务(如果是iOS 15,请执行它)。否则,向用户显示警告,什么也不做)当我试图在iOS 13.5的模拟器上运行这个应用程序时,我的应用程序会在开始时崩溃,出现以下错误:
dyld: Library not loaded: /usr/lib/swift/libswift_Concurrency.dylib
Referenced from: /Users/username/Library/Developer/CoreSimulator/Devices/B316A0F0-B7EF-4F5E-8A26-F7FF54E8A681/data/Containers/Bundle/Application/6CF3D46E-3F15-4FA3-BD61-9D353541B9DA/MyApp.app/MyApp
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/username/Library/Developer/CoreSimulator/Caches/dyld/20F71/com.apple.CoreSimulator.SimRuntime.iOS-13-5.17F61
DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.5.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/username/Library/Developer/Xcode/DerivedData/MyApp-bawyiebpygwuwxawcoistefwxuyy/Build/Products/Debug-iphonesimulator:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.5.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDI
环境: Xcode 13.0beta 2 (13A5155e)模拟器iPhone 8 (iOS 13.5)。Swift语言第5版
我能做些什么吗?
编辑:,这就是我如何使用if可用的
@available(iOS 15.0, *)
class SCTestViewController: UIViewController {...}
发布于 2021-07-14 16:15:19
找到了一个基于@对她的案子做了什么的解决方案。这不是生产代码。我还从快速快照https://swift.org/download/#snapshots下载了PKG文件,从/Library/Developer/toolchains/<snapshotname>/usr/lib/swift/<version>/libswift_Concurrency.dylib
获得了两个版本(iphoneos和iphone仿真器)。
之后,我用lipo创建了一个胖dylib文件:
❯ lipo iphoneos/libswift_Concurrency.dylib iphonesimulator/libswift_Concurrency.dylib -create -output libswift_Concurrency.dylib
❯ lipo -info libswift_Concurrency.dylib
Architectures in the fat file: libswift_Concurrency.dylib are: armv7 armv7s i386 x86_64 arm64 arm64e
之后,我将这个dylib文件作为可选库添加到我的项目中,在我的项目的目标上。
有了这个技巧,我现在可以为我的项目中的设备和模拟器构建、运行和存档( Swift论坛上的讨论表明,这将在某个时候被修复,但同时,我们可以用这个测试我们的应用程序)
https://stackoverflow.com/questions/68353353
复制相似问题