Moving Project file in Xcode Interface Builder - objective-c

I have somehow managed to get the Xcode project file for "My System" in a different folder from all the other project files. Everything works but is there an easy way to get the files together in one folder (ie. either by moving "My System.xcodeproj" into the lower folder or moving all the other files up with it in the higher folder.
If I made this change, what parameters I would need to change inside Xcode.
I'm using Xcode 11.3.1 on Mojave and Objective-C (no storyboard).
I'm not sure if it is worth moving these or whether I should just leave it.
File and Folder Structure:

The arrangement shown in your screen shot of the Finder is correct: a project folder, containing the project file (xcodeproj) along with a single folder that contains the actual code files. That is the standard. Don't mess with it.
Actually you shouldn't even look at it. Look at your project through Xcode, and let Xcode worry about where the files "really" are. Under no circumstances should you touch any of these files in the Finder or you will risk breaking the project entirely.

Related

Changing directory on mac affects all files in Xcode Project

I simply wish to change the name of a folder that lies in my root project folder.
I have changed the name of a project (say from Proj1 to Proj2).
I now have a folder on my desktop that reads Proj2. Inside is Proj2.xcodeproj and a folder called Proj1 with all of my source files and resources.
I want to change that folder to be consistent and read Proj1, however if I change it every file in my xCode proj becomes red.
Is there a technique to change this folder within xCode such that I can rename the folder and keep all my files intact with the appropriate structure (such as what groups the files are in)?
It's annoying, indeed.
However, there's no way to keep files on the hard drive (SSD, ..) and group names and the project structure in Xcode in sync automatically.
You can re-assign the locations of the files in your red folders manually to fix it.
Wish Xcode would offer a feature like this since we've switched to Xcode from MW CodeWarrior, but..
After you rename the folder, open the project in Xcode and select this folder. You can choose the renamed folder in the File Inspector Pane.

XCode copies only changed xib files to the target binary

In my project I have almost 30 xib files located in an en.lproj folder and henced listed as english localization in XCode. When I compile my project, however, these xib files are not copied to the target folder (Resources/en.lproj) unless I modify them. All other resources are always copied, regardless of their change state. Of course all the xib files are in the "Copy Bundle Resources" build phase (along with a lot of other resources like images).
This behavior gives me some trouble, e.g. when I manually remove the .app from the DerivedData folder. The app is rebuilt completely on next build in XCode, only the xibs are all missing until I touch all of them.
How can I solve this problem and make XCode always copy my xib files too?
Seems to have been fixed with one of the latest XCode versions. I just checked with XCode 7.1.1 and the nibs are copied regardless of their change status, if they don't exist in the target folder already.

Files removed from Xcode project, but still available in game

My cocos2d-iphone project has tiled maps (.tmx files along with .png textures).
Recently, I deleted all the .png textures in my project (in Xcode, you hit the delete key and then choose to send to trash).
Then, I ran the project, and it tried to load up the CCTMXTiledMap. I was expected it to crash (there shouldn't be any textures in the project, anyway), but it didn't. In fact, it ran just fine, and the maps did load. No idea why - is Xcode keeping some kind of reference to such files somehow?
I checked the .tmx file, and this is the line that defines the source image:
<image source="myMap-hd.png" width="973" height="1024"/>
There definitely is no myMap-hd.png nor myMap.png file in my project folder. Not even Xcode's search toolbar shows it!
Oh, and I also cleaned the project.
As I wrote in question's comment. Problem was not in your Xcode project. Deleted resource files will most likely be still available on device/simulator if you had run application with these resources previously. The reason is that Xcode doesn't track files that are in application bundle, they're just simply copied. That's why they land in Copy Bundle Resources build phase.
You should delete application from device/simulator and run it again. Or if you have precious data already in application, you could navigate to application bundle and delete file manually. Files won't appear again.
In the simulator, iOS Simulator (menu item) > Reset Content and Settings. Clean your project, then run again. Same thing happens without cocos2D.
I've found this to be an issue when nib files are automagically loaded, and while not in the referenced files seem to still be loaded (or attempted). Can cause some brain pain bc the files don't appear in the Xcode IDE though they do exist in the file system.

Moving .lproj file inside Resources

I'm trying to begin localization on a project, and I've already got an English version of Localizable.strings going. I'm now trying to add French to that file, which is creating an fr.lproj folder, as I'd expect. However, it's putting it in my project root, and I'd like it inside my project's Resources directory.
Xcode seems to have no interest in letting me move the file, and if I move it in Finder, it goes red in Xcode as expected, but doesn't let me click to locate the file.
I've tried moving it in Finder, then editing project.pbxproj in a text editor to add Resources/ in front of the only line in there that mentions fr.lproj/Localizable.strings, and that has worked, but after doing that, the project's targets also turned red in Xcode, and building the app doesn't change that fact. Very odd.. any idea what could be going on, or how to get this going?
This can be a real pain. I even had XCode crash on me when trying to correct unwanted file locations. I found that the best way is to create the localized file (be it .strings or .xib) as a copy of the source language version outside of XCode, then drag and drop it into XCode. If you do this then XCode will display it correctly and your targets' Build Phases > Copy Bundle Resources settings will include it with its correct location. I don't know why your targets are displayed in red, perhaps you could look under Copy Bundle Resources in case anything is wrong there, or also select your project and click Validate Settings in case you haven't already done so.
Also, if you have been testing in the simulator beware of how XCode does not clean up the files in your app bundle--you may want to delete the app and run it again to make sure it's working with your new location.

libcocos2d libraries.a & PROJNAME.app missing

I have this new project created via the cocos2d 1.0.1 template in Xcode and I was copying over files from the project whose cocos2d engine is outdated (it's dated to 99.4, but it didn't have a CCSpriteBatchNode, instead using CCSpriteSheet) and I was rearrange files around into folders that matched the setup of the old file.
One of the folders is Products, which I stuck in the 'Code' folder. However, the two files within this Products folder have gone red:
MyGame.app
libcocos2d libraries.a
meaning they're undefined, and I need help solving this conundrum, I'm very new to paths and directories. Here's a screenshot:
http://i207.photobucket.com/albums/bb289/teh_Mac/Screenshot2011-12-21at90907PM.png
After you created the new project, you should only add source code files and resource files to your project. There's no need to recreate the Products folder.
Besides, the .app and .a are files that are created during the build process. Until you've made a successful build, they will remain in red. And even if the build was successful they may remain red due to bugs in Xcode.