WatchOS 9.1/iOS 16.1 xcodebuild run on Apple Watch fails - ios

Recently I updated my devices to the newest version and with this update I am having troubles to run xcodebuild commands when destination is my Apple Watch.
The problem is in the scheme configuration or devices visibility for scheme, or both
it is working when I use generic destination:
xcodebuild -project MyApp.xcodeproj -scheme 'MyApp WatchKit App' -destination generic/platform=watchOS build
command I used:
xcodebuild -workspace MyApp.xcworkspace -scheme 'MyApp WatchKit App' -destination 'platform=watchOS,id=Watch's ID'
And I see this error:
xcodebuild: error: The run destination My iPhone is not valid for Running the scheme 'MyApp WatchKit App'.
(null) needs to connect to determine its availability.
Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode.
Both devices may also need to be restarted and unlocked.
Restarting and unlocking doesn't help.

Related

how to properly archive an ios app xcode 13

Well there are lots of articles/blog on archiving an iOS app, i've tried several of them, but i end up getting one error or the other, I'm setting up CI/CD, and I'm at the stage of archiving my app.
These are the most promising errors i've gotten so far, i say promising cause other errors encountered seem to be dead ends, but the below commands seems to be a step in the right direction.
1st Command
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution -archivePath $PWD/build/MyApp.xcarchive clean archive
Output
error: Signing for "MyApp" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Decred Wallet' from project 'MyApp')
2nd Command
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration MyApp\ Release -archivePath $PWD/build/MyApp.xcarchive clean archive
Output
error: No profiles for 'com.mydomian.myapp.test' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.mydomian.myapp.test'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'MyApp' from project 'MyApp')
has anyone done this recently, I need some insight please.
also a few steps to this
i already created a direcory mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles and copied my mobile provisioning file there, i also created a keychain and imported my .p12 file into it

Run UITests from command line Apple Watch

I'm having troubles while running XCUITests on iPhone and paired apple watch (simulators) simultaneously using terminal. I can do it by hitting "test button" for each of my uitests targets separately, it works just fine, but I need to do it
1 - from command line
2 - simultaneously
However, I am able to run uitests from command line for the same iPhone simulator (that is paired with apple watch simulator) using
xcodebuild -workspace MyApp.xcworkspace -scheme 'MyApp' -destination 'name=iPhone 11' test
It works as expected- launches simulator and run tests
The problem is:
When I do the same for paired apple watch (it doesn't matter separately or simultaneously with this iPhone) tests for apple watch doesn't launch at all
xcodebuild -workspace MyApp.xcworkspace -scheme 'MyApp WatchKit App' -destination 'name=iPhone 11' test
Terminal says that:
The requested device could not be found because no available devices matched the request.
Available destinations for the "WatchTesterApp WatchKit App" scheme:
{ platform:iOS Simulator, id:2B6CA009-BF6B-4437-9E80-18D53EB003BA, OS:14.5, name:iPhone 11 }
But this device is here and listed as available
So, any suggestions? maybe someone had similar issue?
I will appreciate any help
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'

CodeSign error: code signing is required for product type 'WatchKit Extension' in SDK 'iOS 8.4'

I'm attempting to compile my app with a hosted CI service using xctool. I'm seeing this error during my build:
CodeSign error: code signing is required for product type 'WatchKit Extension' in SDK 'iOS 8.4'
I'm not seeing this when compiling in Xcode (it compiles and code signs perfectly fine).
Here is the command that I'm executing:
xctool ONLY_ACTIVE_ARCH=NO -scheme "ShipIOWatchTest" -sdk "iphoneos" -workspace "ShipIOWatchTest.xcworkspace" clean build CODE_SIGN_IDENTITY="iPhone Distribution: Andrew Page (**********)"
I believe that I have proper configuration within Xcode. Here are my settings:
Main App Team Selection
Project CodeSigning Settings
Main App CodeSigning Settings
Watch Extension CodeSigning Settings
Watch App CodeSigning Settings
This is very frustrating. Does anyone have any ideas?

Archive Build iOS App with XCode Open

I am currently able to adhoc build my iOS app using the following command:
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration AdHoc archive -archivePath /Users/andrewherrick/Desktop/MyApp.xcarchive
It works great when my phone isn't connected to my Mac having XCode recognize it. However, when it's plugged in it always bombs out:
Reason: You cannot archive for the iOS Simulator platform.
Is there anyway I can modify the build command to allow me to NOT have to disconnect my phone everytime I want a fresh adhoc build?
try using the -destination parameter. e.g.:
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration AdHoc archive -archivePath /Users/andrewherrick/Desktop/MyApp.xcarchive -destination generic/platform=iOS

xcode build works on device, but not on simulator

I want to setup a jenkins server to build our app and run javascript/automation tests on a simulator.
Regarding that topic, I had several issues to launch the app on the simulator. Now I am fighting with the hole simulator thing.
My plan is, to build the app and to launch it on the simulator. Here is what Ive done:
Step 1:
(make archive)
xcodebuild -project "myApp.xcodeproj" -scheme "api-dev" -configuration "Debug Dev" -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.1' archive -archivePath /Users/name/Desktop/build/archive/myApp.xcarchive
Step 2:
(make/export .app file)
xcodebuild -exportArchive -exportFormat app -archivePath /Users/name/Desktop/build/archive/myApp.xcarchive -exportPath /Users/name/Desktop/build/myApp.app
Step 3:
(using xcrun to boot simulator)
xcrun simctl boot < device_id >
Step 4:
(using xcrun to install app on booted simulator)
xcrun simctl install booted /Users/name/Desktop/build/myApp.app
Step 5:
(shutdown simulator, since it would crash when I use instruments afterwards)
xcrun simctl shutdown < device_id >
Step 6:
(start .js tests via instruments)
instruments -w 'iPhone 5s (8.1 Simulator)' -t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate" /Users/name/Desktop/build/myApp.app -e UIASCRIPT /Users/name/Projects/project-name/myAppTests/UITests/script.js
When I open the simulator to launch the installed App (so without Step 6), only to test if I can open and launch the App, it does not work. Thats my real issue at the moment.
Error: "Target failed to run: Failed looking up pid of launched process"
When I open Xcode and take a real device and copy "/Users/name/Desktop/build/myApp.app" on it, it totally works fine...
What do I miss here with the Simulator?
Thank you for your input.

Resources