Xcode project not opening in Xcode 8 - cannot be parsed [duplicate] - ios

I think I have made a bit of a mistake here.
I designed an app a few months ago and even got it in the App Store. Since then I have purchased a new mac. I copied my Xcode project file across to my new Mac.
I've just come back to it for the first time in months and nothing opens. I sometimes get a cannot be parsed warning. Even looking at the file sizes I think there are all just empty files. When I try and open them in TextEdit they are just empty.
Any ideas anyone, I have a particular .swift file that I really need to open.

Check if the files are empty on your old Mac. If they are empty on your old Mac then the data has been lost, there is nothing you can do.
If the files are correct on your old Mac then something went wrong when you transferred the data. Therefore just try copying them over again.
If the first situation that I stated is true then there is nothing you can do.

Can you not retrieve the original files from your other Mac?
copy and paste
Would imply that you can. Maybe you should attempt to copy the files again, alternatively, if you just need the one .swift file you could probably copy the text from it and put it into plaintext and then copy that back out into a new xcode project if xcode is having such trouble opening that particular file.
Are you sure that you're not missing out some details? Seems almost too easy to answer this one.

Related

Image.file() Showing Blank When Specified File Was Explicitly Created

In the iOS variant of my Flutter app, when I explicitly create a .jpg file using
File(path.join(filePath, fileName))
..createSync(recursive: true)
..writeAsBytesSync(buffer);
the widget that renders the file (by calling Image.file(), passing to it the file as an argument) results with a blank image.
No exception was thrown indicating that the file was not found or file contents was invalid. Its behaving as if the file is blank, but when I browse to the file using Finder, the file is there and when I click on the image, Preview renders the expected image.
When the same code is executed when the image comes from the device camera or device gallery, it works and when the same code is executed in the Android variant with the file being explicitly created, it works too.
The only thing I can think of is that it has to do with creating the image deep inside my iOS simulator directory structure
ie-/Users/joselitope/Library/Developer/CoreSimulator/Devices/F2AE8082-E670-498B-B2C6-9A83BE1855A4/data/Containers/Data/Application/7B01A347-69AE-4A1F-8567-7FCC256013F5/tmp/comp_image_cropper_2CC9EEFB-A126-4811-BD80-485B4C41F3A2-18523-00001C049E5AAE85.jpg
but again, the file is visible using Finder so this may not be the reason.
Maybe I have to set certain permissions when creating the file in iOS or perhaps settings applicable to iOS in my pubspec.yaml?
All help is greatly appreciated.
My environment is as follows:
Catelina 10.15.7,
Flutter 1.22.5 channel stable,
XCode 12.3,
Simulator: iPhone 12 Pro Max - 14.3,
Someone posted a suggestion that prompted me to look into this problem again. (That someone has since removed his suggestion so I am unable to thank him.)
Anyways, when I tried to reproduce the problem it wasnt happening anymore even in the exact use case it was happening previously.
So the question remains is why and the only thing I ruled out that it wasnt a race condition as this code has been running on Android for quite some time on various devices.
This is what I could come up with:
Knowing the filepath I was writing to, I realized that I was writing to the app's /tmp directory which iOS periodically empties out. I am thinking that I shouldn't be putting stuff there. Instead, I've been writing to the app's documents directory and it hasnt happened since.
The initial /tmp directory was chosen for me by a package I was using and since it was so long and Im new to iOS, I didn't really look into it all that much, caring only that the file was there, which it was.
Anyways, keeping my fingers crossed that the fix sticks.

Cannot open Xcode project on a new Mac

I think I have made a bit of a mistake here.
I designed an app a few months ago and even got it in the App Store. Since then I have purchased a new mac. I copied my Xcode project file across to my new Mac.
I've just come back to it for the first time in months and nothing opens. I sometimes get a cannot be parsed warning. Even looking at the file sizes I think there are all just empty files. When I try and open them in TextEdit they are just empty.
Any ideas anyone, I have a particular .swift file that I really need to open.
Check if the files are empty on your old Mac. If they are empty on your old Mac then the data has been lost, there is nothing you can do.
If the files are correct on your old Mac then something went wrong when you transferred the data. Therefore just try copying them over again.
If the first situation that I stated is true then there is nothing you can do.
Can you not retrieve the original files from your other Mac?
copy and paste
Would imply that you can. Maybe you should attempt to copy the files again, alternatively, if you just need the one .swift file you could probably copy the text from it and put it into plaintext and then copy that back out into a new xcode project if xcode is having such trouble opening that particular file.
Are you sure that you're not missing out some details? Seems almost too easy to answer this one.

Xcode crashed while renaming project - whole project broken

I wanted to release an app I worked on and quickly change the project name. I usually duplicate projects before doing things like this but this time - because this procedure always worked on Xcode as I found it way more reliable than e.g. Eclipse - I didn't, which I immediately regretted.
Opened Xcode again and now I am seeing this
I guess all the linking is gone now which is why Xcode doesn't "find" the files anymore. Renaming the remaining project stem to the old name gives
couldn’t be moved to because an item with the
same name already exists
and also manual renaming of folders won't work as the .xcodeproj is gone.
The project is written in Objective-C, and all the classes are still persistent, but the effort of adding all the xib's, referencing the outlets, setting architectures, etc will become the nightmare of my life. I do have a half-way recent backup but everything I did to make the app store-ready today will be gone.
Any ideas on how to rescue my project?
EDIT: What Xcode is now showing on the welcome screen is a project called "project" (literally) and it has the usual compass icon but with a white instead of a blue background referring to the path <project folder>/<new project name>/ and below that "white" project there is a folder icon with the new name pointing to <project folder>.
I also made a snapshot before, of course it now says "Unable to read snapshots" in the "restore from snapshots" window.
Ok what I now did is renaming ALL references from the old project name to the new one. I even changed file names. I used Xcode's CMD+SHIFT+F and TextWrangler's "replace" function and thankfully I still had the .xcodeproj from yesterday's backup so from there I could copy it into the new project and rename stuff. There are still some things that don't work perfectly, for example auto layout doesn't "stretch" contents over the screen (it stays on iPhone 4s size, even on 6 plus simulator), I needed to set the scheme again and Launch Images / Icons got lost but I can look over that. The only thing I am afraid of now is that the final build might miss out a symbol or something like that so I eventually have a corrupt file in the App Store, but man it's a beta version, how much worse can it get anyway?
Thanks to everyone recommending me to even backup the broken project, I did this even before you said it but because I think it's a valuable advice I wanted to put it in my answer as well.
It's a shame that stuff like this can happen, I've been backing up my work on a daily basis and my project never got corrupted - until now.

Xcode stalls on "loading" when trying to create new project

Xcode 6 never gets past "Loading" when I try to create a new project. I actually was able to create a new project yesterday, but I decided to just ditch it completely (deleted). Clearly there must be a bad file somewhere, possibly related to the project I deleted, since I also see the same stalling behavior now with Xcode 5.1, which has worked fine for creating new projects in the past. Xcode 6 has worked fine when starting with an already existing project and still appears to do so. I did not see this exact problem in your data base, though one person saw the project creation freeze before reaching the stage I get to. Their solution was to delete Xcode and every possible file related to it, which I'm a little squeamish about, since I don't want to affect existing projects, and don't have an understanding of what the various files are for.
Deleting the DerivedData of Xcode should fix the issue. You can do this by heading to ~/Library/Developer/XCode/DerivedData (with a Finder window open press cmd+G) and deleting all the subfolders of it.
This is embarrassing, but if it could happen to me, maybe it could happen to someone else. The problem was that the window that came up after the second step in defining the type of project to be created, the one in which you choose where to save the project's files, extended off the bottom of the screen, so that only the very tops of the buttons were visible. Eventually, I realized the one to the far right might be the one to click to continue. Which it was. Feel free to delete this question.

NSLocalizedString returns text that is defined nowhere

OK, I am officially flabbergasted. I started an IOS project some time ago, and juggled around with localization a bit at the start, which became a bit of a mess, because I did not know how to do that properly yet.
Now I have decided to do the localization from scratch, and therefore threw away all the .strings files, and created a proper multi-language structure. I started with empty Localizable.strings files, and run the app to see whether I cleaned up everything properly. With empty Localizable.string files, I assumed my "NSLocalizedString" calls would simply return the key as text. They don't. They still return the old text that I had in the old .strings files.
Just to be sure, I put an NSLog statement under one of the NSLocalizedString calls, as such:
NSString *text = NSLocalizedString( key, nil );
NSLog(#"key=%# text=%#", key, text);
Then I search my whole harddisk for the text that was returned. No file on my harddisk contains the string that NSLocalizedString returns. And it is a completely different string than the key, so it cannot be constructed by NSLocalizedString either.
Anybody knows how this can happen? Is the old info cached somewhere by XCode? How can I persuade the tool to use the new Localizable.strings files? Obviously, I have already 'clean'ed and rebuilt the whole project.
Try to delete the app from the phone, then clean your project and install the app afresh.
If it still doesn't work, check you haven't somehow messed up with the Build Rules (Xcode 4 -> select your target -> tab "Build Rules") There, check if you don't have too many "CopyStringsFile" rules that aren't using "CopyStringsFile". If so you can remove them all but one.
If you are testing on the simulator, try resetting the simulator using the "Reset content and settings..." option in the "iOS Simulator" application menu.
When you redeploy a new build of the app, even after a clean build, it often doesn't clear out the cached content of the previously built version.
Did you also clean build folder? command + option + shift + k or go to product, press option, there will be a clean build folder, usually, resources file are cached, any resources file replacement (file with same file name but different object) might not be detected by XCode
Also, deleting app / resetting simulator does help. Deleted files sometime don't get removed when you redeploy.

Resources