xcode 如何为 ios 应用程序使用私有 github 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25045697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:18:45  来源:igfitidea点击:

How to use private github repository for ios apps

xcodegitgithub

提问by Rdesmond

I'm currently starting to develop an ios app with some friends. We'd like to use a private github repository for version control so we can collaboratively work and push changes to the code. Xcode 5 creates a local git repository, but there seems to be some differences between using git for an iphone app versus the class projects (java projects like connect 4) that I've been used to.

我目前开始和一些朋友一起开发一个 ios 应用程序。我们希望使用私有 github 存储库进行版本控制,以便我们可以协同工作并推送对代码的更改。Xcode 5 创建了一个本地 git 存储库,但将 git 用于 iphone 应用程序与我已经习惯的类项目(java 项目,如 connect 4)之间似乎存在一些差异。

I've created a repository on github, and pushed an initial commit from my local xcode project to the github repository. However, I'm not sure if others will be able to download the code and import it into an xcode project and have it work as intended.

我在 github 上创建了一个存储库,并将初始提交从我的本地 xcode 项目推送到 github 存储库。但是,我不确定其他人是否能够下载代码并将其导入 xcode 项目并使其按预期工作。

For one, the files on github are organized differently than it displays from my workspace in xcode 5. From the project navigator, most of the yellow folders (folder references, which I don't fully understand) aren't actually folders, and don't appear on the github page. Also, many things (infoPlist.strings, frameworks) are represented in a humongous "project.pbxproj" file, along with confusing build information.

首先,github 上的文件的组织方式与我在 xcode 5 中的工作区显示的不同。从项目导航器中,大多数黄色文件夹(文件夹引用,我不完全理解)实际上并不是文件夹,并且不'不会出现在 github 页面上。此外,许多内容(infoPlist.strings、框架)都在一个庞大的“project.pbxproj”文件中表示,以及令人困惑的构建信息。

I know that this is a vague question, but I really had no idea what to look up or read. Let me know if there's any way I can improve asking questions on stack overflow. Also, if you know any guides that would help me out with this kind of stuff, I'm all ears.

我知道这是一个模糊的问题,但我真的不知道要查找或阅读什么。让我知道是否有任何方法可以改进有关堆栈溢出的问题。另外,如果您知道任何可以帮助我解决此类问题的指南,我会全神贯注。

回答by Mihir

Introduction

介绍

Git and Xcode work wonderfully together to create applications that foster teamwork and minimize versioning complications. However, it's important to understand the basics of Git before proceeding. This answer will walk you through the steps of integrating Git with Xcode, which really isn't too complicated once you understand what's going on.

Git 和 Xcode 完美地协同工作,以创建促进团队合作和最小化版本控制复杂性的应用程序。但是,在继续之前了解 Git 的基础知识很重要。这个答案将引导您完成将 Git 与 Xcode 集成的步骤,一旦您了解正在发生的事情,这实际上并不太复杂。

The difference between Git and GitHub

Git 和 GitHub 的区别

(The OP might know this distinction, but this is really for anyone else who visits this page and is confused)

(OP 可能知道这种区别,但这确实适用于访问此页面并感到困惑的其他任何人)

The first thing to understand is that Git and GitHub are two completely different things. Git is a version control system, like Subversion (SVN), or PerForce. It can be used independently of GitHub. GitHub is a cloud repository storage system that is integrated with Git. That's why it's called GitHUB; it's a HUB for your code and all it's versions/commits. Git can work with many repository storages, one of them being BitBucket. (This is unlike Subversion, which doesn't have a local repository and a remote repository; you have to push changes from your local repository to your remote repository in Git).

首先要理解的是,Git 和 GitHub 是两个完全不同的东西。Git 是一个版本控制系统,类似于 Subversion (SVN) 或 PerForce。它可以独立于 GitHub 使用。GitHub 是一个与 Git 集成的云存储库存储系统。这就是它被称为 GitHub 的原因;它是您的代码及其所有版本/提交的集线器。Git 可以使用许多存储库存储,其中之一是 BitBucket。(这与 Subversion 不同,Subversion 没有本地存储库和远程存储库;您必须将更改从本地存储库推送到 Git 中的远程存储库)。

The question asked how to integrated GitHub with Xcode - the evil answer to that is you do not; you integrate Git with Xcode (which Apple has already pretty much done for you). When you commit something in Git locally, you pushto GitHub, where your code is stored, and where others (e.g. team members or the public, depending on your privacy settings) can clone or fork your repository and build on it.

该问题询问如何将 GitHub 与 Xcode 集成 - 对此的邪恶答案是您没有;您将 Git 与 Xcode 集成(Apple 已经为您完成了很多工作)。当您在 Git 本地提交某些内容时,您会送到 GitHub,您的代码存储在那里,其他人(例如团队成员或公众,取决于您的隐私设置)可以克隆或分叉您的存储库并在其上构建。

Create a remote repository

创建远程仓库

Let's assume you're starting from scratch. If you're not starting from scratch and already have code in a remote repository, skip this step.

假设您从头开始。如果您不是从头开始并且已经在远程存储库中有代码,请跳过此步骤。

In this step, you want to create your repository on GitHub or BitBucket. Follow the instructions that these sites give you to create the repository.

在此步骤中,您要在 GitHub 或 BitBucket 上创建您的存储库。按照这些站点为您提供的说明创建存储库。

Getting the URL to Clone the repository

获取克隆存储库的 URL

Whether you're using GitHub or BitBucket, you have to be able to tell Xcode where you are storing your code. Find the URI that allows you to clone the repository; GitHub and Bitbucket should have easy steps for finding these. Usually look for the word "clone" on the main screen of your repository, and you'll find it.

无论您使用的是 GitHub 还是 BitBucket,您都必须能够告诉 Xcode 您将代码存储在哪里。找到允许您克隆存储库的 URI;GitHub 和 Bitbucket 应该有找到这些的简单步骤。通常在存储库的主屏幕上查找“克隆”一词,您会找到它。

Clone locally

本地克隆

Fire up Xcode, with a new project. Hit the "Source Control" menu bar item, and select "Checkout". In the popup where it says "Or enter a repository or location", copy the clone URI that you acquired in your previous step. Then hit next. When asked to clone, Xcode will prompt for a branch; pick which one you want for now. If you have no idea what branching is, then choose "master".

启动 Xcode,创建一个新项目。点击“Source Control”菜单栏项,然后选择“Checkout”。在显示“或输入存储库或位置”的弹出窗口中,复制您在上一步中获取的克隆 URI。然后打下一个。当要求克隆时,Xcode 会提示一个分支;选择你现在想要的。如果您不知道什么是分支,请选择“master”。

Conclusion

结论

Now you're all set. From now on, most things you need will be under the "Source Control" menu bar items as well; this includes committing, pushing and pulling. Enjoy, and good luck!

现在你已经准备好了。从现在开始,您需要的大部分内容也将位于“源代码管理”菜单栏项下;这包括承诺、推动和拉动。享受,祝你好运!

回答by Obj-Swift

Setup the Xcode project as shown here.

设置如图所示的Xcode项目在这里

Once, done you can see which file's have been added,modified etc in project navigator. https://www.dropbox.com/s/r5gsfh2raxwkam6/Screenshot%202014-07-30%2015.03.03.png

完成后,您可以在项目导航器中看到哪些文件已添加、修改等。 https://www.dropbox.com/s/r5gsfh2raxwkam6/Screenshot%202014-07-30%2015.03.03.png

For commit,push, or to discard changes, use

对于提交、推送或放弃更改,请使用

enter image description here

在此处输入图片说明

Here's detailed tutorial : http://www.raywenderlich.com/51351/how-to-use-git-source-control-with-xcode-in-ios-7

这是详细教程:http: //www.raywenderlich.com/51351/how-to-use-git-source-control-with-xcode-in-ios-7