parameter for xcodebuild for using latest sdk. - xcode

I using ant exec task to execute xcodebuild to build some iOS projects hudson. I would like to be able to crate script that way that allows not to specify sdk version, because after updating sdk on hudson slave or my iOS projects all my projects failing....
There is is nice option in xcode since sdk 4.2 in target setup Base SDK - Latest iOS
and I don't have to provide -sdk param in xcodebuild command, but then (i think) it's taken from xcode project and it's bad because then some one can change target from simulator to device accidentally during commit.
I need something that is constant. I will prefer not to use env variable because I would like to be able to run this ant task also on dev machines and would like not have to renember about setting it on all machines.
Unfortunately xcodebuild -showsdks gives only:
Mac OS X SDKs:
Mac OS X 10.4 -sdk macosx10.4
Mac OS X 10.5 -sdk macosx10.5
Mac OS X 10.6 -sdk macosx10.6
iOS SDKs:
iOS 4.2 -sdk iphoneos4.2
iOS Simulator SDKs:
Simulator - iOS 3.2 -sdk iphonesimulator3.2
Simulator - iOS 4.0 -sdk iphonesimulator4.0
Simulator - iOS 4.1 -sdk iphonesimulator4.1
Simulator - iOS 4.2 -sdk iphonesimulator4.2
I need something like -sdk iphoneosLatest. My only idea is to pare output of xcodebuild -showsdks with some script, but I don't like this idea.

You can use xcodebuild with the latest SDK using :
xcodebuild -sdk iphoneos, for Device
xcodebuild -sdk iphonesimulator, for Simulator.
We use these options for our automated builds and it's been working since XCode 3.2.5

I believe you can use xcodebuild -sdk iphoneos (no version number) to accomplish this.

I tried #jenningj 's solution and it worked for me. Maciek Sawicki, if this works for you, you should mark it as the right solution.
Also, xcodebuild -showsdk should be xcodebuild -showsdks.

You can try: xcodebuild -showsdks | grep -Eo "iphoneos([0-9]{1,}\.)+[0-9]{1,}"

Related

Ionic Cordova - xcodebuild: error: Unable to find a destination matching the provided destination specifier:

I am getting the above error after updating my deployment target (as the store now demands this min version)
<preference name="deployment-target" value="14.0" />
It is the same error as in this post, however I already have target-device set to universal, and also I don't get any Available destinations
Ionic Info is
Ionic:
Ionic CLI : 5.2.7 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.11.13
#angular-devkit/build-angular : 0.802.2
#angular-devkit/schematics : 8.3.29
#angular/cli : 8.2.2
#ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 14 other plugins)
Utility:
cordova-res : 0.14.0 (update available: 0.15.3)
native-run : not installed
System:
Android SDK Tools : 26.1.1 (/Users/Development/.android-sdk-macosx/)
ios-deploy : 1.9.4
ios-sim : 8.0.2
NodeJS : v12.18.0 (/usr/local/bin/node)
npm : 7.11.2
OS : macOS Catalina
Xcode : Xcode 11.4 Build version 11E146
My build.json is
The full error output is
cordova build ios --release --buildConfig platform_build_files/ios/build.json
Reading build config file: /Users/Development/dev/myProductSuite/myApp/platform_build_files/ios/build.json
No simulator found for ". Falling back to the default target.
Building for "iPhone 11 Pro Max" Simulator (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max, iPhone-11-Pro-Max).
Building project: /Users/Development/dev/myProductSuite/myApp/platforms/ios/MyApp.xcworkspace
Configuration: Release
Platform: emulator
Target: iPhone 11 Pro Max
Adding xcodebuildArg: EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
Adding xcodebuildArg: ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO
Adding xcodebuildArg: LD_RUNPATH_SEARCH_PATHS = "#executable_path/Frameworks"
Running command: xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone 11 Pro Max build CONFIGURATION_BUILD_DIR=/Users/Development/dev/myProductSuite/myApp/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/Development/dev/myProductSuite/myApp/platforms/ios/build/sharedpch EMBEDDED_CONTENT_CONTAINS_SWIFT = YES ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO LD_RUNPATH_SEARCH_PATHS = "#executable_path/Frameworks"
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace "MyApp.xcworkspace" -scheme "MyApp" -configuration Release -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 11 Pro Max" build CONFIGURATION_BUILD_DIR=/Users/Development/dev/myProductSuite/myApp/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/Development/dev/myProductSuite/myApp/platforms/ios/build/sharedpch "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES" ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO "LD_RUNPATH_SEARCH_PATHS = \"#executable_path/Frameworks\""
Build settings from command line:
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
CONFIGURATION_BUILD_DIR = /Users/Development/dev/myProductSuite/myApp/platforms/ios/build/emulator
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
LD_RUNPATH_SEARCH_PATHS = "#executable_path/Frameworks"
SDKROOT = iphonesimulator13.4
SHARED_PRECOMPS_DIR = /Users/Development/dev/myProductSuite/myApp/platforms/ios/build/sharedpch
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:latest, name:iPhone 11 Pro Max }
Ineligible destinations for the "MyApp" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
xcodebuild: Command failed with exit code 70
[ERROR] An error occurred while running subprocess cordova.
I have put my project into a fresh folder, so the xcode project is regenerated, but no luck.
Where is it picking to this destination list, and how can I solve this?
Your virtual machine's Xcode version is 11.4. This only supports iOS 13.4 as seen here: https://developer.apple.com/documentation/xcode-release-notes/xcode-11_4-release-notes
So your deployment target of iOS 14.0 is higher than your simulators' OS versions of iOS 13.4, which is why they aren't showing up. I'm unfamiliar with Ionic Cordova, but you need to find a way to use Xcode 12 or later in your VM.
I had a similar issue to this. I'm sure that what caused it was my removal of all of my simulators. The fix I came across was in xcrun simctl
run xcrun simctl list --json to view all of the know devices
run xcrun simctl delete unavailable (or xcrun simctl delete all if you want to get rid of everything.
Now, You could maybe to this through the Devices & Simulators menu, but I wanted to stick with xcrun to create a new simulated device. By typing the command xcrun simctl create you will get usage. I used the commmand:
xcrun simctl create iPhone\ 12 "iPhone 12"

Xcode build succeeds however it does not downloads app on the simulator

Xcode build succeeds however it does not download app on the simulator through terminal.
I am using the below command in mac terminal to build my code, however, the build succeeds but the app does not get downloaded to my ios simulator as it does using the xcode application
xcrun xcodebuild -workspace MyApp.xcworkspace -scheme "Test App" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.2'
How can i successfully pull my code from Github and then successfully deploy on ios simulator with few lines?
After you build your content, run xcrun simctl install <UDID> <PATH> to install the app in the sim. Be sure you have booted it first as well ( which you can also use simctl for).

Jenkins&Xcode : Build crashes in ipad frequently

I'm currently generating an ios app with distribution profile. When I generate an ipa file from Xcode it works fine without any crashes when installed on an ipad but it crashes in most fields when generated from jenkins as a part CI process. Till now its working fine but the issue started while adding developed frameworks to the project. In jenkins I'm using below command line script for xcodebuild.
. xcodebuild -workspace ~/.jenkins/jobs/workspace/repo/Source/App/App.xcodeproj/project.xcworkspace -scheme App -configuration "release" -sdk iphoneos VALID_ARCHS="armv64 armv7 armv7s i386" archive PROVISIONING_PROFILE="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" CODE_SIGN_IDENTITY="iPhone Distribution: company Limited" -archivePath ~/Desktop/../App.xcarchive
Unable to find out the exact issue for the crash.
I suggest you to check the environment variable of your jenkins node.. if they are overriding your build variables.
Before this can you provide more details.

Xcodebuild showSDKs shows different available iOS sims than Xcode 6.3 GUI

OSX 10.10.1
Xcode 6.3 or 6.3.1
xcodebuild version "Xcode 6.3.1"
This happened on one machine and I thought it was a fluke. Has now happened on two machines. I have followed the advice in
Why aren't simulators showing in the Xcode 6.3.1 scheme selector?
to no avail. Here is what I see on the command line:
xcodebuild -showsdks
iOS Simulator SDKs:
Simulator - iOS 8.3 -sdk iphonesimulator8.3
in "xcode GUI -> prefs -> Downloads"
iOS 8.2 Sim (checkmark)
iOS 8.1 Sim (checkmark)
iOS 7.1 Sim (checkmark)
in the ios sim application (opened from Xcode -> Open dev tool -> ios sim)
in the "hardware -> device" dropdown menu i see
iOS 7.1 > (lots of choices)
iOS 8.1 > (lots of choices)
iOS 8.2 > (lots of choices)
iOS 8.3 > (lots of choices)
So the Xcode GUI generally agrees with itself, but I need to build for and kick off all of these iOS sims programmatically from the command line, but xcodebuild doesn't see all of the available simulators.
Ignore what xcodebuild -showsdks tells you. You are confusing SDKs with destinations. A simulator is a destination.
The way to know what simulators you've got is with xcrun simctl list.
The way to tell xcodebuild what destination to build for is with the -destination option. You can construct and specify any simulator with which your project's deployment setting is compatible.

Run installed application on iPad (device) from Mac Terminal

I build the application for iPad (from a Terminal) using:
xcodebuild ARCHS=armv7 ONLY_ACTIVE_ARCH=NO VALID_ARCHS=armv7 -scheme MyApp -sdk iphoneos build
Then I deploy it to my iPad using fruitstrap:
./fruitstrap -b Mobile/DerivedData/MyApp/Build/Products/Debug-iphoneos/MyApp.app/
At the next step I have a problem: I need to run the installed application from a Terminal to be able to run the nightly-iterations on Hudson CI.
Any ideas on how to do it?

Resources