Why in iOS Framework, xctest is always red colour? - ios

I'm trying to make a new framework to use in my other project. I know if it is red colour means can not find to the path of the file. But this not a file I created!
What I don't understand is why my new framework with pretty much nothing inside is always red colour. I even run test cases (default). I appreciate if anyone can help me to fix this:

No, Scheme(not schema) is different from Target. Check out this thread for better understanding Xcode: What is a target and scheme in plain language?
To solve your issue, click on the WSBandKit framework icon on top left section(adjacent to iPad2 simulator icon); and select editScheme option from drop down. You will be presented with a new screen with some option. Go to Build option and tick the option of Run for your test target. Close the screen and Build the framework for Device.
Check the image for reference. Initially the Run option will be unchecked for test target that you have to check.

Related

Cannot see recording red button for XCUITest in Xcode 9.2

As I am new to XCUITest, I want to write a test case by recording actions in the simulator but can't see the recording button in XCTestCase class.
What is the process to record a test case?
This might seem trivial, but almost drove me mad when I started with XCUITesting:
Notice that your cursor must be inside a function starting with test:
This won't work, though (Record button is greyed out):
I think that if you are not seeing the record button is because you don't have a iOS UI Testing Bundle in your targets. To do this you need to go to your project file and click the "+" button down on targets and then you add an iOS UI Testing Bundle. Then you will see a new folder named as your new target. There you can add UI tests and record them.

How can you see the XCUIElement tree?

Background:
I'm experimenting with ui level testing in iOS 9.0 with XCode GM.
Question:
Is there a command in XCode GM that will allow you to see a 'tree' of accessible elements and their relationships? Something similar to the 'page' command in Appium?
Ideally I would be able to run a command in the debugger that would give me a list of elements available for selection/manipulation. Currently you can use debugDescription on a single XCUIElement but that only gives you info for that element.
Set a break point where you would like to see the tree... in the debugger type:
po print(XCUIApplication().debugDescription)
That prints out everything XCUITesting has access to. You can also just throw that in to your test:
func testTreeExample() {
XCUIApplication().buttons["login"].tap()
print(XCUIApplication().debugDescription)
XCUIApplication().buttons["next"].tap()
print(XCUIApplication().debugDescription)
}
Thta way if you are having trouble finding something you can have it automatically print out what the app sees right after you do something.
This isn't exactly what you're asking for, but Xcode’s Accessibility Inspector makes it much easier to look at your view hierarchy in terms of what elements are accessible via Identifiers. (N.B. It's not the "Label" in IB's Accessibility panel that matters, it's the "Identifier" field.):
In Xcode 7.2, open Xcode->Open Developer Tool->Accessibility Inspector. (You may need to give the app permission to run in System Preferences.) Then launch your iOS app from Xcode and hover over any UI element in the SIMULATOR. You’ll see comprehensive information about the element type, description, hierarchy, etc.
Anytime you record UI actions and the output doesn't look right, use the tool to figure out what accessibility descriptions need to be added, changed, or removed. (I spent a couple days trying to get a deeply embedded UISegmentedControl to change via the UI Test harness, and the problem became obvious once I figured out how to use the Accessibility Inspector tool.)
Thanks to the folks at shinobicontrols.com for the great tip!
I would suggest choosing from the menu bar: Debug > View Debugging > Capture View Hierarchy when running in debug. Not only do you a way of visually representing the views but also the left-side debug navigator shows the hierarchy. This may not be one-for-one with UI Testing's perspective but it can be very helpful. Hope that helps.
The way Appium does this is using Facebook WebdriverAgent.
As far as I can tell, the way they do it, essentially, is starting from the root application element and collecting information about each child, then recursing.
What about http://fbidb.io?
With idb ui describe-all command you get the accessibility information of all the elements on screen (not the entire app) https://fbidb.io/docs/commands#accessibility-info
Put a breakpoint in any of your tests then just do: po XCUIApplication() and that will print out the whole app's accessibility hierarchy in easy to read tree format.

Xcode Deployment Info and icons using CMake

I've tried looking for info on how to set these (in red) using CMake but have had no luck so far:
1st red box issue:
First of all, even though the device seems like it's been set to 'Universal' correctly, the value isn't being interpreted correctly by Xcode. When I set it to 'Universal' manually using the dropdown, it gives a tab each for iPhone and iPad. Furthermore, I know it's not being interpreted correctly as the app does not function correctly (in my case, neither the launch image nor the app itself run full screen).
I don't think setting orientation programmatically is an option for me since I need the launch image in the correct orientation as well.
So can't do something like this:
How do I programmatically set device orientation in iOS7?
2nd red box issue:
I use an asset file for all my icons, so at the moment I'm having to build using CMake and then press 'Use Asset Catalog' each time.
I found this but doesn't seem very useful:
http://cmake.3232098.n2.nabble.com/Icon-and-Launch-image-support-for-iOS-apps-td7590970.html
Regarding the "1st box issue", I've found that the approach taken by this demo project works really well.
https://github.com/forexample/testapp/blob/master/CMakeLists.txt
They use a templated Info.plist to inject the bundle identifier, etc, during configure. The nice part is then you can modify the orientations in the plist.in file, and then these get translated cleanly to the Info.plist once you open the project.
Regarding the 2nd red box issue, i found that the attribute I needed to set was XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME
For example:
set_target_properties(${TARGET} PROPERTIES
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
For Launch Images I got it to work by setting it in the plist.in file under UILaunchStoryboardName as described in yano's previous answer.

Full screen issue after manually creating an empty application in Xcode 6

Since xcode 6 didn't offer an empty application any more, I manually created one by deleting the Launch screen interface file and the Main storyboard file base name in the info.plist file, and deleted Main.storyboard and LaunchScreen.xib then. Considering that I'll drawing the UI by myself, I created a view controller without an xib file. But when I ran the app, there are black bars both on the top and the bottom. I checked the [[UIScreen mainScreen]bounds] and found out that the bounds was 480*320.
I've checked on google and there were suggestions like adding png pictures or creating a xib file, but I really wonder why the property bounds didn't get the right size.
I have met with this problem, it's because you delete your "Launch screen file" and didn't set in general tab "Launch image source".
So you need to make .xcassets file, after right click inside .xcassets file you create "New Launch Image" with name something like "LaunchImage" and set images for appropriate sizes. After that in general tab you set "Launch image source" property name with your "LaunchImage".
Step 1:
Step 2:
Step 3:
A better approach would be to keep the storyboard and everything else Xcode sets up for a single-view app, and then build out your UI programmaticly from the ViewController. That way, you inherit all the automagic stuff the SDK does during startup.
I can't tell you exactly what this automagic stuff is; but, I'm pretty sure your bug would go away if you adopted this approach.

Could not load the image referenced from a nib in the bundle with identifier

I had got an iPad application.The ViewContrtoller.xib has got an UIImageView in it. The UIImage of the UIImageView is set through Interface Builder. When I run the application in simulator everything is fine. But when I am trying to run it in iPad the UIImage is not loaded. The message that I am getting is:
HexaPuzzle1.0[3259:207] Could not load the "start.png" image referenced from a nib in the bundle with identifier "com.yourcompany.HexaPuzzle1-0"
2010-12-17 10:57:27.221 HexaPuzzle1.0[3259:207] HexaPuzzle loaded
Any help would be appreciated and will be a great help for me.
The issue has been rectified.
Problem was with the image format. When the image has been edited and saved as PNG-24 everything goes fine.
The application now runs smoothly in simulator and device.
Thanks for all friends who suggested a solution and tried to helped me.
Regards,
Rupesh R Menon
I know it's very late, but this is a solution that also works in Xcode 5, and therefore likely to be useful to people who have this problem in the future.
I have seen a lot of questions like this on the web but none of them seems to have one clear answer. This is, as far as I know, the solution for this problem:
Go to the image in Xcode (no need to re-add or re-generate the
image)
click "show the file inspector"
Make sure the checkbox in the category "Target Membership" is checked. the test check box does not have to be checked to make your app load the image.
The target membership tab looks like this:
if this is already the case, you are working with a broken or damaged file. to rule this out, check if another app (like photoshop) can open your image.
This should do it, hope it helps!
When dragging your start.png file into your project, did you check this option?
I was getting this error in the simulator after upgrading to Xcode 7 / iOS 9 and opening an existing project. The image was present and named correctly, within an XCAssets package.
Turns out the problem was with a parameter within the XCAssets package.
Changing Render As from Default to Original Image solved the problem:
I've had the same problem before. The png file format is not right. Try re-generate the png image file and the problem will be solved.
None of the above worked for me, and the message I got was "could not load the "(null)" image referenced... which means I could not look for the image. Very frustrating. In the end it became a trial and error exercise of going through every xib and storyboard looking for potential conflicts. I finally found it - I had specified a "Selected Image" for a tab bar item which was not needed. As soon as I got rid of that the problem went away.
None of these things work for me. I created a new folder in the projects where I placed the pictures. That worked for me.
This problem was fixed when I changed "add folder reference..." to "add group..." when I import the images to my project. I'd prefer to have folders with live updating, but at least it works now.
Had an image on a XIB (which is replaced by the correct one in code). After finishing this XIB, I renamed the images. So XIB was now referencing a non-existent image.
There is also another potential cause of this problem: If you upgraded to XCode 5 and use both the image asset catalog and "normal" images copied to your project (like you did prior XCode 5). If you then have images with identical names (e.g. "dog.png" and a image set called "dog") it might work in your storyboard and in the simulator, but you'll get this message when run on a real device (where the image will not be shown).
Try moving the images directly to the Resources directory (not in a sub folder)
Make sure the resource isn't too big to be handle.
If you get the error message with the name of the picture, you can search it inside your project and xCode will display immediately the UIImageView with the wrong picture inside UIStoryboard:
Make sure it is included in your Target Membership
Select your "Images.xcassets" file in the file Inspector
Open File Inspector (cmd + opt + 1)
Select your target membership (Usually 1st line)
I had the same problem, but the cause was very different. I was using image sets in the Asset Catalog that varied based on the device idiom: iPad or iPhone.
The framework target they were being added to had been accidentally marked as as having a deployment device type of iPhone, so the images weren't showing up on iPads - they weren't even being copied into the .car file in the framework.
Setting the deployment device type to Universal, as it should have been, solved the problem.
For some reason I was getting error until I put the image in the Assets.xcassets

Resources