How to used Xcode task in Azure Pipelines? - ios

I have a Xamarin CI process set up in Azure Pipelines.
Due to my recent changes, I need to use iOS 13.0 to compile my code.
In my azure-pipelines.yml I have the following code:
- task: Xcode#5
inputs:
sdk: "iphoneos13.1"
xcodeVersion: "/Applications/Xcode_11.1.app"
actions: 'build'
Sidenote: I am using poolvmImage: 'macos-latest'
I took the Xcode task from this documentation.
On GitHub it looks like ALL Mac machines have iOS 13 SDK installed.
...but when I run
- task: CmdLine#2
inputs:
script: 'xcodebuild -showsdks'
from my yml file it is displaying the following output:
Script contents:
xcodebuild -showsdks
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /Users/vsts/agent/2.158.0/work/_temp/11b07ed3-faf4-4917-a9ea-3c1dc52aa96f.sh
iOS SDKs:
iOS 12.4 -sdk iphoneos12.4
iOS Simulator SDKs:
Simulator - iOS 12.4 -sdk iphonesimulator12.4
macOS SDKs:
macOS 10.14 -sdk macosx10.14
tvOS SDKs:
tvOS 12.4 -sdk appletvos12.4
tvOS Simulator SDKs:
Simulator - tvOS 12.4 -sdk appletvsimulator12.4
watchOS SDKs:
watchOS 5.3 -sdk watchos5.3
watchOS Simulator SDKs:
Simulator - watchOS 5.3 -sdk watchsimulator5.3
The question is:
how to force Azure Pipelines to use iOS 13 and Xcode 11 to build my app?

The issue you are facing should be due to our image deployment delays. For my region(East US 2),if I execute the command
xcodebuild -showsdks
xcodebuild -version
And below is the iOS and Xcode info about the Hosted macOS 10.14 on my region.
According to the info you shared, seems the hosted agent used by the region where your org is located have not been deployed with these latest upgrade. So, even with command to pick up iOS 13 or other SDK still could not succeed because of none SDK exists.
Most time, the deployment process would has some delay because of different regions. Please pay some times to waiting for the deployment job finished. It will be fully deployed to all regions in the latest two weeks.
If you are hurry for building and deploy your app with these SDKs, here has a temporary work around can for you use: install the private macOS pre-release agent by reference to this link:
Pre-release agent 2.159.1.

Related

xcodebuild showsdks after installing xcode 9 beta in macos high sierra shows iOS 10.3 SDK

I would like to use iOS 11 SDK to build my app from command line. I have updated my macbook to mac os high sierra 10.13 and downloaded the xcode 9 beta. Also, I installed all the command-line tools and do not have any other versions of xcode installed.
When i type xcodebuild -showsdks i get
iOS SDKs:
iOS 10.3 -sdk iphoneos10.3
iOS Simulator SDKs:
Simulator - iOS 10.3 -sdk iphonesimulator10.3
macOS SDKs:
macOS 10.12 -sdk macosx10.12
tvOS SDKs:
tvOS 10.2 -sdk appletvos10.2
tvOS Simulator SDKs:
Simulator - tvOS 10.2 -sdk appletvsimulator10.2
watchOS SDKs:
watchOS 3.2 -sdk watchos3.2
watchOS Simulator SDKs:
Simulator - watchOS 3.2 -sdk watchsimulator3.2
I would like to use iOS 11 SDK instead of 10.3 to build from command line.
I was able to get iOS 11.0 SDK shown from "xcodebuild -showsdks" after I removed the xcode app from applications and re-installing it again.

How to install iOS simulators from command line

It's a common case to run tests against different versions of iOS simulators/SDKs on CI. However, only the latest iOS simulator is installed by Xcode on default.
So I need install other missing iOS simulators from command line in CI environment. But I cannot find a way to install those simulators from command line.
It can be done with xcode-install, with the following commands
gem install xcode-install
xcversion simulators --install='iOS 9.3'
xcrun simctl create <name> <device type> <runtime>
For example:
xcrun simctl create "ry" "iPhone 11 Pro Max" iOS13.3
xcrun simctl is command utils to control iOS simulator, just like adb for Android. You can also run xcrun simctl help, there are a bundle of useful subcommands. When successful, most of these commands exit with 0; when failed, most exit with a non-zero number.
Personally, I have an article about how to use simulator from terminal.
FYI
All simulators are packed with Xcode app. Instead of installing simulators you can just install the specific Xcode versions.
Xcode7.0 has iOS9 Simulators
Xcode6.4 has iOS8.x Simulators
In your CI testing if you want to test you app for a specific simulator just select xcode version before you do the xcodebuild command
xcode-select -switch <path to your xcode app>
This will set your default xcode to run the xcodebuild
Then run the xcodebuild with your respective simulator.
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
In the place of SIMULATOR_OR_IOS_SDK give your simulator value.
You can find the simulator value by running
xcodebuild -showsdks
This will show like
OS X SDKs:
OS X 10.11 -sdk macosx10.11
iOS SDKs:
iOS 9.1 -sdk iphoneos9.1
iOS Simulator SDKs:
Simulator - iOS 9.1 -sdk iphonesimulator9.1
tvOS SDKs:
tvOS 9.0 -sdk appletvos9.0
tvOS Simulator SDKs:
Simulator - tvOS 9.0 -sdk appletvsimulator9.0
watchOS SDKs:
watchOS 2.0 -sdk watchos2.0
watchOS Simulator SDKs:
Simulator - watchOS 2.0 -sdk watchsimulator2.0
This way you can build your project on any specific device/simulator/os.
Hope this helps :)
For iOS 8.1 Simulator:
http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1434581536.dmg
For iOS 8.2 Simulator:
http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_2-8.2.1.1434581536.dmg
For iOS 8.3 Simulator:
http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_3-8.3.1.1434581536.dmg
For iOS 8.4 Simulator:
http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_4-8.4.1.1435785476.dmg
I don't know where these URLs come from, but I found some clues
https://gist.github.com/masbog/bf6e2d6fce80447396eb

Installing and finding older versions of the iOS SDK

I'm trying to build for iOS 7 from the command line using a makefile, but I have already installed 8.4 SDK. I followed the standard procedure to install it using Xcode and it seems to be installed, as shown in the screen shot below.
However, when trying to find the SDK with xcodebuild I doesn't show. Here's my output:
$ xcodebuild -showsdks
2015-09-09 14:59:33.587 xcodebuild[85926:12435307] [MT] PluginLoading: Required plug-in compatibility UUID 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/VVDocumenter-Xcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs
OS X SDKs:
OS X 10.9 -sdk macosx10.9
OS X 10.10 -sdk macosx10.10
iOS SDKs:
iOS 8.4 -sdk iphoneos8.4
iOS Simulator SDKs:
Simulator - iOS 8.4 -sdk iphonesimulator8.4
What do I need to do?

How to run iOS simulator 4.3 in Xcode 4.6?

I'm trying to test my iOS application on iOS 4.x.
I'm using MAC OS X Mountain Lion(10.8.2) and Xcode 4.6.
I tried to install the older iOS 4 version from the Downloads tab inside the Xcode but that simulator option is not available: http://cl.ly/image/412l3V3C1E3W
I then manually installed the the iOS 4.0 and 4.3 sdk using the packages from the "xcode_4.0.2_and_ios_sdk_4.3.dmg" file and now they are available inside the folder: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs".
My deployment target is set to 4.0 and I'm able to select the iOS simulator from the scheme.
I even checked if the iOS 4.x SDK is correctly installed using the command line "xcodebuild -showsdks" and the system recognizes it:
$ xcodebuild -showsdks
OS X SDKs:
Mac OS X 10.7 -sdk macosx10.7
OS X 10.8 -sdk macosx10.8
iOS SDKs:
iOS 4.3 -sdk iphoneos4.3
iOS 6.1 -sdk iphoneos6.1
iOS Simulator SDKs:
Simulator - iOS 4.0 -sdk iphonesimulator4.0
Simulator - iOS 4.3 -sdk iphonesimulator4.3
Simulator - iOS 5.0 -sdk iphonesimulator5.0
Simulator - iOS 5.1 -sdk iphonesimulator5.1
Simulator - iOS 6.1 -sdk iphonesimulator6.1
The problem I'm facing is that when I run the project I get and error from the simulator: "iOS Simulator could not find the SDK. The SDK may need to be reinstalled."
And if I try to change the version from the simulator there is no 4.3 option:
http://cl.ly/image/1y04201e2o08
Does anyone know how to force the simulator to start with iOS 4.3?

xcodebuild, missing iOS simulator sdk

I'm automating the building process for an iOS project. Everything was fine... but now I have to support iOS 4, what I have installed is the iOS simulator 4.3 (Xcode : Preferences > Downloads > Components).
Inside xcode I have these options:
iOS device
iPad simulator 5.0
iPad simulator 5.1
iPhone simulator 5.0
iPhone simulator 5.1
There is no 4.3
From command line
$ xcodebuild -showsdks
Mac OS X SDKs:
Mac OS X 10.6 -sdk macosx10.6
Mac OS X 10.7 -sdk macosx10.7
iOS SDKs:
iOS 5.0 -sdk iphoneos5.0
iOS Simulator SDKs:
Simulator - iOS 5.0 -sdk iphonesimulator5.0
There is no 4.3
Questions:
Where is the 4.3 simulator installed?
What sdk value should a pass to xcodebuild for the 4.3 simulator?
Thanks guys.
The simulator SDK's are located at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
You can use the following xcodebuild (/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild) command:
xcodebuild -target $target -sdk $sdk -configuration $configuration
where $target is the target name specified in the project, $sdk could be taken from the output of the command you used to see the available SDK's (iphoneos5.0, iphonesimulator5.0) and $configuration could be AdHoc, AppStore or whatever else you have setup in the project.
For the missing SDK issue you could check the item status at Xcode : Preferences > Downloads > Components to be Installed and check the folder iPhoneSimulator4.3.sdk exists at the SDK's location. If it does but still not displayed as installed, you could consider removing and reinstalling it or reinstall the Xcode completely.
If you have iOS Lion.
Follow the following steps
Go to Applications
(Right click on Xcode Icon)
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/ Developer/Applications/iPhone Simulator.app
There you will find the iOS Simulator App.

Resources