Ignore "Attribute Unavailable"-Warning in Xcode4 - cocoa

I'm using a lot of "custom identifiers" for Toolbar Items, which is fine in Xcode4, but it gives me a bunch of warnings when I build the project:
Attribute Unavailable
Custom Identifiers in Interface Builder versions prior to 3.2
Is there a way to ignore these warnings in Xcode4? It's pretty messy when I search for "real" warnings and errors.

Click on your xib file. On the properties you will see the following section:
.
Where it says "Development" change that to Interface Builder 3.2 and you should no longer receive those warnings.
UPDATE for current iOS Xcode users:
In iOS 4.3 - IB is built into the IDE, and on the right after selecting the xib file there will be some icons, the first icon is called "File Inspector" (looks like a page with a fold in it) that is where the section resides (see below).

I am running Xcode 4.2 build 4C199.
Click on xib file,
on the right, click on Utilies View
Click File Inspector. As tony.stack mentioned look under "interface BuilderDocument"
set Deployment = "Project SDK version"
set Development = " xcode 4.2"
Even if you are running xcode 4.2, the Development is set to default 4.1, So you get that warning.

Have you tried looking at the "Document Info" window in Interface Builder? You can set supported versions there.

Related

Compiling Swift source files

When I run the Project, Xcode is always show the message "Building AppName | Compiling Swift source files", without anything. How can I know What wrong with project? thank you!
enter image description here
Xcode Version:7.1.1(7B1005)
It's because your Xcode has option enabled Automatically Refresh Views. To stop that:
Open any XIB or Main.StoryBoard in your project.
From the top Menu bar, select Editor > Untick Automatically Refresh Views option.
From now onwards, it will stop refreshing view.

The selected device specifies an unsupported architecture

I'm trying to launch an Objective C app built on Xcode5 on Xcode6 beta (Version 6.0 (6A215l)). I get the following message when trying to build for any platform except for iPhone 5s:
Xcode cannot run using the selected device.
The selected device specifies an unsupported architecture.
It's not even obvious how to begin troubleshoting this as I can't get to the point where the console is activated. Any pointers?
I just had this myself.
I tried a few things (closing simulator before running, having it open, resetting), but what seemed to fix it was a simple clean, build and then run
If that's not it then I have a couple of other things I did but I don't think they were responsible
I was getting the same issue when the Xcode-> Targets-> General-> Deployment->Devices selected is iPad. but I am going to run this project on iPhone. check your project.
I bumped into this issue after changing the Executable file field in the info tab of my target settings - changing this back to the default ${EXECUTABLE_NAME} fixed it for me.
I was getting the same issue and no amount of cleaning solved it. I had to remove all Swift files from my project. Then I re-added them, but made sure to unselect the "Add to Target" option in the file add dialog. Finally, manually added them to the "Compile Sources" section of your project's "Build Phases". This did it for me. (Also make sure no Swift files end up in the "Copy Bundle Resources" section of Build Phases).
Close simulator if it is opend
Press Command + shift + k (or clean the project by selecting product menu item from xcode menu) and then press Command + r (or run the project)...
iPhone3gs-->iPhone4s:armv7
iPhone5/iPhone5c: armv7s
iPhone5s --> iPhone6Plus :arm64
add architecture to BuildSetting -> Architecture

The document "XXXX.xib" could not be opened. Could not read archive

After opening my project in the Xcode5 developer preview, errors appeared against a few .xib files when I tried to open the project in Xcode 4.5. The error text was:
The document "XXXX.xib" could not be opened. Could not read archive.
Please use a newer version of Xcode. Consider changing the document's Development Target to preserve compatibility.
The project's development target in Xcode5 appears to be iOS 5.0.
Looking at the source code of the .xib files with errors, it is clear that the .xml structure for .xib files in Xcode5 has changed quite dramatically, and it needs to be reformatted to be backwards compatible.
Is there a way to set development targets for specific .xib files? Does anyone know how this error can be resolved?
Many thanks.
Just open Storyboard in XCode 5, into right panel and "File Inspector" tab do:
edit your "Interface Builder Document" like follow:
Save it and open in previous XCode.
First of all open project with Xcode5. and then
select XXX.xib find Interface Builder Document
Opens in Xcode 4.6(if is 5.0)
close project
open it with 4.6
A better and easier solution that works even if your project isn't under source control can be found here (mine):
Just installed xcode 5 and have missing storyboards
Hope that helps.
It's a current problem when you open your Xcode 4.6 project with the new XCode 5.
To reuse correctly your XIB with Xcode 4.6 :
1 Open your project with XCode 5
2 Select your Xib to restore
3 In the File Inspector Section, in "Interface Builder Document",
select Xcode 4.6 in the Development's version of Document Versioning
4 Build and close
5 Reopen your project with XCode 4.6
It's possible to have some regression with elements width & size in your XIB, but it was restored successfully.
Cheers,
well obviously you created your project prior to the new xcode developer preview. then you tried opening your project with the new DP and boom, it automatically changed everything in your xibs to be able to present your xibs in a higher version. easy to fix. with your xcode 4 ios 6 open the same project, then right click on the name of the xib that is not opening and select source control and from there select discard changes. that should return the xib back to the shape it was before you opened it with the new xcode DP.
let me know if you need more help but that should take care of your problem.
First you have to open your's project with newer version of Xcode.
Right click on XXX.xib file and select "Show File Inspector."
Go to Interface Builder Document.
Change Development option with older version of Xcode.
Once I used to manage a project with XCode 5 xibs in XCode 4. I split xibs for each XCode version and made this build script that compiles xib to nib and place that nib them inside the app
#get SDK version
SDK_VERSION=$(echo $SDKROOT | sed -e 's/.*iPhone\(OS\)*\(Simulator\)*\([0-9]*.[0-9]*\).sdk/\3/')
if [ $SDK_VERSION == '7.0' ]; then
echo 'Current SDK is 7.0'
ibtool --compile ${TARGET_BUILD_DIR}/${TARGET_NAME}.app/output.nib ${PROJECT_DIR}/ProjectFolder/input.xib.xib
echo 'Copied nibs to' ${TARGET_BUILD_DIR}/${TARGET_NAME}.app
else
echo 'Current SDK is not 7.0 (SDK is' $SDK_VERSION')'
fi

How can I disable a warning in XCode that is in an xib file

I found a few answers for doing it in code files, but my warning is coming from interface builder, and it is silly.
Attribute unavailable: Defines Presentation Context is not available prior to Xcode 4.2.
I am using Xcode 4.2. Why would I possibly care about this warning? Lots of things don't work in Xcode 0.01. This is day one of a new project and I don't want to spend the whole time violating the no-checking-in-with-warnings rule.
Select xib file; in the Utilities pane (on the right), under File Inspector tab, find "Interface Builder Document" section; change the Development property to "Default Version (Interface Builder 4.2)".

Localizing in Xcode 4 with Localizable.String

I just updated to Xcode 4.
Normally when localizing apps we add "Localizable.String" file to the project, and then navigate to "Get Info" menu and click the "Make It Localized" button.
However, in Xcode 4, there is no "Get Info" menu.
When I try to add a language it only effects the "InfoPlist.String" file (which can only localize the app's name).
How may I add localization to my app in Xcode 4?
It's simple once you understand it.
If you want to accomplish this with Xcode 5.x and iOS 7 or Xcode 6.x and iOS 8, check out "How to localize my app with Xcode 5?" instead.
I liked SNR's link, but his answer was a bit short.
Also, I see that this question is a bit old, and my answer may be different from older versions of Xcode. (I used Xcode v. 4.3.3)
However, i have updated my answer to work with both Xcode 4.3.5 and below + 4.4 and above (and Xcode 5.x and 6.x here: How to localize my app with Xcode 5?).
To begin you should add a new "Strings File" in the iOS Resource category.
Next, create the file as "Localizable.strings".
When the file is created, select it and open File Inspector .
EDIT: Things have changed (a bit) with the new Xcode 4.4, 4.5 (and above) (for iOS 6 support).
If you'r Not using Xcode 4.4 or above, joust skip this step.
{ The Xcode 4.4, 4.5 (and above) way:
Click the "Make localized" button
Now head over to your Main Project page.
And click the "+" button under Localization, and select the languages you want to support.
(I'll select German / Deutsch)
Now a window will appear asking you what files you want to localize, make sure Only the "Localizable.strings" file is selected and click Finish.
}
{ The Xcode 4.3.5 and below way:
Click the "+" button under Localization, and select the languages you want to support.
(I'll select German / Deutsch)
}
.
.
.
.
You should now see that you have two files under the "Localizable.strings" file.
Next, add your localization strings inside both of the localization files.
Now here comes the coding part.
Here i'll simply declare a UILabel and set it's text to the Localizable file string.
Declare:
IBOutlet UILabel *testLabel;
And Inside ViewDidLoad i'll set the text using NSLocalizedString:
[testLabel setText:NSLocalizedString(#"TEST", nil)];
To finish up, just connect our testLabel in "Interface Builder".
Now you should be able to run the Project and see the localized string.
And if you change the language, you should see the localized string change as well.
Select the file you want to localize and klick on the file inspector in the utilities section.
There is a section Localization
You can view the file info (and add localizations) when you select the file and open the "File Inspector" via the main menu's "View" -> "Utilities" -> "File Inspector".
first you need to add new Localizable.string file and select it and go to View" -> "Utilities" -> "File Inspector click on + button to add language in localization section.
also check it XCode 4, Adding localization
the way of Localization in xcode4 has changed! right click the localizable.strings, and to add support for another language, simply click on the ‘+’ in that ‘Localization’ pane on the right.
You can take advanced of the User Defined Runtime Attributes:
http://cupobjc.blogspot.com.es/2014/04/interfaz-builder-localization.html
First define a new category for UILabel:
#import "UILabel+Localized.h"
#implementation UILabel (Localized)
-(void) setTextLocalized:(NSString *)aText{
[self setText:NSLocalizedString(aText, nil)];
}
#end
Then in the interface builder, User Defined Runtime Attributes :
textLocalized String your string to localized
And you don't need to declare the IBOutlet,
and don't need code this in the ViewDidLoad [testLabel setText:NSLocalizedString(#"TEST", nil)];
If you want a dynamic way of switching languages inside your app AND using a Pods based solution check out:
https://github.com/nullic/DPLocalizationManager
Install with: pod 'DPLocalization', '~> 1.2'
It supports the same standard localization files but also uses dynamic linking using User Defined runtime attributes and also inside code such as viewDidLoad.
Some examples in the example project:
self.startup.text = DPLocalizedString(#"TITLE", nil);
self.label.autolocalizationKey = #"LABEL_TEXT";
[self.label updateAutolocalizationArguments:#[#"Hello", #1234567890, [NSDate date]]];
self.autolocalizationKey = #"TITLE";
Download the git project that includes example project showing several examples.
Or you could use TraductoPro to automate this process for you and save a lot oftime. It is a Mac app that integrates well with Xcode.

Resources