문제

This is my build command

xcodebuild -workspace MyApp.xcworkspace \
           -scheme MySchemeName \
           -configuration AdHoc \
           clean archive

It works but its uses the default configuration for the archive scheme (which is release) instead of AdHoc which I specified. In fact if you specify -scheme ASchemeNameThatDosnNotExist it still works and silently ignores the configuration name.

The project is setup like this:

xcodebuild -list
Targets:
    MyApp
    MyAppTests

Build Configurations:
    Debug
    AdHoc
    Release

If no build configuration is specified and -scheme is not passed then "Release" is used.

This project contains no schemes.

And the workspace like this:

xcodebuild -workspace MyApp.xcworkspace -list
Schemes:
    MyApp
    Pods
    Pods-AFNetworking
    .. More pods

I.e. There are no targets and no configurations in the workspace.

How do I make a target visible to the workspace? Or is there another way?

도움이 되었습니까?

해결책

It's impossible to configure target for workspace. You can create a scheme based on a particular target and then build a project passing scheme name. Setting configuration via '-configuration' switch works fine for me. I use xcode v. 5.0.2.

In general a configuration is set via action. You can create multiple schemes for archiving (with different configurations) and there's no need to pass configuration at all. Default configuration will be taken.

다른 팁

Thank you @Opal for your answer. I was initially mislead by your statement that '-configuration' was working. In fact, this does not work, and the specified configuration is silently ignored when performing an xcodebuild via the workspace:

xcodebuild -workspace $WORKSPACE.xcworkspace \
    -scheme $SCHEME \
    -configuration QA \
    clean archive -archivePath archives/$APP_NAME

xcodebuild -exportArchive \
    -archivePath archives/$APP_NAME.xcarchive \
    -exportPath . \
    -exportOptionsPlist $WORKSPACE/ExportOptions.plist

mv $APP_NAME.ipa $APP_NAME.$VERSION.$BUILD_NUMBER.ipa

However, after creating a custom shared scheme for that configuration, "myapp-QA", the build completes correctly:

xcodebuild -workspace $WORKSPACE.xcworkspace \
    -scheme $SCHEME-QA \
    clean archive -archivePath archives/$APP_NAME-QA

xcodebuild -exportArchive \
    -archivePath archives/$APP_NAME-QA.xcarchive \
    -exportPath . \
    -exportOptionsPlist $WORKSPACE/ExportOptions.plist

mv $APP_NAME-QA.ipa $APP_NAME.$VERSION.$BUILD_NUMBER.qa.ipa

There is an issue with using configuration & scheme arguments. A scheme has its own configuration and most probably it overrides configuration specified via xcodebuild -configuration.

You can solve it by using configuration & target:

xcodebuild -project <project>.xcodeproj \
           -configuration <configuration> \
           -target <target> \
           -sdk iphonesimulator \
           clean build
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top