How to use xcodebuild in Xcode 7 with chat extension

Our team used to be like this

xcodebuild -configuration Release -target "xxx" -sdk iphoneos9.0 -scheme "xxx" archive 

Now in Xcode 7 we get this error:

 Build settings from command line: SDKROOT = iphoneos9.0 === BUILD TARGET xxx WatchKit Extension OF PROJECT Mobile WITH CONFIGURATION Release === Check dependencies target specifies product type 'com.apple.product-type.watchkit2-extension', but there no such product type for the 'iphoneos' platform 

How do we determine the use of the iOS 9.0 SDK and watchos 2.0 SDK?

+5
source share
2 answers

If you need to build a simulator, follow these steps:

 xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target -destination 'name=iPhone 6' build 

And if you need to create a device assembly, follow these steps:

 xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target build 

The trick is that for any build you need to remove the -sdk option. To build the simulator you need to specify -destination , which should be iPhone 6 or iPhone 6 Plus . And for devices it builds to skip -destination .

+20
source

There are several reasons why you see this error, but it comes down to dependencies. If you select the scheme that creates the iOS target, then you have no problem using the following command. Please note that I used iphoneos to automatically select the latest SDK.

 xcodebuild -configuration Release -target "ios" -sdk iphoneos -scheme "ios" build 

The problem you're working with is starting up due to the watchOS extension dependency. I created a sample project and added a watchOS application. On the Build Phases tab, you see in the Dependencies section that the iOS target has a dependency on the WatchOS target.

enter image description here

This is not a problem if you specify destination in your build command. But this creates a problem if you tell xcodebuild what needs to be created using a specific SDK. What for? Since the goal of WatchOS cannot be built using the iOS SDK. If you specify iphoneos as the SDK, the assembly will fail.

Specifying the addressee solves the problem, but be aware that you are using a specific simulator. If you use the same command on another computer and this simulator is not available, the assembly will fail.

Honestly, I don’t know if there is a middle way that allows you to choose the latest SDK and still use the correct SDK for each goal, regardless of dependencies. If you remove the iOS target dependency, the build command above should not be interrupted. You may also need to update the scheme you are using.

0
source

All Articles