How to run automated XCUITests in Xcode for iOS via .ipa - ios

I am facing an issue which ultimately results in following error -
The bundle “$(PRODUCT_NAME)” couldn’t be loaded because its executable couldn’t be located. Try reinstalling the bundle.
Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo=
{NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
I have been working on getting my UITest automated but i am intermittently(though 80% of the time) facing the above issue.
I am using the following command from command line .
xcodebuild -project Commute.xcodeproj -scheme CommuteUITests -configuration Debug test -destination "platform=iOS,name=$DEVICE_NAME" -derivedDataPath $DERIVED_DATA_DIR -only-testing:CommuteUITests/$SUITE .
where everything have there usual meaning but this results in above error, and also i sometime provide multiple destinations.
On the other hand i want to run .ipa instead of building via source code.
So basically there are 2 problems here -
Why do i get these errors, i hovered around the internet but i'm not
able to find the solution?
How to do i start my tests for testing an .ipa?
Someone please help me i'm stuck here big time, any help/pointer is greatly appreciated.

If you are still having this issue please check that your tests are picking up the correct info.plist file. If the tests pick up the incorrect info.plist file it will result in the following error:
The bundle “$(PRODUCT_NAME)” couldn’t be loaded
I know you are not using cocoapods but this guy had the same issue:
https://github.com/CocoaPods/CocoaPods/issues/7178
So make sure your tests are using the correct info.plist. Hope this helps!

As the mentioned answer was not sufficient enough, here are my additional insights:
Yes, there was an Info.plist file loaded, which should not have been loaded. But where did it come from?
My Tests target (in particular my UI Tests target) had an Info.plist file on their own, that was just fine, until I decided to make use of the #testable opportunity given by Xcode nowadays.
Open your file-browser of your project in Xcode:
⌘+0 then ⌘+1
Enter in the search field at the bottom Info.plist
Now I had two referenced Info.plist-files:
Info.plist with Target Membership to the Target Application (which classes are also imported via #testable)
Info.plist with Target Membership was the (UI) Testing Target
Just deselect the 2nd Info.plist Target membership (or delete it, if you don't need it anymore) and should be all fine.

Related

XCTest, Failed to load test bundle. Crash on test launch

In Xcode 9.1, I added a Unit Test Target to an older project and I'm not able to get tests to run. The target crashes on launch with the following error in the console:
The bundle “XXXTests” couldn’t be loaded because it doesn’t contain a version for the current architecture*
Full output:
2017-11-15 11:52:40.973 XXX[54962:16511010] Failed to load test bundle from file:///Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3585 "dlopen_preflight(/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/XXXTests): no suitable image found. Did find:
/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/XXXTests: mach-o, but wrong architecture" UserInfo={NSLocalizedRecoverySuggestion=Try installing a universal version of the bundle., NSFilePath=/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/XXXTests, NSLocalizedFailureReason=The bundle doesn’t contain a version for the current architecture., NSLocalizedDescription=The bundle “XXXTests” couldn’t be loaded because it doesn’t contain a version for the current architecture., NSDebugDescription=dlopen_preflight(/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/XXXTests): no suitable image found. Did find:
/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest/XXXTests: mach-o, but wrong architecture, NSBundlePath=/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-gaxtmzjadfkxzsdciqnpmyczgntj/Build/Products/DEV-iphonesimulator/XXX.app/PlugIns/XXXTests.xctest}
(And then some diagnostic output that I didn't include)
Stuff I've checked after extensively googling:
Build Active Architecture Only setting is consistent across the app and test targets (With a value of Yes)
Enable Testability is set to Yes for the main target
I've deleted the target and started over, no luck
How do I fix this?
Make sure iOS Deployment target fields of your application target and test target are the same
I had the same issue. Simply building and running the associated application target on an iOS11.1 simulator (which happens to match the "iOS Deployment Target" of Test target) it started working.
It seems starting the test the first time did not trigger a build of the test host. Subsequent runs seem to trigger the builds as needed and all is good.
YMMV
It happened to me when updating the Xcode version from 9.3 to 10. In my case, deleted the DerivedData, then the unit test works.
I had the same error. And for me what it worked was the following:
Select your test on the PROJECT NAVIGATOR
on the right side, in FILE INSPECTOR choose the Target Membership, in this case your test target.
In my case, The Team under Signing & Capabilities were different for both Target Membership
making the Team same for all Target Membership solved the issue for me.
I had a similar error. My tests were passing locally but failing on CI (Xcode Cloud). The fix for me was to set Enable Hardened Runtime to No for Debug.
(from https://www.jessesquires.com/blog/2020/02/23/mac-app-tests-fail-with-hardened-runtime/)
In my case, I had Mac version of OCMock.frameworked in Link Binary with Libraries build phrase for an iOS project.
Removing it solved the issue for me.
run with another ios11 device solve the problem

Xcode iOS app crash on launch: unable to create lldb_private::Process

I've been trying to get my OpenFL game to build for days, and finally got to the point where the build succeeds (had a lot of trouble linking everything correctly, using severla static libraries of different shapes and forms). It finally builds, and now I Get this:
How can I debug this? In the console it just says
error: failed to launch
'/Users/joon/Library/Developer/Xcode/DerivedData/TryHarder-cynkhfxgstydmgawfivgqqiluryl/Build/Products/Debug-iphoneos/TryHarder.app/TryHarder'
-- unable to create lldb_private::Process
I have rebooted computer, mobilde device, cleaned, rebuilt, uninstalled, which is what many sources recommend in the case of an on-launch crash with no info. Nothing does the trick however. Some sources recommend to set debugger to GDB, which is no longer possible in XCode 6 it seems.
I'm not sure how to debug this any further.
I began to get this when I changed Mach-O type to "Bundle" in Targets > build settings > Linking. I won't claim to know much about this, but perhaps it will help..
Set the Mach-O type to Executable and it will work absolutely fine. you can find it in Targets > build settings > Linking

Unable to make ipa: Archive Failed

Xcode Project works well in simulator but i am unable to make an ipa.
It showing error while archiving..
Error :Lexical or Preprocessor issue Classes/ViewControllers/QUProgramDetailsController.h:13:9: 'ProgramDetailsDTO.h' file not found and Archive gets failed
can any one please help me?
Ensure the Framework and all it's headers are imported into your project properly.
Also in your Build Settings set YES to Always search user paths, and make sure your User header paths are pointing to the Framework.
Finally, Build->Clean and Restart Xcode.

XCode:4.6 Lion:10.8 IOS 6.1 error: SBTarget is invalid

XCode:4.6 Lion:10.8 IOS 6.1 error: SBTarget is invalid , how to solve this?
After hundreds of times testing, I find a way that can help the programme run,
here is it:
When you first meet SBTarget is invalid, choose Product --> Clean
Run again, this time you may also get error: SBTarget is invalid, it doesn't matter.
Turn off the XCode totally, 'totally' means that the Xcode icon should not appear in the Dock.
Double click your project file(xxx.xcodeproj , the blue one) to start Xcode, run again. (Do not Clean this time), and it runs ok.
Let me know if this can help you or you have any other methods. Thx
I had this issue while incorporating the Facebook SDK into my app. The error would alternate between SBTarget is invalid and telling me that my architecture was incompatible with my device so it would not launch. If I followed alexqinbj's advice it would run the app once but then it would go right back to having the same error again. I tried messing with architectures and build settings and removing derived data but in the end it really was just a duplicate file in my file structure. Facebook told me to add their SDK and then to add a folder (that the SDK file already contains). Once I saw that it was just a matter of removing the duplicate file. I've heard of this error happening with duplicate plists as well. Good luck
Indeed, the root cause (in Facebook integration) is the duplicate resources in the Facebook SDK (as per their instructions). When I deleted the resource files (remove references only), this problem went away permanently. Not sure why Facebook instructions ask you to drag the resources bundle over to the Facebook SDK framework you just brought in...
TARGETS -> Build Phases, remove info.plist from Copy Bundle Resources. Clean and run. It works for me.
Unfortunately, the accepted answer didn't work for me. I can provoke this error with 100% certainty. It is not necessarily an internal consistency issue with XCode that can be resolved through cleaning, rebooting and rebuilding.
SBTarget is Invalid is an internal XCode error. It happens when attaching a debugger and the architectures specified in the XCode project do not match up with the binary.
On OS X, you can diagnose this by going to the binary on the hard drive and typing:
lipo -info <bin>
Then comparing this to the build settings ARCH and ONLY_ACTIVE_ARCH. They must match. It is not enough for ARCH to be a subset of the possible architectures contained within the binary.
There are any number of reasons why they might not match up. Here are some suggestions:
You are using an external build scheme. XCode therefore does not dictate the contents of the binary. The build settings merely tell XCode what to expect when launching GDB or LLDB.
The executable specified for launch in the scheme is not correct. If it can't find the executable, the architectures will not be present.
This error has a very distinct cause in my case. Whenever "Expand Build Settings in Info.plist File" was set to "NO" in Xcode's "Build Settings", this message came up. Will submit rdar to Apple.

Strange errors when Archiving iPhone app

So I am trying to archive my iPhone app for ad-hoc testing and I am getting some weird circumstances. When I archive it, at the top where it says archive type, for some reason it says "Mac app archive" instead of the usual "iOS App Archive"
I do not know why this is happening, because this is not a mac App.
I have the following three warnings when I archive the app that may help, but I'm not sure.
The first is this one
iPhone/iPod Touch: application executable is missing a required architecture.
At least one of the following architecture(s) must be present: armv6 (-19033)
I am not sure why this is happening, because I have both armv6 and armv7 listed in valid architectures
The second warning I get is this
The CodeResources file is missing and it must be a symbolic link to
_CodeSignature/CodeResources. Make certain that the bundle is on a locally-mounted volume
(not a remote SMB volume), and be certain to use the Mac OS X Finder to compress it
(-19062)
Again, not sure why this is happening, or even what it means.
The last error is this one
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'Catch It/Resources/Info.plist'.
I am really lost on that one, I don't know what it is trying to tell me.
Please help me, because I cannot distribute this ipa because it thinks it is a mac app.
Thanks
I guess you are using Xcode 4.5.
I've just run into the same problem, and managed to solve the problem. My app is waiting for review now.
This is what I changed: In the target, I selected "Build phases", then in "Copy bundle resources" I removed the plist file.
If this doesn't fix your problem, also make sure you set the iOS deployment target to iOS 4.3 at least.
Edit: I also removed armv6 from both Architecturesand Valid Archictectures in the build settings.
I get message on Xcode 4.6.3
The CodeResources file is missing and it must be a symbolic link to
_CodeSignature/CodeResources. Make certain that the bundle is on a locally-mounted volume
(not a remote SMB volume), and be certain to use the Mac OS X Finder to compress it
(-19062)
when try Build app, after running it on Simulator. Change target to iOSDevise solve this problem.

Resources