Xcode 7 UI test cases for pre Xcode 7 projects - ios

Apple simplified iOS UI testing in Xcode 7.
With new Xcode 7 projects, all you have to do to get the complete configuration for iOS UI testing is to check "Include UI tests" when creating a project.
What are the steps to get the same in Xcode 7 for projects that were created before Xcode 7 existed?

After testing several older projects:
Adding a new UI test target is sufficient as suggested by a-live in a comment to the question:
File > New > Target > Test > Cocoa Touch UI Testing Bundle
With Xcode 7 beta1, all of my projects habe been unstable after adding this target with different symptoms:
Compiler not able to import XCTest
red recording button greyed out and not working (even with cursor in the method)
Xcode crashing after pressing record button
Most problems were fixed after rebuilding the project, exiting XCode, restarting XCode with the project, rebuilding again. All were fixed after repeating this.

New UI testing framework requires your simulator running on iOS version 9.0. I encountered the issue of recording button being disabled for version below 9.0, like 8.4 etc.

The steps to add UI tests to an old project are also the same. Add a UI Testing bundle as suggested by Gerd, above. Then:
Take the cursor to a method in the .m test file.
When you take the cursor there, you will see the record button is enabled, which is on the top of the debug console.
Press record. This will start up your simulator and start writing code as per your actions.
You can find detailed steps here - https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line

Related

Xcode 7.1: Failed to build project <Project Name> for scheme

Has anyone faced this issue?
Been stuck trying to do a simple Xcode Bot integration with my simple project. Keeps coming back with this error that the bot wasn't able to build the project. From what I see, the scheme is just a normal scheme with the Unit Tests and UI Unit Tests. Bot is enabled Periodically and the Devices currently I've only set it to All Simulators (tried with others but it didn't work too). One thing I notice was when remove the Tests from the Scheme the Integration worked fine.
Thanks!
Was finally able to find the issue for this! Removing UI Tests initially showed that the integration was working fine. It seems that as Xcode UI Testing is only available on iOS9, the automated building would fail (without telling you the true reason) when testing on older simulators/devices. To overcome this I configured two separate bots:
Test for Unit Test Cases
Test for UI Test Cases (specifically on iOS 9 simulators / devices)
Hope this solves the issue for anyone else facing it!
It turns out, that in automatically updating Xcode it uninstalls the iOS 9.0 simulator and replaces it with the iOS 9.1 simulator. It doesn't think to update the build settings on the Xcode server.
So to fix the problem, you have to manually open Xcode on your server, it then prompts you to install several items which you need to do. Then go to xcode preferences > Downloads and you can reinstall the iOS 9.0 simulator.

AppCode no product for target

I am trying to run Swift iOS app in iPad simulator in AppCode. App is successfully built, but there is an error
Error running ios-app: No product for target 'ios-app'
I am quite green in iOS development and I am trying to switch from XCode to AppCode since I am more familiar with it.
I am using latest AppCode (3.1.7), everything works great in XCode.
Thanks for responses :)
I ran into the same problem - I wasn't able to run my XCTest unit tests in AppCode any more although they were running perfectly in XCode.
My error message was "No product for target ..."
I was able to get them running again by switching to the latest AppCode 3.2 build (Tascalate).
You can get this one by opening the IDE Preferences, then go to Appearence & Behavior > System Settings > Updates
There you can switch to the Early Access Program to check for updates.
Hope this solves your issue, too.
Edit: Since Julian above asked an important question about the XCode version... in my case I was using AppCode 3.1.7 and XCode 7 beta 4. The switch to AppCode 3.2 EAP - as already mentioned above - solved the issue.
I have delete the .idea folder and restart Appcode, it's work

add xctest framework to an old project

how can I add xctest framework to an old project? When I try to add a new framework I couldn't find xctest in the available list in Link Binaries With Libraries.
I also tried edit->refractor->convertToXCTEst but select targets to use xctest: lists no targets
In Xcode 6.1.1, and also in Xcode 6.0.1, the XCTest.framework is not listed anymore as an available framework. In Xcode 5.1.1, however, the framework is listed.
So something appears to have changed between Xcode 5 and 6 when it comes to testing. For instance, when you create a new project in Xcode 6 you no longer need the XCTest framework. You can simply add a new test case, build and the test runs just fine. I have yet to figure out why this is the case, but for you this might be the first thing to try: Just code a test case and see whether things work.
If they don't, then you could try this ugly workaround: Open the project with an older version of Xcode, add the framework there, then go back to work in your new version of Xcode. This worked for me when I tried it with Xcode 5.1.1.
EDIT: The reason why XCTest.framework is no longer needed in projects created by Xcode 6 is because these projects have the build setting CLANG_ENABLE_MODULES set to YES. Xcode 6 exposes this in the UI under the name "Enable Modules (C and Objective-C)". With this setting enabled, any #import statements for system frameworks such as XCTest cause clang to automatically link against that framework. Details are available in the "Modules" section of the clang documentation. Once this build setting is enabled you can also remove any other system frameworks from the "Link Binary with Libraries" build phase of your targets.
And for completeness' sake: The reason why Xcode 6 no longer lists XCTest.framework as an available framework is because the framework's location inside the Xcode bundle has changed:
# Xcode 6
/Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework
# Xcode 5
/Applications/Xcode-5.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/Developer/Library/Frameworks/XCTest.framework
Apparently Apple now relies entirely on CLANG_ENABLE_MODULES to get test targets to link against XCTest.framework. If you want Xcode 6 to list XCTest.framework as an available framework, you can manually create a symbolic link inside the Xcode app bundle:
cd /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
sudo ln -s /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework .
You need to restart Xcode after creating the link.

New PhoneGap / Cordova iOS project won't run after renaming

When you create a fresh Cordova project it's called HelloCordova, which is also the app icon name. If I rename the project in XCode it will no longer run in the iPad simulator.
I am running Cordova 3 and Xcode 4.6.3 on OS X 10.8.4
Steps to reproduce
In terminal:
cordova create Survey com.domain.mysurveyap
cd Survey
cordova platform add ios
cordova build
This creates the XCode project in platforms/ios/. I then open it in XCode. The project is called HelloCordova. I hit run with the target set to iPad 6.0 Simulator.
Running HelloCordova on iPad 6.0 Simulator. No issues
Good. I get the Hello World app up.
Next I rename the project by changing the Project Name in the Identity panel. I'm doing this
a) because I don't want my project to be called 'HelloCordova'.
b) because the name here seems to dictate what the App Icon is labelled as on the device.
I rename it to 'Survey':
Xcode prompts me to rename related project content items for me. I click 'Rename'
After renaming, I go to run in the simulator again. Now it won't run. I see a 'Build succeeded' overlay for a moment. But in the status panel at the top it says:
Finished running Survey.app on iPad 6.0 Simulator. No issues.
I notice that it still shows 'HelloCordova' in the scheme selector. I have tried running 'Clean' and also restarting XCode.
This is a completely fresh PhoneGap project with no modifications. Any ideas where I'm going wrong?
I don't know why the renaming was failing, and I can't explain that "Finished running... No issues" problem. But: cordova create takes an extra argument that was missing.
This solves the problem:
cordova create Survey com.domain.mysurveyap "Survey"
The final "Survey" there sets the project name on creation, thus avoiding the need to rename the project in the first place.

Xcode iOS Base SDK Missing

I have an old iOS app that I never distributed and am now trying to work on the project again. It worked fine with an earlier version of Xcode but I was not ready to deploy it at that time. Now I am using the current version of Xcode but I have an error that there is a missing base SDK. I have explored every posting here with that error message and they did not work for me.
On investigation in Xcode. I can choose my app under "Project" pane. With the Info tab chosen, it has under Deployment Target as "Mac OS X Deployment Target" and Default in the drop list.
This is an iOS app and not a Mac OS X app. How do I change this?
I already have the base SDK as the Latest iOS.
Suggestions?
Try this:
Open Xcode and Press cmd + 1
In left panel choose your project -> Your target in center panel-> Build Settings in right panel
Find "Base SDK" and choose "Latest iOS". If you see a Release and Debug lines, then choose this for both Release and Debug.
Restart your Xcode
Usually when you see this, it's when you've got an old iOS project and you're using a version of Xcode that uses a newer base iOS. In those cases, you can click on the target on the top of the tree structure of the Project Navigator on the left, and you'll see the project settings. There's a button labelled "Validate Settings" and will show up near the lower center portion of the main panel. Click on it.
If that doesn't do it (e.g. it's from a really old version and Xcode can't figure out how to remedy it), it might be easier to recreate the project. Create a new iOS project and then copy your source code, its NIBs and resources into that project. Maybe that will be easier than trying to fix the old project you have.

Resources