Unable to find a destination matching the provided destination specifier - ios

Currently, I am struggling with the following issue and it's kind of big blocker for our project.
We need to run ui tests for apple watch test target in the iOS App with Watch App using terminal and we receive such error, which is quite frustrating
Command I use:
xcodebuild test -workspace WatchTesterApp.xcworkspace -scheme 'Watch' -destination 'id=F35DCC98-0F7D-460E-A49F-A446FD5FB4BE'
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:F35DCC98-0F7D-460E-A49F-A446FD5FB4BE }
The requested device could not be found because no available devices matched the request.
Available destinations for the "Watch" scheme:
{ platform:iOS Simulator, id:F35DCC98-0F7D-460E-A49F-A446FD5FB4BE, OS:14.5, name:iPhone 12 Pro }
Ineligible destinations for the "Watch" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }
Destination is iPhone's simulator id which is paired with apple watch
Has anyone faced such issue?

So, after a long investigation and a long list of possible fixes that resolved nothing, I updated Xcode and tried to run the same command, which didn't work either and only after creating new clean project using new Xcode it finally worked.
I used:
xcodebuild test -workspace WatchTesterAppExample.xcworkspace -scheme 'WatchTesterAppExample WatchKit App' -destination 'platform=WatchOS Simulator,name=Apple Watch Series 7 - 45mm' &
xcodebuild test -workspace WatchTesterAppExample.xcworkspace -scheme 'WatchTesterAppExample' -destination 'platform=iOS Simulator,name=iPhone 13'
It worked for me on the simulators, didn't try it on real device yet
Interesting fact: I am still able to see this error in some case, especially when I don't specify platform in the 'destination'

Related

How to use Fastlane with a CMake generated XCode project with dependency on WebP?

I have a project written in C++ where CMake is used to generate the build system for various platforms including iOS. The project has a dependency on WebP. You can find an example project on GitHub here that can be used to reproduce things & I've included the relevant source files at the end of this post for completeness.
The Xcode build system for iOS is generated using CMake as follows:
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=third_party/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=15.0 -DENABLE_BITCODE=0 -S . -B cmake-build-release
We can now attempt to build/archive the app using Fastlane with the command from within the generated cmake-build-release directory:
bundle exec fastlane ios beta
However this fails due to being unable to locate various webp object files (that based on console output it appears to have previously successfully compiled):
...
▸ Compiling buffer_dec.c
▸ Compiling alpha_dec.c
▸ Building library libwebpdsp.a
...
** ARCHIVE FAILED **
▸ The following build commands failed:
▸ Libtool /Users/dbotha/Library/Developer/Xcode/DerivedData/CMakeFastlaneWebpTest-dlwvukebfiwjqvaqiepshuxqklhh/ArchiveIntermediates/CMakeFastlaneWebpTest/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libwebpdecoder.a normal (in target 'webpdecoder' from project 'CMakeFastlaneWebpTest')
▸ (1 failure)
▸ ❌ error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/dbotha/CLionProjects/CMakeFastlaneWebpTest/cmake-build-release/third_party/libwebp/CMakeFastlaneWebpTest.build/Release-iphoneos/webpdecode.build/Objects-normal/arm64/alpha_dec.o (No such file or directory)
▸ ❌ error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/dbotha/CLionProjects/CMakeFastlaneWebpTest/cmake-build-release/third_party/libwebp/CMakeFastlaneWebpTest.build/Release-iphoneos/webpdecode.build/Objects-normal/arm64/buffer_dec.o (No such file or directory)
...
Internally Fastlane attempted to build/archive the project with the following command:
xcodebuild -scheme CMakeFastlaneWebpTest -project ./CMakeFastlaneWebpTest.xcodeproj -configuration Release -destination 'generic/platform=iOS' -archivePath ./out.xcarchive archive
Interestingly an archive can be successfully generated if I use the following xcodebuild command (note how -target flag is used instead of -scheme):
xcodebuild -project CMakeFastlaneWebpTest.xcodeproj archive -target CMakeFastlaneWebpTest -configuration Release
After this successful attempt bundle exec fastlane ios beta will now also succeed as the compiled object files are where it expected them to be.
Now I'd happily workaround this issue using my xcodebuild + -target flag approach and then use the fastlane command to push to Testflight, etc. but the real project (not this toy example) takes a very long time to build so building it twice is really wasteful from a cost point of view on CI platforms.
Does anyone have any idea what's going on here & how I can successfully build things in the first instance using fastlane without my own explicit call to xcodebuild first? Or alternatively how can I have Fastlane use the successfully built objects from my workaround so it doesn't need to rebuild the entire project from scratch?
CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(CMakeFastlaneWebpTest)
set(CMAKE_CXX_STANDARD 14)
add_executable(CMakeFastlaneWebpTest src/main.cpp)
# Skip building of unused webp tools which fail for me under ios:
set(WEBP_BUILD_ANIM_UTILS OFF)
set(WEBP_BUILD_CWEBP OFF)
set(WEBP_BUILD_DWEBP OFF)
set(WEBP_BUILD_GIF2WEBP OFF)
set(WEBP_BUILD_IMG2WEBP OFF)
set(WEBP_BUILD_VWEBP OFF)
set(WEBP_BUILD_WEBPINFO OFF)
set(WEBP_BUILD_WEBPMUX OFF)
set(WEBP_BUILD_EXTRAS OFF)
set(WEBP_BUILD_WEBP_JS OFF)
add_subdirectory(third_party/libwebp EXCLUDE_FROM_ALL)
target_link_libraries(CMakeFastlaneWebpTest PRIVATE webpdecoder webpdemux)
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/libwebp/src)
configure_file(${CMAKE_SOURCE_DIR}/fastlane/Appfile ${CMAKE_BINARY_DIR}/fastlane/Appfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/fastlane/Fastfile ${CMAKE_BINARY_DIR}/fastlane/Fastfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Gemfile ${CMAKE_BINARY_DIR}/Gemfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Gemfile.lock ${CMAKE_BINARY_DIR}/Gemfile.lock COPYONLY)
set_target_properties(CMakeFastlaneWebpTest PROPERTIES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/iOS-Info.plist.in
MACOSX_BUNDLE_GUI_IDENTIFIER com.dbotha.CMakeFastlaneWebpTest
MACOSX_BUNDLE_BUNDLE_NAME CMakeFastlaneWebpTest
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
)
set_xcode_property(CMakeFastlaneWebpTest PRODUCT_BUNDLE_IDENTIFIER "com.dbotha.CMakeFastlaneWebpTest" All)
set_xcode_property(CMakeFastlaneWebpTest CODE_SIGN_IDENTITY "iPhone Developer" All)
set_xcode_property(CMakeFastlaneWebpTest DEVELOPMENT_TEAM "GFP63373B2" All)
fastlane/Appfile
app_identifier("com.dbotha.CMakeFastlaneWebpTest") # The bundle identifier of your app
apple_id("REPLACE_ME") # Your Apple Developer Portal username
itc_team_id("REPLACE_ME") # App Store Connect Team ID
team_id("REPLACE_ME") # Developer Portal Team ID
fastlane/Fastfile
default_platform(:ios)
platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
build_app(scheme: "CMakeFastlaneWebpTest", configuration: "Release")
upload_to_testflight
end
end
src/main.cpp
#include <iostream>
#include <webp/demux.h>
int main() {
WebPAnimDecoderOptions decOptions;
(void)decOptions;
std::cout << "Hello, World!" << std::endl;
return 0;
}
I'm not an expert in this topic but according to the documentation you should provide workspace to build your scheme.
To build an Xcode workspace, you must pass both the -workspace and
-scheme options to define the build. The parameters of the scheme will
control which targets are built and how they are built, although you may
pass other options to xcodebuild to override some parameters of the
scheme.
Scheme controls what target will be build, and guessing by your example, since you do not provide a workspace, it gets lost in the process.
The scheme is not lost anymore if you build the target manually. Since it is already build the scheme does not have to do a thing.
My proposals:
Option 1: Try adding workspace to build_app parameters in Fastfile.
Option 2: Don't bother with building scheme just use target in the
build_app parameters in Fastfile like so: build_app(target: "CMakeFastlaneWebpTest", configuration: "Release")

Multiple Xcode workspace matches were found. The first match will be used in Flutter

I'm trying to integrate the Azure CI CD pipeline for Fluter application. I'm getting below mentioned errors in my Azure CI iOS integration and unable to generate signed builds.
Azure Pipeline YML code sign
- task: Xcode#5
displayName: "Code sign ipa for Distribution"
inputs:
actions: "build"
xcWorkspacePath: "**/Runner.xcworkspace"
scheme: "Runner"
sdk: "iphoneos"
configuration: "release"
packageApp: true
signingOption: "manual"
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
Error :
2022-04-13T08:36:40.5885050Z ##[section]Starting: Code sign ipa for Distribution
2022-04-13T08:36:40.5898160Z ==============================================================================
2022-04-13T08:36:40.5898480Z Task : Xcode
2022-04-13T08:36:40.5898860Z Description : Build, test, or archive an Xcode workspace on macOS. Optionally package an app.
2022-04-13T08:36:40.5899750Z Version : 5.200.0
2022-04-13T08:36:40.5899960Z Author : Microsoft Corporation
2022-04-13T08:36:40.5900350Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/xcode
2022-04-13T08:36:40.5900750Z ==============================================================================
2022-04-13T08:36:40.9267540Z ##[warning]Multiple Xcode workspace matches were found. The first match will be used: /Users/runner/work/1/s/makeawish_mobile/ios/Runner.xcworkspace
2022-04-13T08:36:40.9291950Z [command]/usr/bin/xcodebuild -version
2022-04-13T08:36:42.7698550Z Xcode 13.2.1
2022-04-13T08:36:42.7901000Z Build version 13C100
2022-04-13T08:36:43.0275140Z [command]/usr/bin/xcodebuild -sdk iphoneos -configuration release -workspace /Users/runner/work/1/s/makeawish_mobile/ios/Runner.xcworkspace -scheme Runner build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=iPhone Distribution: XXXXXXXXX Ltd PROVISIONING_PROFILE=1319a551-3a8d-XXXXXXXXX PROVISIONING_PROFILE_SPECIFIER= | /usr/local/lib/ruby/gems/2.7.0/bin/xcpretty -r junit --no-color
2022-04-13T08:36:49.1496410Z --- xcodebuild: WARNING: Using the first of multiple matching destinations:
2022-04-13T08:36:49.1601060Z { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
2022-04-13T08:36:49.1704150Z { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
2022-04-13T08:36:54.2881640Z ** BUILD FAILED **
2022-04-13T08:36:54.2884770Z
2022-04-13T08:36:54.3515950Z ##[error]Error: /usr/bin/xcodebuild failed with return code: 65
2022-04-13T08:36:54.4265010Z ##[section]Finishing: Code sign ipa for Distribution

Ionic Capacitor can no longer produce a buildable iOS project, CompileAssetCatalog error

Having intractable build issues with Ionic 6.5.0 / Capacitor 2.2.0
I made the app not long ago, but today it won't build. After much fruitless updating/cleaning/building I deleted the ios directory and re-added it.
ionic cap add ios
ionic cap sync
Updated, removed DerivedData, clean build, same error:
CompileAssetCatalog /Users/me/Library/Developer/Xcode/DerivedData/App-ayobzjywexbfvjdrynzhsnownnyr/Build/Products/Debug-iphoneos/App.app /Users/me/Projects//MyProject/ios/App/App/Assets.xcassets (in target 'App' from project 'App')
cd /Users/me/Projects//MyProject/ios/App
/Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/me/Library/Developer/Xcode/DerivedData/App-ayobzjywexbfvjdrynzhsnownnyr/Build/Intermediates.noindex/App.build/Debug-iphoneos/App.build/assetcatalog_dependencies --output-partial-info-plist /Users/me/Library/Developer/Xcode/DerivedData/App-ayobzjywexbfvjdrynzhsnownnyr/Build/Intermediates.noindex/App.build/Debug-iphoneos/App.build/assetcatalog_generated_info.plist --app-icon AppIcon --compress-pngs --enable-on-demand-resources YES --filter-for-device-model iPhone10,1 --filter-for-device-os-version 13.5.1 --sticker-pack-identifier-prefix com.prosc.itineris.sticker-pack. --development-region en --target-device iphone --target-device ipad --minimum-deployment-target 11.0 --platform iphoneos --product-type com.apple.product-type.application --compile /Users/me/Library/Developer/Xcode/DerivedData/App-ayobzjywexbfvjdrynzhsnownnyr/Build/Products/Debug-iphoneos/App.app /Users/me/Projects//MyProject/ios/App/App/Assets.xcassets
2020-06-15 15:40:01.929 ibtoold[73405:1839106] DEBUG: Added to environment: {
TMPDIR = "/var/folders/g8/hc3lzhqn75d1ms9dzt46s7nw0000gn/T/E2DC0A8E-13DD-4566-A0E9-59C812831E2A";
}
Command CompileAssetCatalog failed with a nonzero exit code
If I run this command from the terminal it appears to exit with a 255 status, no errors/warnings/notices.
I tried the recommended updates in XCode, but I'm seeing some errors in the Xcode prior to the failure:
/Users/me/Projects/MyProject/node_modules/#capacitor/ios/Capacitor/Capacitor/Plugins/Network/Reachability.swift:207:4: Unexpected version number in 'available' attribute for non-specific platform '*'
/Users/me/Projects/MyProject/node_modules/#capacitor/ios/Capacitor/Capacitor/Plugins/Permissions.swift:39:5: Switch covers known cases, but 'AVAuthorizationStatus' may have additional unknown values, possibly added in future versions
/Users/me/Projects/MyProject/node_modules/#capacitor/ios/Capacitor/Capacitor/CAPBridge.swift:375:29: Coercion of implicitly unwrappable value of type 'String?' to 'Any' does not unwrap optional
/Users/me/Projects/MyProject/node_modules/#capacitor/ios/Capacitor/Capacitor/CAPPlugin.m:6:17: Method definition for 'shouldOverrideLoad:' not found
I don't think these are causing the error, however. Any suggestions / insights?
The solution was to update XCode to 11.5 by installing a new build from the App Store. My version of XCode was not installed from the app store.
After updating the additional XCode tools, this updated actool from 11.2.1 to 11.5
This had nothing to do with Ionic/Capacitor, building a totally new native iOS app was exhibiting the same error.

How to specify Cordova build target in build.json

I'm having an error when I execute cordova build.
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:latest, name:iPhone 11 Pro Max }
Since my app only builds on iPad, I think I need to set a build target to an iPad, but I'm not sure how to do this.
Versions
XCode: Version 11.1 (11A1027)
Cordova: cordova#9.0.0
MacOS: 10.15 Catalina
My config.xml has these tags to specify iPad only:
<preference name="target-device" value="tablet" />
<preference name="deployment-target" value="10.3" />
The full error:
Reading build config file:
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/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/Sokketsu.xcworkspace
Configuration: Debug
Platform: emulator
Target: iPhone 11 Pro Max
Running command: xcodebuild -workspace Sokketsu.xcworkspace -scheme Sokketsu -configuration Debug -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone 11 Pro Max build CONFIGURATION_BUILD_DIR=/Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/sharedpch
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/emulator
SDKROOT = iphonesimulator13.1
SHARED_PRECOMPS_DIR = /Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/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 }
Available destinations for the "Sokketsu" scheme:
{ platform:iOS Simulator, id:B90FC025-F8EB-40B3-90C5-E9094C0FFD17, OS:13.1, name:iPad Air (3rd generation) }
{ platform:iOS Simulator, id:3131A6AD-3C4E-4CEA-8889-9C7E22EAF816, OS:13.1, name:iPad Pro (9.7-inch) }
{ platform:iOS Simulator, id:A8055BC4-F95C-43FA-8B28-7FACBD3D57B6, OS:13.1, name:iPad Pro (11-inch) }
{ platform:iOS Simulator, id:7FAD7B1C-70DD-407A-AC99-3ACAD2670726, OS:13.1, name:iPad Pro (12.9-inch) (3rd generation) }
Ineligible destinations for the "Sokketsu" 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
You need to set the target-device to universal and then change it back to tablet in Xcode when finished.
config.xml
<preference name="target-device" value="universal" />
PS: This issue started probably around cordova-ios version 5.0.1 when running cordova build ios command.
You can solve this issue by sending the device name as a buildFlag
If you are using cordova use below command
cordova build ios --buildFlag="-destination platform=iOS Simulator,name=iPad Pro (11-inch)"
For me, I was using this in an Ionic project.
ionic cordova build ios -- --buildFlag="-destination platform=iOS Simulator,name=iPad Pro (11-inch)"
You can choose any device name you want from the list Available destinations listed in your error
As you can see in terminal it says:
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:latest, name:iPhone 11 Pro Max }
You can follow below steps:
Go to Xcode
Under simulator target click 'Add Additional Simulators'
Once this screen pops up, click on + icon on bottom left corner
It will display a screen to add new simulator: Add the one for which your build is failing , in this case:iPhone 11 Pro Max, Select Device type as(iPhone 11 Pro Max) and latest OS version.
Go to terminal and try build command again.

Set CFBundleDisplayName app name for cordova app on iOS (using fastlane)

I have trouble setting the correct app name below the icon for a Cordova iOS app.
I use Cordova, Fastlane, match and gym to create the build.
To create a Cordova project I do:
cordova create cordova-dir cordova.app.id cordova-appName
In the generated Info.plist file it says:
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
gym command in Fastfile file is:
gym(
project: "./cordova-dir/platforms/ios/cordova-appName.xcodeproj",
scheme: "cordova-appName",
use_legacy_build_api: "true",
export_method: "enterprise",
codesigning_identity: "iPhone Distribution: My Company Limited"
)
The generated command is:
set -o pipefail && xcodebuild -scheme 'cordova-appName' -project './build-cordova/platforms/ios/cordova-appName.xcodeproj' -destination 'generic/platform=iOS' -archivePath '/private/var/user/Library/Developer/Xcode/Archives/2016-03-29/cordova-appName 2016-03-29 16.20.06.xcarchive' archive CODE_SIGN_IDENTITY='iPhone Distribution: My Company Limited' | tee /private/var/user/Library/Logs/gym/cordova-appName-cordova-appName.log | xcpretty
The ipa file is called cordova.app.id.ipa
The displayed name on the device below the icon later is cordova.app.id, not cordova-appName.
I'm confused what actually sets the name of an app. I don't want to involve opening xcode in this at all. I hope one of the involved settings/options is able to set the correct name.
HockeyApp is used to distribute the app.

Resources