0

I'm writing a script to build and generate an .app file from an specific target and scheme (to work with simulator). I was using something like:

DEVELOPER_DIR=$xcode_app_path/Contents/Developer xcodebuild -sdk iphonesimulator -scheme "${SCHEME}" -target "${TARGET}" ONLY_ACTIVE_ARCH=NO CONFIGURATION_BUILD_DIR="${build_folder}" clean build

The problem is, that I need to open XCode for the code above to work, otherwise will show me a message telling me that:

xcodebuild: error: The project 'Project-name' does not contain a scheme named "${SCHEME}"

I still yet, don't understand what is XCode doing in background. But if I open the IDE and run the script, works. If I open and later close it, and run the script works. It's not working if the project hasn't been opened first with XCode ¬¬

Any suggestion would be appreaciated

Sophy Swicz
  • 1,307
  • 11
  • 21

1 Answers1

1

If someone is facing the same experience, this is what I found out. And works.

Well, apparently when you create a new scheme through command line, by default is not "shared". So when you start to link to the folder

xcshareddata --> xcschemes 

(trying to build with command line, for example) there's nothing to link with. Xcode do this automaticaly under the hood when you open your project...

The guys from CocoaPods were facing the same issue, so they created a Ruby gem that shares the scheme and place the file in his xcscheme folder:

This is the repo: https://github.com/CocoaPods/Xcodeproj

Also, thanks to this post and this post I found out how to use xcodeproj gem, and change the shared option with a script that I put downhere:

require 'xcodeproj'
xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
Community
  • 1
  • 1
Sophy Swicz
  • 1,307
  • 11
  • 21