xcode swift项目运行、连接真机运行报错,引入文件夹失败

最近乱七八糟解决了很多报错,看着记录点吧

xcode版本:16

  1. failed to emit precompiled header '/Users/yuqing/Library/Developer/Xcode/DerivedData/cloudspace-ios-ejldldcfhouqnretchuzoewmsqkg/Build/Intermediates.noindex/PrecompiledHeaders/spice-bridging-swift_3NESF7AR5B9EZ-clang_2VK5NNZMD2JQ0.pch' for bridging header '/Users/yuqing/Desktop/cloudspace-ios/cloudspace-ios/spice-bridging.h'

解决方法:

  1. 连接真机运行报错
    dyld[34390]: Library not loaded: @rpath/libpixman-1.0.dylib
    Referenced from: <27C19E31-3CAC-3029-91AF-D563F06A2CF7> /private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/cloudspace-ios.app/cloudspace-ios.debug.dylib
    Reason: tried: '/usr/lib/system/introspection/libpixman-1.0.dylib' (no such file, not in dyld cache), '/private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/Frameworks/libpixman-1.0.dylib' (no such file), '/private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/cloudspace-ios.app/libpixman-1.0.dylib' (no such file), '/private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/Frameworks/libpixman-1.0.dylib' (no such file), '/private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/cloudspace-ios.app/libpixman-1.0.dylib' (no such file), '/private/var/containers/Bundle/Application/101FCD29-5874-4D03-9BB5-EA4FA22C2793/Frameworks/libpixman-1.0.dylib' (no such file)

解决方法:

修改runpath search paths

@executable_path/Frameworks

$(inherited)

  1. xcode中引入文件夹下的html,报错找不到文件

解决办法:

  1. 我引入的html是一个uniapp打包出的h5,嵌入项目后可以正常展示,但uni.navigateback({delta:1})方法失败,返回无效 原代码:
bash 复制代码
    func loadLocalHTML() {
        if let filePath = Bundle.main.path(forResource: "index", ofType: "html", inDirectory: "h5") {
            do {
                NSLog("---------开始h5---------")
                let htmlString = try String(contentsOfFile: filePath, encoding: .utf8)
                let baseURL = Bundle.main.url(forResource: "h5", withExtension: nil)
                webView!.loadHTMLString(htmlString, baseURL: baseURL)
            } catch {
                print("读取文件失败: \(error)")
            }
        } else {
            print("未找到h5/index.html 文件")
        }
    }

解决方法:

bash 复制代码
    func loadLocalHTML() {
        guard let htmlFolderPath = Bundle.main.path(forResource: "h5", ofType: nil) else {
            print("not file")
            return
        }
        let htmlFilePath = (htmlFolderPath as NSString).appendingPathComponent("index.html")
        let fileManager = FileManager.default
        if !fileManager.fileExists(atPath: htmlFilePath) {
            print("Error: 'index.html' not found at path: \(htmlFilePath)")
            return
        }
        let fileURL = URL(fileURLWithPath: htmlFilePath)
        webView.loadFileURL(fileURL, allowingReadAccessTo: fileURL.deletingLastPathComponent())
    }
相关推荐
HarderCoder36 分钟前
深入理解 Swift 的 `@dynamicCallable`:让你的类型像函数一样被调用
swift
littleplayer12 小时前
Swift: Combine基本使用
swift
MicrosoftReactor1 天前
技术速递|Model Context Protocol (MCP) 支持已上线 JetBrains、Eclipse 和 Xcode
ai·eclipse·copilot·xcode·mcp
大熊猫侯佩1 天前
SwiftUI 三阵诀:杨过绝情谷悟 “视图布阵” 之道
swiftui·swift·apple
大熊猫侯佩1 天前
斯塔克工业技术日志:用基础模型打造 “战甲级” 结构化 AI 功能
ai编程·swift·apple
Magnetic_h1 天前
【iOS】内存管理及部分Runtime复习
笔记·学习·macos·ios·objective-c·cocoa·xcode
HarderCoder2 天前
Swift 数据容器全景手册:Sequence、Collection、Set、Dictionary 一次掌握
swift
HarderCoder2 天前
深入理解 SOLID 原则:用 Swift 编写优雅、可维护的代码
swift
HarderCoder2 天前
Swift 并发全景指南:Thread、Concurrency、Parallelism 一次搞懂
swift
HarderCoder2 天前
Swift 并发模型深度解析:Singleton 与 Global Actor 如何抉择?
swift