简体   繁体   中英

Xcode bot: cloning multiple repositories before build

I have three repositories for my current project. They contain some shareable core functionality and individualized components:

  • MainApp.git
  • Components.git
  • Controls.git

The xcworkspace lies in MainApp.git and links to its own xcodeproj file as well as the other xcodeprojs in the two other repositories.

When creating a bot in Xcode server, there's only the option to select one repository for cloning. This lets the build fail eventually, since it cannot find any resources needed from the Components.git and Controls.git.

How can I achieve a working build with my workspace configuration?

You could:

1) Add all the code to the main repo (I highly advise against it)

2) Use a dependency manager such as Cocoapods, where you would have to create podspecs for your dependencies. If they are open-source great they are probably already in GitHub in Specs . Integration between Xcode bots and Cocoapods is kind of broken right now. You could have a pre-build script running the command:

pod install

Amongst other things. See here

3) Use git submodules . They can give you some headaches but they usually do the job when it comes to managing enterprise dependencies. Once again, unfortunately, they are completely broken in Xcode bots:

Xcode bots with git submodules

Problems with Xcode Bots

The list is large, a mere search on twitter for problems related with git/cocoapods and Xcode bots will show you how frustrating it can be.

My personal opinion, if it is a small project and you want to see what Apple's been up to, Xcode bots are great, also the built-in integration inside the IDE is amazing and something to look for in the upcoming iterations.

However, if the project is complex, with some dependencies, maybe UI Automation, integration with Testflight/HockeyApp, etc, I would go with either Jenkins or Travis CI . Stick with something that has a great community, years of development, plugins..

I was looking for this answer myself, but was not satisfied with the suggestions.

Turns out, it is possible to do everything inside Xcode with just a little helping from the Terminal.

I detailed it here: http://swiftrien.blogspot.com/2016/04/xcode-server-and-multiple-repositories.html

But will summarise here.

1) Create a workspace directory. None of the projects to-be in the workspace should be in this directory (or any of its subdirectories).

2) Using Xcode, create the workspace. You can add the projects now.

3) Exit Xcode.

4) In Terminal go to the workspace directory and do "$ git init"

5) Add a ".gitignore" file with ".DS_Store" and "xcuserdata".

6) Add the files with "$ git add ."

7) Commit the files with '$ git commit -m "Initial commit"'

8) Exit Terminal, start Xcode and open the workspace

9) Use the "Source Control" menu to verify that you now have a git repo for the workspace.

10) Use the "Source Control" menu to add a remote repo on the server.

11) For all projects, use the "Source Control -> Configure ..." menu to tell Xcode that that repo is necessary to include in the checkout.

You will need to create new bots or upgrade the old ones.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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