Run .app file in iOS 8 simulator - ios

I have a .app file shared from a developer which i would like to run in iOS 8 simulator. I have seen similar questions which has solutions for older versions of iOS which is no longer working for iOS 8. Can someone point out what needs to be done to run the .app file in an iOS 8 simulator without using xcode.

Boot the simulator you want to install it to in the iOS Simulator and then do the following:
xcrun simctl install booted /path/to/Your.app
xcrun simctl launch booted com.yourcompany.yourapp
The "booted" token was not supported on older versions of simctl in Xcode 6.0. If you get an error, please use the full device UDID instead of "booted". You can determine the UDID by running xcrun simctl list

If the application crashes after installing in the simulator using the command,
xcrun simctl install booted /path/to/Your.app
It's probably because the architecture issues, since we used the device build instead of simulator build.
The basic architecture difference between the iphone simulator and iphone device is
iPhone simulator uses the architecture i386 or x86_x64
whereas,
iPhone device uses the architecture arm64 or armv7 or armv7s
We can find each device architectures in this link. So to over come this problem we need to get the simulator build by changing the xcode build location settings.
SOLUTION :
To change the build location settings, Open your xcode and follow the below steps.
Go to xcode preferences.
Choose the locations tab.
In the 'Derived Data:' section click 'advanced', from the resulting screen choose 'legacy'.
Now build the application, after successful build go to 'Your-App-Folder/build/Debug-iphonesimulator' in finder, and copy the build available on the same folder with the extension .app
Copy that and run the above command answered by #jeremy.
xcrun simctl install booted /path/to/Your.app
After running this command, note that your simulator is installed with the build you specified. There you go, run the application in simulator by clicking the corresponding app and use it.
I deliberately write this solution to help the needy, those who are clueless about the architecture issues specified above.
Happy Coding :)

iOS Simulator also supports dragging and dropping for installing .app files
Open Simulator
you can do it through XCode under XCode > Open Developer Tool > Simulator
to open it "without using xcode", see these answers.
Find the .app file in Finder and drag it into your Simulator window
Wait for the app to install and launch it

For developers looking to provide a simulator build to theirs testers, these are the steps that I followed to create and test a build -
Add i386 in valid architectures section of build settings.
Open terminal and navigate to your project folder. Then execute the command -
xcodebuild -arch i386 -sdk iphonesimulator8.1
(This will build the application)
To install the application on simulator, run the command mentioned in the above answer i.e -
xcrun simctl install booted /path/to/Your.app
Now you should be able to run the app by clicking on the installed application in the simulator.

I have followed all the above commands and stuff but none worked. All I was doing is creating .app through archiving the app from Product->Archive and then converting that generated .ipa to .app by changing the extension to .zip.
But the app is crashing as and when it is being launched.
For those facing the same issue, go to
DerivedData/projectname/Build/Products/Debug-iphonesimulator/
folder. There you can find the .app file with app name. You need to use this .app file by dragging and dropping onto the simulator. Product->Archive->.app doesn't work.

Related

How can I build and run an iOS Swift app from the terminal?

I've recently started learning Swift and SwiftUI for iOS development and I completely understand how to run my apps for testing using XCode. You just click the play button with whatever simulator device is selected. However, I really don't like using XCode. I want to use VSCode for my development. Looking online I can find very complicated tutorials on how to build my project for release on the App store or "Ad-Hoc" from the terminal. But, I don't think this is what I need. I'm wondering if there is a way to build and run my app from the terminal on to a simulator or personal device (connected with USB)? I understand I can just have XCode open on the side and run it from there while developing from VSCode, but, my computer is kind of old and having both those apps open makes my fans go crazy.
You can follow this guide on how to build your project using xcodebuild.
Assuming you are in the directory with the .xcodeproj file, the command will look something like this:
xcodebuild -destination "platform=iOS Simulator,name=iPhone 14 Pro Max,OS=16.0" -scheme YourScheme SYMROOT="./build" build
Of course, you can choose any simulator you like. You can find a list of the simulators by doing xcrun simctl list.
The built app will be located in a folder called build/Debug-iphonesimulator, or build/Release-iphonesimulator, depending on your default configuration. The configuration can be set by the -configuration option.
Now you can launch the simulator. Here is a guide for that. Basically, you just specify the UUID of the simulator (again you can find this using xcrun simctl list), and then launch Simulator.app. Example:
xcrun simctl boot 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
To install the built app, you also need the UUID (see also this answer)
xcrun simctl install 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1 build/Debug-iphonesimulator/YourApp.app
Finally, you launch your app by specifying the UUID of simulator, and the bundle ID of your app (source)
xcrun simctl launch 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1 com.mydomain.YourAppBundleId

iphone sdk missing from xcrun how to build for iphone from command line?

I'm trying to figure how to build metal shaders for iphone os using xcrun.
I have (the almost latest) Xcode 11.3.1 installed on macos 1.4 Mojave.
xcrun --sdk iphoneos --show-sdk-path
reports that the sdk cannot be found.
I checked
xcrun --sdk macosx --show-sdk-path,
which reports
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
The iphone and TVOS sdks don't seem to be there at all. However, I'm able to use the Xcode IDE to build to an iphone. I checked the build logs and found that one step sets the SDKROOT to:
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk which is inside the Xcode bundle.
I want to be able to build from the command line, but clearly the correct path hasn't been registered. Do I need to reinstall the command line tools, or is there some setting I need to add an SDK to xcrun?
How do I proceed?
I very quickly realized that I must have been using the bare-minimum command line tools from when I first installed the machine.
In Xcode, go to Preferences>Locations and select a specific set of command line tools from the drop-down. This updates xcrun to point to the full collection of SDKs that Xcode provides.

App opens and crashes on simulator using desktop Appium app

Test Environment
Desktop OS/version used to run Appium:Version 1.2.0-beta.3 (1.2.0-beta.3)
Node.js version (unless using Appium.app|exe):
Mobile platform/version under test:ios simulator
iPhone 6s plus 10.2
1.Pulled latest code from sourcetree
2.opened xcode
3.made a archive file
4.got the app file from there.
5.opened Appium desktop app
6.added the desired capabilities
.{
"app": "/Users/Desktop/PreProd.app",
"platformName": "iOS",
"deviceName": "iPhone 6s Plus",
"platformVersion": "10.2",
"automationName": "XCUITest"
}
8.The app opens and crashes
appium log file
try to follow the below tutorial for real device setup
https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md
If it is done already, restart your device and MAC once and try executing again.
To run in simulator, you should get the .app file from simulator folder NOT from the xcode archives.
The architecture for the archived build will be arm64/armv7, which can only be installed in real device.
To get .app file for Appium test in simulator :
Open project in Xcode --> expand your project --> expand products --> you will see .app file there.Go to file location and copy .app file.
You can use this .app file for Appium test in simulator.
Note : this only help if you have access to Source code. If you don't have access to source code to run the project and only have archived build, then only option you have is to run it in real device.
The application crashes because the .app file you are trying to launch is either
Not simulator compatible
Not bundled and compiled with the current simulator architecture
Has incorrect bundle id
Try building the .app file for the simulator using the xcode command
xcodebuild -arch x86_64 -sdk iphonesimulator11.3 -workspace {projectname}.xcworkspace -scheme {schemaname} -configuration {configurationname} SYMROOT=${WORKSPACE}/build/{projectname}.xcarchive
Once the .app file is generated, use that and try launching.

How to run a previously compiled version (or a previous build) of an Xcode project in ios 10.0 simulator

I'm trying to test one of my apps on ios 10. I have downloaded the Xcode 8 beta which ships with the ios 10.0 Simulator. However, as expected, Xcode 8 is throwing tons of errors on the libraries I'm using [like Alamofire] which is preventing me from building in Xcode 8, which I don't feel I need to worry about right now. I'm just looking for an easy way to run the last stable compiled version (which I can successfully build within Xcode 7 for ios 9.3). I am unable to trigger the ios 10.0 Simulator from my terminal via xcrun as I have used to achieve similar things in the past.
Any guidance would be much appreciated!
EDIT -- Solved
I figured out a way to achieve what I was looking for, for those interested.
In Xcode7 go to Preferences > Locations > and change Command Line Tools to Xcode 8.0
In Terminal, type xcrun simctl list to see the available Simulators (ios 10.0 simulators should be available now).
Copy the UDID of the Simulator you want.
Make sure the normal Simulator app is not running, then run open /Applications/Xcode-beta.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID <Copied UDID>
After the desired Simulator is booted, run xcrun simctl install booted <path to project .app file> (the path to the .app file can be found in Xcode on the left pane, under your main project, under the folder "Products" copy the file path from the [project-name].app file located there)
This should install the app onto the desired Simulator. I did encounter some errors the first few times I tried this. I got around them by simply quitting the Simulator.app and trying again (Worked for me on the fourth try).

Running iOS app on a different Mac / simulator

I have built a demo iOS app on my Mac. My client wants to get the executable and run it on his iOS simulator on his Mac so as to give me feedbacks. I have an Apple developer account and I can deploy my app to my iPad / iPhone or distribute it via AppStore. But I don't know how to generate an iOS simulator executable for him. He only wants the iOS simulator executable. Does anyone have tried this before?
P.S. I can't really distribute it via AppStore since it is just a demo app. It is very likely rejected. Plus, I have to send it to him today so I don't think Apple can pass my app within a day.
P.P.S. I can't give him the source code unless he pays me. But it is not possible after a month.
Please help. Thanks in advance!
You need to send him the Application folder under the iPhone Simulator folder.
You can find it here:
~/Library/Application Support/iPhone Simulator/<Simulator-Version>/Applications/
Building upon this answer by #Midhun, for later versions of Xcode (Xcode 6, Xcode 7 and Xcode 8 in my research), the simulators now live here:
~/Library/Developer/CoreSimulator/Devices
I was actually trying to use an app built on Xcode 8 for iOS8 simulator and get it to run on an ios7 simulator from Xcode 6 on another Mac. I couldn't find out how to simply copy files around but I did manage to copy the Mine.app folder to the other Mac, then install it using
xcrun simctl install 6DC6323C-504C-423F-ACD6-652557B33D48 Mine.app
where you need to replace 6DC6323C-504C-423F-ACD6-652557B33D48 with your simulator device type ID (find using xcrun simctl list devices).
For running app, build on other mac machine to yours machine simulator. we require .app file for that project.
run below command in terminal
xcrun simctl install booted $LOCATION/FILENAME.app
replace $LOCATION with the path and the FILENAME should be the name.for more details check this link => https://www.webdigi.co.uk/blog/2016/how-to-transfer-your-app-to-an-ios-simulator-on-another-machine-using-app-file-and-xcrun/
iOS Run .app on another simulator
Build .app[About]
Xcode: Product -> Build
xcodebuild command[About]
//building workspace
xcodebuild -workspace "/path/to/workspace" -scheme "MyShemeName" -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
Find .app
//1. Build location*. Usually it is derived data folder
//2. Xcode.
Project navigator -> project -> Products group
//3. Get it from iOS simulator
Activity Monitor -> <App Name>(not Xcode) -> Double click -> Open Files and Ports -> Find <App Name.app> path -> find and copy a file <App Name.app> by path -> save the file locally
[Build location]
Install .app
xcrun simctl install booted <app_path.app>
Or you can send just the one app you need from ~/Library/Application\ Support/iPhone\ Simulator/7.0/Applications/GUID-OF-YOUR-APP
i have used a similar tool called Simulator Bundler in a recent project with no issues,
https://github.com/landonf/simlaunch/downloads
Midhun MP answer is good but in case of solution don't work then in emergency sometimes making video and sending it to client would help. This tool provide light weight video creation.
http://www.screencast-o-matic.com/
You can resize it for your simulator.

Resources