Mac - Appium - How to setup Xcode simulator with specific OS version and .app file through command line - xcode

While setting up Appium on Mac, I am stuck at a point where we have got .app file to automate on an iphone simulator.
I am able to launch app which comes with .xcodeproj on Xcode.
But now I have an MyApp.app file to use on a Simulator. if I try to open a simulator using UDID it always open latest iOS version on Latest iPhone Simulator using this command:
open -a "Simulator" --args -CurrentDeviceUDID 8A63E11E-BEE4-4A1A-B77B-205D19A3DEE3
I need to open this on a specific iOS version on specific device then install MyApp.app on it. (also I am not able to get bundle id of app; not sure at which step I can do this)
Moreover, it Would be great if you can also share settings for Appium Inspector and where to fetch values from ?

Related

React Native `RuntimeError: abort(Error: xcrun exited with non-zero code: 2` on iOS simulator

I was working on a React Native project with a group and was asked to use the iPhone 13 simulator as a model while working. I only had access to the iPhone 12 simulator, and I saw that my XCode was a version behind, so I updated it. Now with the new XCode, I am getting an error when I start the React Native server and try and open the iOS simulator. the error is shown below:
Running this command with the suggested build with -s Assertions=1 reveals the following:
My package.json is as following:
Any idea what is going on or how to proceed? Expo seems to be able to run, but trying to open the simulator crashes the server. The project I am on is near tight deadlines and I am totally held up by this. Either a way to troubleshoot this error or a way to roll back my XCode install and just live with a dated simulator would be greatly appreciated.
Figured it our thanks to ShepSims from https://github.com/expo/expo-cli/issues/2413 . Before being able to open the iOS simulator from the terminal, I needed to open XCode and open the simulator there. This mounts the simulator bundle, allowing later access by pressing i after running expo start.
I was receiving the same error as above with XCode command line tools installed only, no XCode installed.
I tried re-installing XCode command line tools which didn't do anything.
For me this was solved with advice mentioned at https://github.com/expo/expo-cli/issues/3871:
open Simulator.app, as it automatically sets the default device.
It is not anything. It was solved by opening simulator from XCOde on my mac
The fastest way from my point of view is "spotlight" (Cmd+Space) search for "Simulator", hit enter before running "expo start" in your terminal.
You can solve the problem by using this command
sudo expo start
Or
manually open simulator
start app: react-native run-ios
manually do: Hardware -> Device -> select iOS -> select Device (different than before !)
that will open a second simulator
start the app again: react-native run-ios (expo start then press i)
this opens the app in the selected simulator
Note:- please stay open the silumater then press the i in the expo and same for the react-native run-ios command

macOS app built with Unity hangs upon launch after signing with codesign command in Terminal

I am trying to submit a macOS app built with Unity to the Mac App Store. I followed the instructions mentioned in the Unity documentation, Delivering your application to the Mac App Store.
I am able to run the Build command for macOS and get a .app bundle for my app. I am also able to launch it and it runs fine. However, after running the following codesign command (as mentioned in the linked document above), the app freezes upon launch and has to be force quitted. This is the codesign command line that I am running:
codesign -o runtime -f --deep -s '3rd Party Mac Developer Application: DEVELOPER NAME' --entitlements "GAMENAME.entitlements" "/AppPath/GAMENAME.app"
I have a paid (Individual) developer license with Apple, and have properly set up the certificates in keychain as mentioned in the document. I also managed to check that the app bundle was signed by running the command line:
codesign -dv --verbose=4 GAMENAME.app
Running the above command displays that it's signed with my 3rd Party Mac App Developer certificate.
I have tried looking for a way to export the Xcode project out from Unity app, so I can attempt to build and sign it with Xcode, but after searching the Web, I realized that Unity doesn't have support for exporting the Xcode project for macOS app yet (it can do the same for iOS).
I am running the current latest version of all the software, and the same are mentioned below:
macOS Catalina 10.15.1
Xcode 11.2.1
Unity 2019.2.13
My questions are:
What is it that may be going wrong?
What other avenues do I have?
I am looking for distributing the app exclusively via the Mac App Store for the time being. This is going to be a paid app (if that's relevant).
If you are building the .app from the command line (using Unity's command line invocation), try building from the editor instead.
Confirm you are not building a 32 bit-only binary.
Try removing -o runtime from your codesign command, this is the only part of your process that differs from mine, and mine works fine.
Otherwise, when uploading to the App Store, I believe Xcode will sign for you. While this will not be different from codesign, Xcode may check if you accidentally blocked or otherwise misconfigured running binaries signed by you on your particular machine. You should test on a different machine or macOS VM.
My app is not targeting yet the app store so i'm building using my Developer ID Application certificate
I'm building now by xcode 13.2 a Unity 2021.1.28f1 produced xcodeproj on macOS 11.6.2
The produced app bundle is notarized during Archiving it (so using the -o runtime switch implicitely) and
running seamlessly on macOS 11.6.2 even if no entitlements exception is used
freezing on macOS 10.15.7 till the "Allow Unsigned Executable Memory" (com.apple.security.cs.allow-unsigned-executable-memory) entitlements is not added during the build
So now the solution was for me to add com.apple.security.cs.allow-unsigned-executable-memory to the app entitlements

Can I install Xcode from the command line?

Is it possible to install Xcode from the command line (on iOS)? I need it to create Appium tests, and because Appium is a booger to install, I'm trying to automate as much of the set-up as possible.
For me its a little bit hard to get your intention.
Do you want to install the Mac Xcode on an iOS device? No this is not possible?
-> no you cannot install the Xcode for Mac on iOS
Do you want to use an Terminal app on your iOS device to install Xcode for Mac on your Mac?
-> You can use MAS and SSH into your Mac from your iOS device and execute the command.

How can I install .ipa file to iPhone simulator in Xcode version 9.X

I have an iPhone simulator running on Xcode 9.
I have a .ipa file, can you please tell me how can I install it on the Xcode simulator (iPhone X)?
You cannot. The simulator cannot run ARM code.
For those came here, if you have the source code then I suppose you have launched multiple times your app during development. You can copy the file yourapp.app from DerivedData folder:
~/Library/Developer/Xcode/DerivedData/...your.app.folder../Build/Products/Debug-iphonesimulator
and drag the file yourapp.app to any other iphone simulator.

Unable to launch iOS7.1 simulator in Xcode 6.2 instruments

Code which was working fine in xcode 6.1.1 now fails to launch the iOS 7.1 simulator in xcode 6.2 (but works fine for the iOS 8.2 sim).
Here is the command I am using:
instruments -t Automation -w /Users/USER/Library/Developer/CoreSimulator/Devices/233D1DE0-8660-4D98-8E45-5E0794CF7366 /Users/USER/Library/Developer/CoreSimulator/Devices/233D1DE0-8660-4D98-8E45-5E0794CF7366/data/Applications/APPNAME/APPNAME.app -v -l 20
This is the error returned:
instruments[2274:66214] -[UIAInstrument(UIAInstrument_Simulator) _startAgentForApp:withPID:]: Warning: Automation instrument could not locate sim tool.
That command launches the simulator and briefly shows the app's splash screen, then dumps out.
Any ideas?
You may go to xCode -> Preference -> downloads and see in iOS Simulator 7.1 is downloaded or not, if it is not downloaded then download and install it, it might work for you

Resources