如何从 GitHub 私有存储库下载 iOS 应用程序配置文件
我正在开发一款 iPhone 游戏,希望将其设置为下载配置数据,以便我可以进行构建,然后我或我的队友可以进行更改并重新运行游戏而不是重建(对于非程序员,重新分发构建)。
这基本上是一件简单的事情,我可以将其设置为使用 NSURL 从公共 Dropbox 或 FTP 下载,没有问题。
但是,我们使用 GitHub 进行修订控制,因此最好从 GitHub 下载文件,然后我们就可以获得配置数据处于修订控制之下的优势,而无需在修改文件时手动将文件复制到共享(需要显然是提交/推送,但这已经是工作流程的一部分)。请注意,我不需要签出文件或对其执行任何实际的版本控制操作,因为应用程序不会修改它,我只需要应用程序获取文件的最新版本。
GitHub 允许基于 Web 浏览存储库,因此这个问题似乎应该减少为从 URL 下载文件,但由于我们的存储库是私有的,我不确定如何处理身份验证。看起来 NSURLConnection 类可以处理身份验证,但我尝试对其进行设置,但无法获取我的文件。老实说,我什至不确定 GitHub 的身份验证系统是否可以实现这一点。不幸的是,我没有太多的 HTTP 或 Web 开发背景,所以对我来说,这是一种我不知道如何解决问题的情况。
我在 Google 和 SO 上进行了一些搜索,很惊讶我没有找到任何做此类事情的简单示例,我认为从源代码管理下载应用程序数据将是一件很常见的事情; GitHub 私有存储库部分显然让它有点特别,但现在似乎每个人都在使用 GitHub。
感谢您的任何帮助。
I am working on an iPhone game and would like to set it up to download configuration data so I can put up a build and then I or my teammates can make changes and just rerun the game rather than rebuild (and for non-programmers, redistribute the build).
This is basically an easy thing to do, I can set it up to download from a public Dropbox or FTP using NSURL no problem.
However, we are using GitHub for revision control, so it would be nice to download the file from GitHub and then we get the advantages of having configuration data under revision control without having to manually copy the file to a share when it's modified (need to commit/push obviously but that's already part of the workflow). Note that I don't need to check the file out or do any actual revision control operations on it as it won't be modified by the app, I just need the app to acquire the latest revision of the file.
GitHub allows web-based browsing of repositories, so it seems like this problem should reduce to downloading a file from a URL, but since our repository is private I'm not sure how to handle the authentication. It looks like the NSURLConnection class can handle authentication, but I've tried to set that up and I can't get my file. I'm honestly not even sure if this is possible with GitHub's authentication system. I unfortunately do not have much of an HTTP or Web development background, so for me this is a situation where I don't know what I don't know about approaching the problem.
I searched around a bit on Google and SO and was surprised I didn't find any straightforward examples of doing this sort of thing, I figured downloading application data from source control would be a pretty common thing to do; the GitHub private repository part obviously makes it a bit special but it seems like everyone is using GitHub these days.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您认为您的配置数据是超级机密,否则在中央存储库中设置一个接收后挂钩将数据导出到不需要身份验证的 URL 可能会更容易。
Unless you consider your configuration data to be super-secret, it might be easier to just set up a post-receive hook in your central repo that exports the data to a URL that doesn't require authentication.