xcodebuild says does not contain scheme

后端 未结 10 1569
天命终不由人
天命终不由人 2020-12-04 05:26

I have a curios issue.

I have a project that I\'ve worked on and always built from the XCode IDE, and it worked fine. Now I\'m setting up Bamboo to build the projec

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 06:20

    Most of the answers would suggest you to make your scheme shared using Xcode, then commit changes to repo. That works, of course, but only if you have access to source code and have rights to commit changes, and couple of other assumptions.

    But there's a number of "what ifs" to consider

    • What if you just can't modify the Xcode project for some reason?
    • What if you create a new scheme automatically on CI server?
      This actually happens quite often. If you use test automation framework, like Calabash, you'll normally end up duplicating an existing target, which automatically duplicates a scheme as well, and the new scheme is not shared, even if the original scheme was.

    Ruby & xcodeproj gem

    I would recommend using xcodeproj Ruby gem. This is a really cool open source tool that can help you to automate tons of Xcode-related tasks.

    Btw, this is the gem used by CocoaPods to mess around with your Xcode projects and workspaces.

    So install it

    sudo gem install xcodeproj
    

    Then write a simple Ruby script to re-share all the schemes, the gem has recreate_user_schemes method for that purpose

    #!/usr/bin/env ruby
    require 'xcodeproj'
    xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")
    xcproj.recreate_user_schemes
    xcproj.save
    

    It doesn't just copy scheme files form user's folder to xcshareddata/xcschemes, it also creates those files first by parsing the pbxproj file.

提交回复
热议问题