xcrun error domain=FBSOpenApplicationErrorDomain, code=1 - ios

I'm trying to build an app via the command line, using these commands:
xcodebuild PRODUCT_BUNDLE_IDENTIFIER=com.myapp \
PROVISIONING_PROFILE="XXXX-XXXX-XXXX-XXXX-XXXX" \
CUSTOM_URL="http://mycustomurl.com" \
-project AppName.xcodeproj \
-scheme AppName \
-sdk iphoneos \
-configuration AppStoreDistribution archive -archivePath $PWD/build/AppName.xcarchive
then:
xcodebuild -exportArchive \
-archivePath $PWD/build/AppName.xcarchive \
-exportPath AppName.app \
-exportFormat app
Now, I would like to run this app to test using the emulator, so I run these commands to install and launch the app:
xcrun -v simctl install booted AppName.app #Install
xcrun simctl launch booted com.myapp #Launch
The app instantly closes and xcrun comes back:
An error was encountered processing the command (domain=FBSOpenApplicationErrorDomain, code=1):
The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.)
Now, if I try to launch my app with xcode (by gui) this starts without any problems.
I've also tried to:
Reset the Emulator
Check the App Transport Security Settings
Close all instance of the app

You're building for iphoneos (I can see a "-sdk iphoneos" parameter in your xcodebuild command line). Then you're trying to install the resulting .app object onto the simulator (!!).
That will produce an architecture mismatch, and thus that cryptic runtime error.
Change your compilation commands from "-sdk iphoneos" to something like "-sdk iphonesimulator9.3" (in case this is the version you need).
If in doubt, type "xcodebuild -showsdks" and a list of installed SDK's will appear on screen. Choose the one you need.
You'll probably need to mess with -arch parameter also and change it from ARM to i386 (Remember the Simulator runs onto your intel MAC ).
Try and tell us if it works.

Related

Not able to build Xcode project on real device

I am facing a strange issue:
I am trying to build using this xcode command
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id={deviceID}' test
But every time I run this command I see an unusual prompt that shows up in the next line --
quote]
I am not sure what quote means and what I am expected to enter. I tried entering other device attributes but still it din help me .
Could some one please help me?
As far as I understand your provided information you are trying to start a test on a real device. Tests are executed on simulator only, which is why Xcode tells you it's not able to build your project.
Try something like this instead:
xcodebuild \
-project WebDriverAgent.xcodeproj \
-scheme WebDriverAgentRunner \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
test
As you can see this command tries to build your project on an iPhone 6 simulator with iOS 8.1 installed. You can define this to your liking (e.g. OS=13.0 or another iPhone/iPad).
You can give these reads a try, too, for more examples and a better understanding:
https://www.mokacoding.com/blog/running-tests-from-the-terminal/
https://www.appsdeveloperblog.com/run-xcode-unit-tests-from-the-command-line/

Building and launching app in Simulator from terminal

I wanted to build and launch my iOS app using a shell script and not Xcode. My question is the similar to this question: How to launch an iOS app in the simulator without XCode rebuilding the app, which was asked in 2012.
It says that the IPA file created in build directory within the project directory can be used. I could not find a build directory inside my project folder. Also, I want to build the app from a script.
What is the most latest way of building and running an app on simulator using terminal commands?
Edit:
I built the app from command line:
xcrun xcodebuild \
-scheme UITestingTutorial \
-project UITestingTutorial.xcodeproj \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=13.6' \
-derivedDataPath \
build
But how do I launch it now?
Running this script inside your project directory will launch the app programmatically.
xcrun xcodebuild \
-scheme UITestingTutorial \
-project UITestingTutorial.xcodeproj \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=13.6' \
-derivedDataPath \
build
open -a "Simulator"
# This simulator id has been manually found
# by running 'xcrun simctl list' and searching
# for iPhone 11 under iOS 13.6 under Devices
# A script can be written to automatically find this.
xcrun instruments -w 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A
xcrun simctl install 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A ./build/Build/Products/Debug-iphonesimulator/UITestingTutorial.app (http://uitestingtutorial.app/)
xcrun simctl launch 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A com.codepro.UITestingTutorial
You can refer to Launch apps in iOS Simulator using Terminal for more details. Please note the xctool is deprecated.

Xcodebuild test hangs indefinitely without error

Xcodebuild hangs indefinitely in Jenkins. But same setup works properly in local machine.
(Xcode 7.3.1, OS X 10.11.6)
Command executed (After clearing DerivedData & Clean)
xcodebuild -scheme APP_SCHEME -derivedDataPath ./DerivedData -sdk iphonesimulator -destination 'OS=9.3,name=iPhone 6' ARCHS=x86_64 VALID_ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES test
Launches app in simulator and then Hangs indefinitely after following command without any error
touch APPSCHEME.xctest
xcodebuild hangs because it is not able to find & launch the appropriate simulator.
Verify whether the below 2 commands gives the matching list of simulators and they are in available state.
- xcrun simctl list
- instruments -s devices
If not, then proceed on to do a clean uninstall of Xcode,install and then try running the command again
Delete Xcode from Applications folder
In ~/Library/Developer/ Delete Xcode and CoreSimulator folder
sudo rm /Library/Preferences/com.apple.dt.Xcode.plist
sudo rm -r ~/Library/Caches/com.apple.dt.Xcode
sudo rm -r ~/Library/Application\ Support/Xcode/
Clean Trash
Restart Install Xcode ,Launch and Accept license Agreement and then Restart

Build and run an app on simulator using xcodebuild

I have the following goal to achieve: build and run an .app application using xcodebuild and ios-sim.
I'm using the following script to build the application.
xcrun xcodebuild \
-scheme $XCODE_SCHEME \
-project $XCODE_PROJECT \
-configuration Debug \
-destination generic/platform=iOS \
-derivedDataPath \
build
Then for running it, I'm using
ios-sim launch MyApp.app/ --devicetypeid "iPhone-6-Plus, 9.1"
Each time I receive the following message:
Program specified by service does not contain one of the requested
architectures: ?
What is happening, that the app doesn't run?
Note: if I run the second command (ios-sim...) against the .app built from Xcode (the one contained in derived data) the procedure works fine.
Ok. Figured out the issue.
You need to specify the correct destination. For example.
xcrun xcodebuild \
-scheme $XCODE_SCHEME \
-project $XCODE_PROJECT \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=9.1' \
-derivedDataPath \
build
In this way Xcode will create the folder (called build) containing your products (in particular look at Debug-iphonesimulator). The build dir is created within the dir you are running the xcodebuild command.
Now you can point that folder in order to run the ios-sim command (see ios-sim for more references) or simctl (see iOS 8: Building custom simulators and Build And Run iOS Apps In Commmand Line for more info).

xcode Code to install app

I want to achieve with the code, I write the program to install other applications to the phone, I found online said to be to app unzip and copy to the / var / mobile / Applications directory, I follow suitHowever, the installed program, you must restart the phone to display and install the application can not run
You can combine xcodebuild and xcrun commands to install and run your app.
The xcodebuild compile your project and create a .app file in DSTROOT that um point.
xcodebuild -sdk iphonesimulator8.4 -arch i386 install DSTROOT=~/MyApp
if you are using some pod file you have .xcworkspace instead .xcodeproj then add -workspace and -scheme at your xcodebuild.
xcodebuild -sdk iphonesimulator8.4 -arch i386 -workspace MyApp.xcworkspace -scheme MyApp install DSTROOT=~/MyApp
After created the .app file you can run into a Simulator device.
xcrun instruments -w "iPhone 6 (8.4 Simulator)"
xcrun simctl install booted ~/MyApp/Applications/MyApp.app
if you want to run in another Simulator device, try see all devices available.
xcrun instruments -s

Resources