In xcode 5, there is no option for creating unittest project while creating project. I want to delete the unitest target after the project is created.
There is no target list I can right click, I can chose target to edit but not able to delete. I know it should be really basic and really simple. But I google it and play around for almost half day, still confused.
Can anyone help?
Thanks,
You probably just hid this menu with the arrow in it:
In Xcode 6 its different as to how to delete the target. See these pics.
Related
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.
With XCode 6.4 I could easily clone an existing target. However this functionality doesn't seem to be available in XCode 8.x.
Does anyone know how to do it?
Select your target, right-click on it, then select Duplicate.
As you can see - the project now has 2 targets:
I could not figure out what I was missing. The above answer is missing a step. The panel where you can duplicate targets is probably hidden.
Click the side panel button to see the targets.
Now you can see the targets and right click to duplicate, then just click on the name and rename it. Much easier.
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.
I am trying to rename the class name in swift but it gives me error Can't refector swift code. I want to know the best way to rename a file that will reflect in the whole project
Currently you can't refactor in Swift. However, you can do Find menu > Find and Replace in Project. (Carefully)
Edit: Xcode 9 allows you to refactor.
Highlight your property/function and choose Editor Menu -> Refactor -> Rename
Wait a second or two for Xcode 9 to scan your project for all occurrences and then type the new name.
Now it's possible in Xcode 9.
Right click on class name and choose Rename.
After doing what #Caroline has pointed out, you should also change the name of your .swift file because it does not change using Find > Find and replace.... For doing that, you can click on the name of a .swift class and rename it as you want.
I am using XCode 8 and it is the best option I could find to change the name of my class in the whole project.
EDIT, The Latest Solution:
Starting Xcode 9 you can now do it easily. These are the steps:
Highlight the code that you want to rename
right click and choose refactor -> rename.
Or you can also use the Editor menu on top of the Xcode and choose refactor -> rename. Done!!
Old solution for XCode 9 and below:
click Find -> Find and Replace in Workspace
Rename it, for example I am renaming ChatViewController with ChatVC then hit Enter. This usually rename the naming in storyboard too, So it's really convinient, but just double check if you want to really make sure it's changed.
Lastly, Dont forget to rename the file itself in the project navigator
With Xcode 9, to be released in fall 2017 - Developers would be able to -
1. Refactor their Swift code.
2. Rename Swift project classes.
3. Run multiple instances of the simulator at once.
4. Run and debug on physical devices wirelessly.
5. Access, pull, push and commit to Git directly from XCode.
My personal favorite is the way issues are highlighted in red in multiple lines completing the sentence of the issue.
This WWDC 2017 session is a good view
XCode is getting smarter for us.
Find & Replace by cmd + shift + F
Rename class name.
If you use storyboard/Nib file, don't forget change the class you assigned in Show the identify inspector to new class name.
TIP Set scope under the search field for Find & Replace can make this work clear.
AppCode by Jetbrains can refactor/rename both Swift and Objective-C classes quite easily;
It's not free but it does a great job.
If you are facing similar error I was facing, where an error pops up when I choose the rename menu, just build the project and try again.
It seems like the Xcode needs some kind of parsing table to refactor the class name.
For some reason my Xcode project doesn't recognize (autocorrect) my code. It doesn't color-code text except for NSStrings (in red). It doesn't autofill things like it used to (e.g. if I would type "CGR" it would put in "CGRectMake:(x,y,width,height)" but not anymore. I don't remember at what point this started happening but it does work in my other projects. Any ideas?
BTW, deleting the derived data doesn't fix it. Nor does creating a new project and importing the files.
this issue has happened to me, I give you 3 sulutions, you can try them.
Solution 1:
Open xcode;
Open Organizer (Xcode-> Window-> Organizer-> Projects)
Select your project and right click, then remove from Organize...
Close xcode and reopen your project.
Solution 2:
Open your project.
Targets -> Building Settings, set Precompile Prefix Header = NOï¼›
repeat solution 1 (Sometimes the Precompile Prefix Header occurs a issue).
Solution 3:
Using commandline.
cd YourProject.xcode
Delete items except project.pbxproj
Good luck.
Hah, figured it out! For some reason my project was split up in different folders. I.E. it was one folder with all the images, another with ViewController.h and another with ViewController.m. Moved all the files to the highest folder in the hierarchy and everything works great :) Thanks for all your help though!
I suppose it would be too easy for your text editing preferences to be wrong? Command-comma -> text editing.