简体   繁体   English

在Xcode项目中使用GIT的问题

[英]Issues Using GIT with Xcode projects

I know git and use it to manage a lot of my Repos on other projects. 我知道git,并用它来管理其他项目上的很多Repos。 However I run into issues when it comes to xcode projects. 但是,当涉及到xcode项目时,我遇到了问题。

I start a project on Machine 'A' - when I push up to a repo and pull to let say machine 'B' I always receive compiling errors. 我在机器“ A”上启动了一个项目-当我上推一个回购并拉动说机器“ B”时,我总是会收到编译错误。 Normally the errors have to do with files not being found. 通常,错误与找不到文件有关。 Literally "no such file or directory" followed by a path. 从字面上看,“没有这样的文件或目录”,后跟路径。

I'm working with the same version of Xcode on both mac's A and B. I also use the threetwenty framework. 我在Mac的A和B上都使用相同版本的Xcode。我还使用threetwenty框架。

When I zip the project up and send via email - the same results occur. 当我压缩项目并通过电子邮件发送时-会发生相同的结果。

Many times these files that xcode can't find and that fail the build, are media files, like a image or video. 这些xcode找不到且构建失败的文件很多时候都是媒体文件,例如图像或视频。 Sometimes I see the three20 framework too. 有时我也看到three20框架。

My question is - how in xcode should I set a project up to play nice with git and or code sharing in general. 我的问题是-我应该如何在xcode中设置一个项目,使其在一般情况下与git和/或代码共享兼容。 Let me know if you need more information, I know the above is a little vague. 让我知道是否需要更多信息,我知道以上内容有点含糊。

The first thing I always do is set up the .gitignore file before adding any other files from the project. 我始终要做的第一件事是在添加项目中的其他任何文件之前设置.gitignore文件。 Problems can occur when loading project settings for two different machines that may have the same User account name. 为可能具有相同用户帐户名的两台不同的机器加载项目设置时,可能会出现问题。 You have to make sure some settings aren't added to the repo whilst others are. 您必须确保没有将某些设置添加到存储库中,而将其他设置添加到存储库中。

I set up my .gitignore by adding the following: 我通过添加以下内容来设置.gitignore:

.DS_Store
*/.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

*.mode1v3
*.mode2v3

Documentation/Generated
doxygenWarnings.txt
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad

If you create the repos from scratch or run git rm --cached <filethatshouldbeignore> to each file that should be ignored and then commit, see if the problem still occurs. 如果您从头创建存储库,或者对每个应该忽略的文件运行git rm --cached <filethatshouldbeignore> ,然后提交,请查看问题是否仍然存在。

Problems will occur in the .pbxproj file, so make sure all conflicts are corrected too. .pbxproj文件中将出现问题,因此请确保也纠正了所有冲突。

Regarding files that cannot be found, remember to import the libraries etc. into the project folders and reference them from there. 对于找不到的文件,请记住将库等导入项目文件夹并从那里引用它们。 Apple's own iOS libraries should be fine, but others won't be. 苹果自己的iOS库应该不错,但其他的则不是。 For example, in your project folder, copy your images from there and reference them only within the project folder. 例如,在项目文件夹中,从那里复制图像,然后仅在项目文件夹中引用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM