cristallo
cristallo

Reputation: 2089

Azure devops pipeline for building an ios bundle with iphone app and watchos app

I'd like to use an Azure devops pipeline for building ios bundle that contains both an iphone app and a watchos app.

There is a workspace that contains the 3 apps (one for the phone and two for the watch)

MyWorkspace:

I use the following XCode task

- task: Xcode@5
  inputs:
    actions: 'build'
    scheme: 'MyApp'
    sdk: 'iphoneos'  
    configuration: 'Release'
    xcWorkspacePath: '$(system.defaultworkingdirectory)/MyWorkspace.xcworkspace'
    xcodeVersion: '12'

This task launches xcodebuild

xcodebuild -sdk iphoneos -configuration Release -workspace /Users/runner/work/1/s/MyApp/MyWorkspace.xcworkspace -scheme MyApp build

and it fails with the following errors:

error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphoneos' (in target 'MyWatchApp' from project 'MyApp')

error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphoneos' (in target 'MyWatchApp Extension' from project 'MyApp')

What kind of SDK do I need to specify to build it?

Upvotes: 1

Views: 1934

Answers (2)

Avinash Jadhav
Avinash Jadhav

Reputation: 501

To generate Ad-Hoc build on DevOps, create following tasks

  1. Copy source code to agent machine
  2. Set environment variable if any
  3. Install npm tool and then create terminal task for npm install npm install -g react-native-cli npm i @react-native-community/[email protected]
  4. Create devOps Apple certificate installation tasks to install Apple developer certificate Provisioning profiles Signing certificate development/ distribution certificates
  5. Create terminal task for xcodebuild clean -workspace Project.xcworkspace -scheme ProjectScheme
    xcodebuild build -workspace Project.xcworkspace -scheme ProjectScheme -destination generic/platform=iOS -destination "platform=iOS Simulator,name=iPhone 13 Pro Max" -allowProvisioningUpdates
    xcodebuild archive -workspace Project.xcworkspace -scheme Project -archivePath D:/path_to_save_build/terminalBuild.xcarchive
    xcodebuild -exportArchive -archivePath D:/path_to_save_build/terminalBuild.xcarchive -exportPath ../../iOSbuilds -exportOptionsPlist ExportOptionAdhocSigning.plist
  6. Copy this .ipa file to your artifacts location.

Upvotes: 0

cristallo
cristallo

Reputation: 2089

The command that I'd like to run using azure pipeline xcode task is the following:

xcodebuild -configuration Release -workspace /Users/runner/work/1/s/MyApp/MyWorkspace.xcworkspace -scheme MyApp build

Without the sdk specification

-sdk iphoneos

In this way the build of each component will follow the project default and the phone app will be built using iphoneos SDK and watch app will be built using watchos SDK.

Unfortunately if I remove the sdk specification from the xcode task

- task: Xcode@5
  inputs:
    actions: 'build'
    scheme: 'MyApp'
    configuration: 'Release'
    xcWorkspacePath: '$(system.defaultworkingdirectory)/MyWorkspace.xcworkspace'
    xcodeVersion: '12'

then it uses its own default

-sdk $(SDK)

and it causes an error because the $(SDK) is not defined.

The right (but pretty odd) syntax for this use case is

- task: Xcode@5
  inputs:
    actions: 'build'
    scheme: 'MyApp'
    sdk:   
    configuration: 'Release'
    xcWorkspacePath: '$(system.defaultworkingdirectory)/MyWorkspace.xcworkspace'
    xcodeVersion: '12'

leaving the sdk specification empty without any value.

Upvotes: 1

Related Questions