XCode 6: The custom class and the several project targets - ios

I would like to have both DEV & PROD versions of my app working on my iPhone at the same time.
So I created a new target AppNameDev with a different bundle identifier.
When I launch the app on my iPhone, I get the error :
Unknown class _TtC4Wesh10InviteCell in Interface Builder file.
My custom class InviteCell is not found by the new target's interface builder. How to tell it where to find the class ?

When you click the InviteCell source file check from the File Inspector on right that both targets are checked. Or that the file exists in Build Phases - Compile Sources for both targets.

You need to click "InviteCell" class file from left side on Project Navigator and then go to "File Inspector" and click both targets (DEV & PROD) from Target Membership on the right side. I hope that helps you. For example:
Pro Tip: If you are planning to create a new file, make sure to select both DEV & PROD version targets before you click to "create" button. It will save you a lot of time because you don't have to go back and forth.

Related

Cannot load underlying module for 'XCTest'

Every time I start to run my app, or I'm just starting Xcode I get this error:
I think the problem is that I don't know where my .xctest files are. I think I maybe deleted them.
Would be very nice if someone of you could help me! Maybe tell me how to recover these files, make some new one or something else.
You accidentally added one of your Xcode Unit Test files to your main app target.
Remove it:
Select test file
Open right side panel
Select Identity and Type tab
Unselect your app Target (not the unit test lego icon)
Tip:
Next time you add a new unit test, only add it to your unit test target. If you accidentally include any of your app targets, they will not have the XCTest framework available.
See also Apple Technical Q&A QA1954 'Cannot load underlying module for XCTest' which covers several variants of the issue
https://developer.apple.com/library/archive/qa/qa1954/_index.html
The main project does not link with the XCUnit framework. You should create a separate testing target for your project, if one does not already exist, and add your test source files to that target.
Select your project in the Project Navigator. This will open the project's settings in the editor.
Click the "+" button at the bottom of the column listing your Targets.
If you are working on an iOS project template, select iOS > Test > iOS Unit Testing Bundle.
If you are working on an OS X project template, select OS X > Test > OS X Unit Testing Bundle.

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)

Creating custom framework in iOS

I am trying to create my own iOS framework for my project. I am following the below link to create it:-
Creating custom framework in iOS
I am not getting any error as well as warning but not able to see the content of Product folder generated during project creation.
I am facing problem in this step:-
To build, select the target as iOS Device and press cmd+B to perform the build. Once completed, the libRWUIControls.a product in the Products group of the Project Navigator will turn from red to black, signaling that it now exists. Right click on libRWUIControls.a and select Show in Finder.
Looking for all yours help and support on this.
Suppose you are using Xcode 6, and Apple has provided an easier way to create a custom framework.
You can refer to some instruction on How to create an iOS Cocoa Touch Framework using Xcode
And you may still encounter some problems while using your custom framework in your app.
Here are 3 tips to solve the problems you may face.
Add your public headers:
In your custom framework project, please select TARGETS->Build Phases->Headers->Public, and drag and drop your headers here.
Build a static library framework:
In your custom framework project, please select TARGETS->Build Settings->Linking->Mach-O Type, and select it as Static Library.
To fix Xcode “Missing Submodule” warning while import your custom framework in your app:
Please refer the solution here.
Enjoy your own framework.
There are several parts to this "step"
Assuming since frameworks are fairly advanced that building is not your issue.
This tutorial uses multiple targets. To choose which target you want to build you must select it from the drop down menu at the top left of your Xcode window. This is immediately to the left (and loosely tied to) the drop down for choosing the device/emulator type. The target selected in the drop down becomes the active target and will respond to the build menu and shortcut keys.
Once a target is built the object created by the build will be displayed in the XCode Project Navigator inside the folder named "Products" In the default view the left most panel in XCode is the Navigator panel. Selecting the folder icon at the top of this panel will display the Project Navigator and the projects file structure. This is where you will find the Products folder containing your newly created file.
If the file is still red then the build did not complete correctly.
If it is black then you can right click on the file and choose "Show in Finder" to see the file.
If the file remains red or as an alternative to finding the file location you can use the build log.
To show the build log - in the Navigation Panel select the "Report Navigator". This is the right most icon at the top of the panel and looks like a cartoon text bubble. In the Report Navigator highlight the "Build" Entry associated with your static library. You can now review the build log to determine why the target didn't build correctly or if it did build correctly you will see an entry near the end of the log showing the path of build files.

renaming classes in iOS

I am working on Xcode 4.3.2 i wanted to rename my classes so i used refactor>rename, but after that i changed my mind and decided to go back to the older name. But when i do the same thing i've done before again, a warning dialog appears saying:
yourclass.h is not part of the build phase of any targets in this workspace and so can't be refactored. add the file to the build phase of a target in this workspace, or make a selection in another file.
what's the build phase? how can i solve this problem?
Thank you very much
It may be worthwhile to delete the projects derived data
Organizer --> Projects --> hit the delete derived data button for the project in question
Quit XCode
Open XCode
Build project. This will re-index your project and has been known to fix various environment issues such as
code sense
auto complete and
copmpiler targets
In Xcode, select your project at the top of the file tree on the left hand side.
From there, select your target, and click the "Build Phases" tab. Make sure the .m file of the class you're wanting to rename is listed under "Compile Sources"
You could check if you have the file here:
Targets => Select the target which is the select target your scheme is trying to run => Tab Build Phases => Compile Sources
Check if there is something wrong there (like file in red).
xCode usually takes snapshots when you rename the classes through the re-factor option .. you can go to File > restore SnapShote .. and choose the snapshot you want retrieve to and you will get back all the changed names.
In my case the .m file was under the compile sources. I did clear the project derived data and restarted xcode but to no avail.
I figured out though, that attempting to refactor the specific property in the .m file worked and renamed the property both in the header and the rest of the project references.

Xcode 4.3.1: Unable to open documents of type iPad XIB

I have just upgraded to Xcode 4.3.1 and SDK 5.1. My project uses storyboard but has one nib/xib file. After the upgrade the compile fails with:
/* com.apple.ibtool.errors */
/Users/jhn/Udvikling/Projekter/rmtelemedicin/RMTeleMedicin/RMTeleMedicin/MenuViewController.xib: error: Interface Builder is unable to open documents of type iPad XIB.
Recovery Suggestion: Ensure the plugin for the iPad XIB document type, from the corresponding SDK, is installed.
Any one seeing the same problem?Any help would be appreciated.
I figured it out!
Go to your project settings, and delete the line that says Interface Builder Plugin search path or something similar.
the exact line in project.pbxproj is:
IBC_PLUGIN_SEARCH_PATHS = "${PROJECT_DIR}/**";
That's it.
I had this problem too. I just created a new project and copied all the source/xib/resources files to the new project. Hope it helps someone
To fix this:
Press Command-1 to go to the project tree
Select your project
The in the right panel select your project, and then click on "Build Settings"
In search field just below the "Build Settings" enter: "Overriding Plug-In"
Now, the only visible setting left should say "Overriding Plug-In and Framework Directory"
Double-click the value and remove all entries using "-" button
Click somewhere else so settings are saved
That should fix it

Resources