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
Related
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.
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?
You can run the Swift REPL with a couple of different options for the --sdk option. You can run:
xcrun swift -v -sdk $(xcrun --show-sdk-path --sdk iphonesimulator)
or
xcrun swift -v -sdk $(xcrun --show-sdk-path --sdk macosx)
There is also
xcrun swift -v -sdk $(xcrun --show-sdk-path --sdk iphoneos)
Which doesn't seem to work very well and causes lots of errors.
How will my output differ when using the iphonesimulator sdk vs the macosx sdk?
The desktop, device emulator and device hardware are different build targets:
SDK Target
macosx OSX Desktop
iphonesimulator iOS Simulator
iphoneos iOS Hardware
Currently, xcodebuild supports these platforms:
OS X The local Mac, referred to in the Xcode interface as My Mac, and which supports the fol-lowing following
lowing keys:
arch The architecture to use, either x86_64 (the default) or i386.
iOS An iOS device, which supports the following keys:
name The name of the device to use.
id The identifier of the device to use, as shown in the Devices tab of the Xcode
Organizer.
iOS Simulator The iOS Simulator, which supports the following keys:
name The full name of device to simulate, as presented in Xcode's UI.
OS The version of iOS to simulate, such as 6._, or the string latest (the default) to
indicate the most recent version of iOS supported by this version of Xcode.
This is abstracted in the IDE:
For iOS, Xcode automatically switches between the iOS Simulator SDK and the device SDK, depending on where you intend to run your app. You don’t need to select these settings manually.
References
Xcodebuild Command Line FAQ
Mac OSX Glossary
XCode Release Notes Archive
Configuring a Project for SDK-Based Development
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?
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.