XCode: Can I delete test target? - ios

What would happen if I delete the test target for my app? Would this affect my other target? How would I go about properly deleting the target?

Select '.xcodeproj' file from project navigator, then select 'Show project and targets list' icon, select 'target' to delete and then click '-' at bottom

If by test target, you mean a unit test target, then deleting the test target would mean you couldn't unit test the code in your project. Deleting the test target wouldn't affect the other targets in your project.
To delete a target select your project from the project navigator to open the project editor. Select the target you want to delete from the left side of the project editor and press the Delete key.

Related

Multiple Targets in Xcode: "File not found"

I am having a single project file. Then I created another target for a "Lite" version. I changed the bundle ID and product name for each target and am able to continue working this way.
But when I added a new custom class to the project, I try to use the class in existing VC by #import "NewClass.h" but it only works on one target, on the Lite target, it says:
File not found
Why is this and how to solve it?
While adding any new file and if you are working on multiple targets and you want that file in both the targets then you need to check both the targets while adding file
Check screenshot
You need to add the file to both the Target, so it can be accessed.
Click on the file you have added and then go to the Utilities Area in the right and click on File Inspector. You will have section called 'Target Membership', please select the target from the list of Targets.
Alternatively approach :
Select the Target in which you are getting error then got to Build Phases -> Compile Sources and make sure the file is present there.
If you forgot to add a target when you creating a file, you can add later by selecting the file in project navigator and then check/uncheck the target(s) in the File Inspector (on the right)

How to use classes from another target for tests in XCTest

I use Xcode 6.1 to create a new project, and it comes with a Tests target. I am trying to use the classes defined in another demo target in the same project for tests. But how do I accomplish this (besides setting the class's target membership to both demo and tests targets)?
Go to the source file in question and press option+command+1 to see the file inspector, and then select the appropriate targets in the "Target membership" section. Or, go to the target setting, click on "Build Phases" tab and add it to the "Compile Sources" section.

Migration of OCUnit to XCTest leads to linker error

I've tried to migrate our OCUnit to XCTest. So I have 100% compilable project but I see next linker error:
Error:Undefined symbol '_OBJC_CLASS_$_XCTestCase' referenced from:...
My "Framework Search Paths" looks like this:
$(SDKROOT)/Developer/Library/Frameworks (non-recursive)
$(inherited) (non-recursive)
$(DEVELOPER_FRAMEWORKS_DIR) (non-recursive)
I'm not familiar what else to do to satisfy linker
I am seeing the exact same error messages in Xcode 6.1 after migrating with
Pull Down Menu → Edit → Refactor → Convert to XCTest.
I got 2 solutions:
Solution 1 (recreate test project)
Backup all source files in your test project.
In Project Navigator, select the project.
This shows the project settings.
In the project settings, click Show project and targets list.
Select the test target, and press delete to delete it.
In Project Navigator, select the test target, and press delete to delete it.
In Test Navigator, click the + button on the bottom left, and choose New Test Target.
Add your original source files back into the new test target.
Now test your project as usual.
Solution 2 (hackishly modify test project)
In Project Navigator, select the project.
This shows the project settings.
In the project settings, select the test target (not the main target), then select Build Phases.
In Link Binary With Libraries, click the + button.
This shows the list of frameworks, but there is no XCTest.
Choose a framework that you don't use at all, say, Twitter.framework, and click Add.
Open your project file (something.pbxproj) in a text editor, and replace all occurrences of Twitter.framework with XCTest.framework.
Note: the pbxproj file is inside the .xcodeproj folder. In Finder, you have to right click on the .xcodeproj and select Show Package Contents.
Go back to Link Binary With Libraries in Xcode, and check that XCTest.framework is added.
If not, try restarting Xcode.
If it is added but is red, just ignore it. Xcode can't find the framework, but the linker can.
Now test your project as usual.

Import XCTest in to existing project

I added a new target as a Cocoa Touch Unit Testing Bundle, named the directory "MyAppTests", and the actual framework is not active-- it is highlighted red
When I add the framework by the 'link binary with libraries' in the 'build phases' tab technique, a new Framework is added, instead of updating the one that was created with adding the target.
When I go to run the code, I then run in to all sorts of troubles, ranging from linking errors to other frameworks not being recognized.
How can I activate the XCTest.framework that was generated when I added target? Please help, thank you!
XCTest.framework is the bundle that Xcode uses to enable
#import <XCTest/XCTest.h>
To add test cases to an existing project select the target, right click > file > new > objective c test case class. Then in your build phases you can add the XCTest.Framework. Make sure you check the add to target boxes when creating the test case.

File in IOS bundle is not found in the simulator

I am working on an ios 6.1 application, that uses cocos3d, i have a file that is
certainly in the bundle, which is 'CC3TexturableMaterial.vsh', but at a point in
time when the applications needs that file, it crashes and shows the following error:
[***ERROR***] Could not load GLSL file '/Users/macbook/Library/Application Support/iPhone Simulator/6.1/Applications/3505ADEC-C70B-490F-9011-A433D85C2D66/3D.app/CC3TexturableMaterial.vsh' because it could not be found
Which implies that the file is not in the simulator's .app.
does anyone encountered a similar problem?
This can happen when the file isn't explicitly being copied to the bundle.
To check this, ensure that it appears within the "Build Phases" -> "Copy Bundle Resources" section within your project's build settings. (To view the main build settings, select "Project" -> "Target" from within the left hand pane).
Just open terminal
pod deintegrate
and then
pod install
Just Follow Below Step:
1)Select your project from the left panel.
2) Select the target and then select Build Phases
3) There you should fin a button called Add Build Phase (Bottom right side)
4) There will appear a box where you have to select the files (there's a little +sign). And be sure you selected Destination: Products directory
Build the project, run it and now it should work !!

Resources