How to remove target for unit tests in Xcode5? - ios

I'v just upgraded to Xcode5, and my unit tests with OCUnit (SenTestingKit.framework) stopped to work. I'v tried various solutions but none of them helped, so I'v decided to remove the target for tests and add a new target "Cocoa Unit Testing Bundle" with XCTest. I know I could ask Xcode to convert existing one, but I would like to make a clean remove and add a fresh one. However, I can't find how to remove the target. Any ideas, where the button is hidden :) ?

Have you tried turning it off and on again? :)
Just right-click (command-click) the target:
Or select the target and hit the Delete (Del) key.

Related

Xcode 10.1 doesn't show 'distribute app' option when archiving, can't archive

I suddenly got this weird issue with Xcode 10.1.
When I archive app store target for my app I cant see "distribute app" option, instead it now says "Distribute Content" and neither I can export ipa nor upload to app store directly.
My archive comes under "Other items" in Organizer instead of iOS apps.
It seems to work fine with development target though.
Here is the screen shot.
Anyone with any knowledge about it please help.
Thanks
Please make changes as follows
Change Skip install to NO
Make sure only the Application has this set to NO. Embedded Targets like Frameworks need to have Skip Install = YES
Faced the same issue few days ago. This usually occurs when you have multiple schemes in a project.
Go to edit scheme (Next to stop button)
Select the target of which you want to archive.
In build option, remove other targets or you may unselect archive checkbox.
Re-archive
I ran into this annoying error today - I thought it was the new version of Xcode - but no. I had multiple targets for my project (staging/production), and also a nested framework project.
To solve this I opened the staging scheme and made sure only the checkboxes are checked for that target: (the top row was selected before)
I have run into this situation and solved it.
The solution set SkipInstall=No does not work for me.
I find the reason for my situation is that I imported a framework by adding it into Link Binary With Libraries section.
So I changed a way to import the framework.
Remove the framework at Link Binary With Libraries section.
Add the framework directory to the framework search paths.
For more information ,see my blog at JianShu:
https://www.jianshu.com/p/c65599da18c0
i got the same issue and nothing works from above answers. so i debugged my code and i found out that there was a folder that was missing and instead of showing any error i was getting "distribute content" instead of "distribute app". So if anyone have the same issue please check for the red folders or swift files in their xcode.
Unticking the 'Find Implicit Dependencies' tick box solved it for me. Hope this helps.
I had the same problem in different projects in the last few days.
In one of the projects, a solution had to delete the .xcproject subproject file.
In another project, the solution was to uninstall .xcworkspace (I use cocoapods) and run pod install.
Thanks for the old answers, I have solved the problem by keeping "Skip install" of frameworks to false.
My XCode is with version 13.2.1. One thing special is that runner and framework in my project are in different schemes. Hope the picture will help newcomers.
I got the same issue, I tried skip install setting it with "No" didn't work for me.
I removed the script added for swiftlint in build phases then it works fine.

Xcode UITest Record button is disabled

Has anyone seen this happen before? I can not run UITests because the button is disabled. I have not found any help online. I have deleted and added a new test target, restarted Xcode and deleted derived data. None of these worked and I have no idea what to try next.
You have to create a new target in your project.
Steps:
1) File > New > Target
2) Select in left box: iOS > Test
3) In right box: iOS UI Testing Bundle
4) Run your aplication
5) Record your actions
6) Make assertions
Another possible cause could be that the UI testing target was not build/run successfully.
Go to Product > Test and make sure no errors. You should also see the test cases in the Test Navigator (if you don't see, then it is not recognised).
I had the same issue and finally found a solution.
Write a new UI test in a file which is linked to the UI test target.
In the new test write XCTFail("") (which will fail the test)
Run your UI tests and they should fail.
Remove XCTFail("") you added and the red button is now enabled.
For me it was Deleting ~/Library/Developer/Xcode/DerivedData/ as above, and letting Xcode reindex the project, but I had to make sure to not interrupt the index. Indexing took a while, and if its interrupted, it seems to not pick pack up where it left off. At least for XCUITest targets.
Try to delete
~/Library/Developer/Xcode/DerivedData/ and let xcode to reindex your project. This should do the trick
Make sure the name of the UI Test file is the same as its class.
I just fixed this by commenting out a failing test in my test class. Ran the test so it's green, and then put my cursor on a new line (below commented out test), and the Record button is red again.
You can have other failing tests in your app, but not in the file that is active in Xcode.
In Xcode 9.0
Click inside test function. You should select test method first. Usually when the button is not active, that means that xcode does not know which test to rec.

Adding test target to an existing project is not working

I need to add test cases to an existing project, so I tried adding a new test target via
File -> New -> Target -> Cocoa Touch Testing Bundle
From the test navigator filter bar.
Even after adding, the target is not getting listed in the test filter bar.
May be because of this issue, Product -> Test option is diabled in my project.
Also I could see some differnce between the build setting in my project and another sample project I started in Xcode 6.1 in which Product -> Test option is enabled and everything working fine for Test cases.
Please find the build settings screen shots.
Any help is appreciated.
I had this exact problem. It turns out my existing project was creating my Cocoa Touch Testing Bundle with the .app extension when it should've been a .xctest extension.
You can fix this by going to your test target you created. Build Settings > Wrapper Extension and changing it from app to xctest.
You may have to restart Xcode after this change to select your test target.
UPDATE: I found out the reason the Testing Bundle was becoming a .app extension in the first place. I had to go to the main project Wrapper Extension and make sure it was blank instead of .app. Apparently that was forcing all targets to become .app extension as well.

Xcode 6 ignoring breakpoints - Swift

Xcode 6 is completely ignoring my breakpoints. I saw a post here from 2008, but the answers are outdated, and don't seem to work.
EDIT:
This is happening only with projects that I start. All my downloaded open source projects work perfectly fine, as well as projects I started a few months ago.
UPDATE:
This is what I get when I create a brand new project and set a breakpoint in viewDidLoad
After trying many different things, I ran
defaults delete com.apple.dt.Xcode
This reset my Xcode settings. Now when I create a new project, breakpoints work fine.
I realized that the problem happened when I added Cocoapods to the project. B/c right after I ran pod install, breakpoints stopped working. I'm not sure why.
Hope this helps anyone with the same problem
I had a similar issue when I added a target to my project. Breakpoints placed in that target were ignored.
The solution was to set "Debug Information Format" in the new target's build settings to "DWARF with dysm"
In XCode 7.1 it defaulted to DWARF
There can be various culprits for this, a common one being setting the build scheme to Release instead of Debug.
For me it was the Debug Optimization Level set to -O0 in my target's build settings. Changing it to "Fast [-O, O1]" makes Xcode breakpoint-respectful again.
There is an interesting post about it here:
http://blog.credland.net/2014/03/xcode-debugger-why-do-you-stop-working.html
Close Xcode and remove the derived data and then reopen Xcode it will work

Xcode lost button test in xctest

I working on Xcode 6. When I coding XCTest, Xcode has been crash. When I reopen my Xcode, and it lost little diamond run button.
It should be:
But it got:
I open other project and it don't have this error. But when I create new target, it get same error (in other project).
I checked Target Membership, but it checked in target name. When I choose Test in Product>Test it run but the button not show.
Thank a lot, sorry for my bad english.
Prefix func name with test
Also try changing the targets
Click on the test file (unit test or UI test file)
Go to right panel and you'll see Target Membership.
Select the Unit Test target and all would be good to go.
There is two way to check it.
If you have multiple scheme, In top of Xcode, make sure you choose Test to run the test.
Click on your test class, then click right panel. In target membership, checklist the tests target.
In case you disabled indexing earlier,
Close all Xcode and Simulator instances
Delete this setting
defaults delete com.apple.dt.Xcode IDEIndexDisable
Restart Xcode
This should reenable indexing and should bring back the individual test button (diamond shaped) in the subsequent Xcode launch.
My issue was file was not included in the workspace. If not included, go to finder and drag and drop to that folder.
In Xcode 12.4 just Command+U or menu Product > Test and all buttons in your XCTestCase will appear again.
A possible answer for some - I had added a new scheme in Xcode, but the tests were only in the original scheme. Switching back to the original scheme re-instated my tests.
I just re-started my Xcode and it worked. as everything was set-up the way it should be !!
Prefix func name with test
example test function name:
secondExample() must be **testSecondExample()**
then clean the build file
use this shortcut key command + shift + k
Need More description?
But Try following troubleshooting...
check Target Membership of test file
Go to,
Xcode > Window > Projects
click on the delete button for derived data. Close Xcode and open again. You should be good to go.
Solution that is working for me in Xcode 13, SWIFT 5:
Open another Xcode file and then open the file wth your function again, the button should appear then.

Resources