Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 alist-ios 构建后放到自己的项目报错 #1

Closed
toutoumu opened this issue Aug 16, 2024 · 2 comments
Closed

使用 alist-ios 构建后放到自己的项目报错 #1

toutoumu opened this issue Aug 16, 2024 · 2 comments

Comments

@toutoumu
Copy link

toutoumu commented Aug 16, 2024

我使用命令
gomobile bind -target ios -tags netgo -bundleid com.toutoumu.alist -o /Users/apple/WorkSpace/alist/AListFlutter/ios/Runner/Alist/Alistlib.xcframework -ldflags "-s -w" github.com/alist-org/alist/v3/alistlib 构建好后放到我自己的项目中报错了, 无法运行, 但是在 App Store 下载的可以正常运行. 我对IOS开发不是太懂, 因此希望大侠能够帮忙解答一下是什么原因. 下面是错误日志和我的代码

func dataDir() -> String {
        let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
        NSLog(" \(documentsDirectory.path)")
        return documentsDirectory.path
    }

   func initAlist() {
        Alistlib.AlistlibSetConfigDebug(true)
        Alistlib.AlistlibSetConfigData(dataDir())
        Alistlib.AlistlibSetConfigLogStd(true)
        var error: NSError?
        Alistlib.AlistlibInit(self, self, &error)
    }
/var/mobile/Containers/Data/Application/1D5DCA30-D994-4765-B5F7-00A5AD87F3BB/Documents


2024/08/16 09:08:22 �[35m/Users/apple/WorkSpace/alist/alist-ios/internal/bootstrap/db.go:54
�[0m�[31m[error] �[0mfailed to initialize database, got error unable to open database file: no such file or directory
Failed to write to log, can't make directories for new logfile: mkdir /var/mobile/Containers/Data/Application/B4C225D9-2FD8-4D95-B25D-9D2FC9BEE35A: operation not permitted


2024/08/16 09:08:22 �[32m/Users/apple/WorkSpace/alist/alist-ios/internal/db/db.go:26
�[0m�[33m[0.001ms] �[34;1m[rows:0]�[0m SELECT count(*) FROM sqlite_master WHERE type='table' AND name="x_storages"

这里的两个路径都不一样, 感觉像是把数据库创建到领一个应用里去了
/var/mobile/Containers/Data/Application/1D5DCA30-D994-4765-B5F7-00A5AD87F3BB/Documents
/var/mobile/Containers/Data/Application/B4C225D9-2FD8-4D95-B25D-9D2FC9BEE35A

@sunzongzheng
Copy link
Owner

应该是你成功运行过一次,alist配置文件记录了绝对路径,再次运行的时候由于iOS沙盒机制,应用Document目录发生变化,路径变了而没有处理。你的客户端需要做类似的处理:

const ensureConfigDirectory = useCallback(async () => {

@toutoumu
Copy link
Author

非常感谢,问题已经解决了,昨天发布的商店版本,同步功能非常好用,再次感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants