Converting iPhone XIB to iPad version with Xcode 4 - xcode

With Xcode 3 in Interface Builder you were able to upscale an iPhone XIB file to an iPad version. However in XCode 4 I cannot find a way to do this. I would really prefer not to have to create the XIB again from scratch. Is there a way to do this like there was in Xcode 3?

This has been asked a few times, and unfortunately it seems (or rather, it's sure) that the option (Create iPad Version Using Autosizing Masks) has been removed from Xcode 4.
You will need to copy/paste the UI elements, and re-link them to your code.
OR: You are now allowed to install both Xcode 3 & 4 (simply choose a different folder to install it to). Since the nib files' format did not change, you can upgrade them in Xcode 3, and copy the converted files back into Xcode 4.

Related

Xcode Changes Contraints Of Layout By Itself After Reopening The Project

I set the constraints of layout properly and also tested it on every device. But the next time I open the project, Xcode just ruined the constraints totally.
How did this happen?
May be the project has a problem and for some reason it is not saving the changes. I have indeed put this solution on my troubleshooting book about Xcode from Apress (shameless advertising... 😃). I have seen this before.
Backup your project and try this:
Quit Xcode
Using finder, right click on the .xcodeproj file of your project and select Show Package Contents.
delete everything from that except the file project.pbxproj.
open the project again fix the constraints and see if the changes are saved the next time you open Xcode.
You did not specify you Xcode version, but my own experiences with code, that is developed using Xcode 8 Beta 1 to Beta 6: The problem may be caused by bug in XCode.
The explanation, if you use Xcode 8 Beta, could be:
New Xcode offers new storyboard-display logic, that shows different difficulties still in Beta 6
After fixing both constraints and frames automatically / manually, warnings come back again after reopening project
This problem moves from Xcode Beta 2 to Beta 6 after my own researches
Let's give Apple a little more time to fix the issues and let's wait until Apple releases GM Seed. It's only beta though

NSToolbar items hidden using xibs migrated on Xcode 7

We are using xib files to show a window + toolbar.
Compiling a Mac OS app with the latest Xcode (7 or 7.1) makes our toolbars items to be hidden for Yosemite 10.10.5, but it works fine on El Capitan.
If I click the area, the actions are taken, so only the labels and images are hidden.
I have recreated the xib file from scratch with Xcode 7.1 but the issue is still there.
FYI: going back in our code history, before Xcode 7 was launched, and compiling the app without migrating xibs to Xcode 7 the issue is not reproducible.
It seems that the issue was generated by a missing font which seems that broke the whole CoreText and that's generated the missing toolbar items. Really strange issue.

Images not showing in iOS 7.1 with XCode 6 / Swift

I have this ObjC code:
[self.myButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:#"%#-button", self.myObject.name]]
forState:UIControlStateNormal];
This works great with these combinations:
XCode 5, iOS 7.1
XCode 6, iOS 7.1
XCode 6, iOS 8
But when I port one single class of the project to Swift -- a class which is unrelated to anything that is happening in this code -- the images do not display in XCode 6 for iOS 7.1. It does work with XCode 6 and iOS 8.
I finished porting the entire project to Swift, so now the code looks like:
self.myButton.setBackgroundImage(
UIImage(named:self.myObject.name + "-button"),
forState: UIControlState.Normal
)
And it's still unhappy on iOS 7.1. Still no images. (The custom icon works, though.) Yes, I know this is just beta software, and it's probably just a bug ... ? But I'm just wondering if anyone has a solution or insight.
I only started using XCode and ObjC about a week ago (surprise! ObjC is now deprecated!), so it could be that I am missing something, but since it works in ObjC, and in Swift+iOS8, it seems like it's probably a bug.
I've managed to overcome this by not using Asset Libraries to store my images.
Add your images to the project using the "old style naming", like Image.png and Image#2x.png, then load them without any extensions in the filename, as such:
let myImage = UIImage(named:"Image")
Fixed in XCode 6 beta 2
Images from asset catalogs in projects with a minimum deployment target of iOS 7 or OS X
10.9 will be available when running on iOS 8 and OS X 10.10, and now also iOS 7 and OS X
10.9. (17029658)
release xcode 6 beta 2 notes
For me it was because I suddenly add jpg image to Image Assets. Just resaved it as png and all work well
I guess you are testing it on simulator. Make sure the desired image is copied to 7.1 bundle. To do it check copy resources bundle build stage or check manually app bundles for different simulators at ~/Library/Application Support/iPhone Simulator/.
#o KB o points out here that the Xcode6 Beta release notes mention that xcassets bundles aren't supported for iOS7. Additionally, I've found it surprisingly hard to get rid of asset bundles in your project. This can cause naming collisions if your images have the same name as images that were previously in the bundle (you probably want the same names, so you don't have to rename your images everywhere in code / IB).
Here's a workaround:
Copy each image out of your .xcassets image bundle to a new directory (let's call it Images/). See below for a script to make this easier.
Delete your .xcassets bundle. (surprisingly, removing it from the project isn't enough. In my testing, if the .xcassets bundle was anywhere in the same directory as the Xcode project or related sources, it would get copied in. Alternately, you can remove the .xcassets extension)
Add all your image files to your Xcode project
Clean (cmd + shift + k)
Delete the app from the target device or simulator
Install and run
To make step #1 less tedious, I wrote a script to copy images out of the .xcassets bundle and into a directory of your choice: https://github.com/johnboiles/xcasset_exporter
mkdir Images
./xcasset_exporter.py MyProject/Images.xcassets Images
I had a problem where some images in xcassets worked and others didn't (only for iOS 7.1).
I solved it by deleting the problematic image sets and creating new ones with different names.
If you are attempting to use an external bundle with proper PNG images stored in either an "old style" folder or inside xcassets then apps running on iOS 7 will not be able to access these images.
I tried a suggestion from another answer here to add the "old style" folder path of the images in the external bundle but that didn't work for me. My solution, which fit my scenario, was to expose an outlet for the resource in the nib inside the external bundle. This allowed the main app to set with an accessible image to it. Whether this is a bug or simply a constraint in using nibs contained in external bundles with iOS 7 will matter less as it rides on to the usage sunset...
PS: Apps running on iOS 8 where able to access images in the external bundle xcassets just fine so choose your poison for supporting iOS 7.

Can you install the Xcode 5 Developer Preview in parallel with Xcode 4.6.2?

Apple announced the Xcode 5 Developer Preview today and I want to try it.
But before I download this, I want to know that what happen with my current version of Xcode (version 4.6.2)?
Will the Xcode 5 Developer Preview install as a different application or it will remove the old version? Will some common tools collide, like the command line tools?
The Xcode 5 developer preview comes as a normal app DMG (not with the usual packager/installer) and has a different name.
So essentially, you download it, open a DMG, then pull to the Applications folder and thence have two Xcodes there (the old and the new one called Xcode5-DP). It even comes with a slightly different icon (red badge across a corner) and the intro screen is different too, so there is very little chance of confusing them.
I already did that today (and a colleague also).
Now that xcode 5 has reached the first official release and is no longer in beta, you have to do ONE of the following if you wish to keep BOTH versions.
Run the dmg of the new version you download from developer.apple.com. Drag the app to applications, and when asked to overwrite click KEEP BOTH. This will rename the existing app to xcode 2 I believe.
Select your existing xcode 4 in applications. Rename it to xcode4 or whatever. Now you can drag in the new version without overwriting the existing one.
Drag the new xcode to someplace other than applications. Rename it and then drag it into applications.
I personally favour option 2, since going forward we'll be using xcode 5 and it's helpful if it retains the default name from the get go for easy updating.
BTW, if you do have more than one xcode installed expect the mac app store to report that you need to do an update. Probably best to install it by downloading it from the developer portal if this sort of thing bugs you.
Xcode 5 preview works fine with Xcode 4.6.2 or any other Xcode, It has different icon and it runs from its .dmg file (no install).
Pay attention you cannot submit an app with Xcode 5, So keep the old Xcode till Apple would release the stable version of Xcode 5.
Short answer: Dont replace XCode 4!
If you plan to deploy some app to appstore, you can't do it using Xcode 5 at this moment.
The best way is download the Xcode 5 version, unpack it and run the app on different folder (not application folder). You will stay with Xcode 4, and can run Xcode 5 separated (You don't need to 'install' xcode 5).

Can't find Xcode 3 launch icon - Running both Xcode 3 and 4

At first, I installed Xcode 4 on my Lion machine, but since I couldn't find an easy way to implement tables, I also got Xcode 3 (place it in a separate folder: /Developer/Xcode 3). I can't find the Xcode 3 launcher anywhere... Anyone had this problem before?
You'll find your Xcode 3 IDE in /Developer/xCode 3/Applications (correct name is Xcode, by the way -- unlike "xCode 3", which is how you had it listed before Kevin's edit).
And you can drag the icon to your dock to add it there. And then you'll have two Xcode icons in your dock. Good luck telling one from the other. ;-)

Resources