Search code examples
xcodepodfile

XCode Project with Podfile - Git Repo


Which files of a XCode Project should I upload to my git repo to build the project from any computer? The project was generated by Apache Cordova. I supose that it is enough uploading the .xcodeproj and the podfile. But if I open the .xcodeproj how can I tell XCode that as pre-build action should download the packages specified in the podfile?


Solution

  • If you use Cocoapods, after pod install, you can see a Podfile.lock, Pods folder and .xcworkspace.

    • Podfile.lock: the lockfile for the dependencies. Usually, you got the version info of the dependencies.

    • Pods : usually, can ignore this in .gitignore file. It contains the dependencies for your projects, those you specified in the Podfile and their own dependencies.

    • .xcworkspace. Right click it -> Show Packages Contents.

      enter image description here

      • you can ignore xcuserdata, it contains local info about the user. It will be changed when other users open this .xcworkspace
      • ignore the xcshareddata, it has info about the IDE.
      • while the contents.cxworkspacedata contains a reference to your project and Pods.xcodeprojc, which is generated by pod install to manager your dependency targets.
    <?xml version="1.0" encoding="UTF-8"?>
    <Workspace
       version = "1.0">
       <FileRef
          location = "group:YourOwnProject.xcodeproj">
       </FileRef>
       <FileRef
          location = "group:Pods/Pods.xcodeproj">
       </FileRef>
    </Workspace>
    

    When your colleagues pull your changes, run Pod install locally to generate the missing Pods/* and Open xxx. xcworkspace.