Cannot save project in Scratch - mit-scratch

My project no longer saves in Scratch 3.0. I tried refreshing and going to My Stuff but that did not help.
The project does not contain any large files, but there are large blocks of code.
To try to fix it, I moved the sprites into the backpack to copy to a new project. However one of the sprites failed to copy.

Apparently there was a line of code that got corrupted. Deleting and then creating the line again (no changes) fixed the problem.
The backpack helped find where the problem was. I deleted various parts of the code in the sprite that failed to copy and then tried to copy it again. This process eventually led to the single line of code causing the problem.

Related

Make sure that there are no compile errors and that the file name and class name match

I keep getting the same error over and over no matter what I do.
"Can't add script component 'PlayerMove' because the script class
cannot be found. Make sure that there are no compile errors and that
the file name and class name match".
I am very sorry that this is very long, but this is the extent of what I have been trying to do to resolve this problem, so please be patient.
I have been working on this 2D project for three weeks. It was working fine until 3 days ago. So far, I had only created the environment and added characters who were doing nothing. There is music and effects. All of these is (still) working fine.
Then I added a script to make my character move. Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour {
public float moveSpeed;
public Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
rb.velocity = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, rb.velocity.y, rb.velocity.z);
}
}
I was so happy, my character was moving!! There were no errors! It was all fine. It worked like that for two more days after adding the script. I'm saying this to emphasize that Unity did not crash because of the script.
Unity crashed, this happened on Monday. Even though I did not lose my project files, and restarting Unity did not work, I had to uninstall and reinstall Unity. My version was 2019.4.1f1 before and after as well, been working on same version, since I don't want to get stuck with upgrade issues.
When I reinstalled Unity and reopened my project, unfortunately, Cinemachine and ProBuilder were both gone. This is another problem I have been facing since the start. But that should be another topic.
PART 1
After a lot of work, I gave up and decided to create a new project. Following are the steps I took:
I created a new project
installed CM, PB,
went and imported my project.
The script was not working so I reimported it.
PART 2
It still did not work, so I created a new script- with a different name- by using the method of right clicking in Assets and creating a script.
Then I just copied my THREE LINES OF CODE - literally as you can see above - and tried to add it to my character. Still not adding. It wants to know if the class name and file name are same - which they are of course - no matter how many files I create, in whatever method, I make sure the class name and file name are same. And the class does inherit from Monobehavior. Plz refer to error message in start.
PART 3
I then created another script file. I deleted the previous script, made sure there were no other scripts with similar names, then went to the PLAYER and created a file from the Add Component menu in the Inspector. I double clicked the file from there and then added the code. And after I had saved it in VS 2019, it's an invalid file in the Inspector in Unity.
I have tried doing this with several file name changes. And I have tried to import the script file from another folder. I keep getting the same error over and over again. Just now I finished reimporting all process as well. I even uninstalled VS 2017, and installed all latest .Net SDK Frameworks.
I'll be grateful to anyone who can help.
I also added this question to the Unity forums a week ago (I was getting same error message), and was successful in resolving it, but now that solution is not working.
Remember that I have created absolutely no other scripts. The only scripts present in my project would be the ones attached already to the assets, and there is no asset in my project that requires a movement from input, or can be called a "player character" game object.
Oh, and I also tried to re-drag (?) the Prefab of my Player asset from the main folder over to the scene view. I even just now reimported the whole thing - Reimport all.
I have been trying to shorten the question over and over, but the steps I took to resolve this issue were so many that I could not manage it.
However, good news is that I did finally resolve the issue.
Of all the things that could be expected, this is what worked: I went and deleted all "SmoothMoves" folders from my assets. I have no idea why that helped, I don't know the connection.
Please read this question I posted on Unity Answers - anyone with similar issues - as proof that I don't know what effect SmoothMoves files and folders had on my project and I don't know what effect removing it will have. (Yes, I know some of my character assets (enemies) use SmoothMoves, but I'm still not sure what was in those folders I deleted).
But my main player characters are both now moving. My script file added to the game object without so much as a blink.
https://answers.unity.com/questions/1753426/smoothmoves-dll-file-problem-can-anyone-please-hel.html
So this problem, make sure the class name and file name are same, an odd issue, can arise from SmoothMoves folders (I still have all character prefabs in the project, I only deleted the specific SM folders ONLY). Be careful.

AndEngine classes - problems with opening declarations: Source not found

Im working with AndEngine in eclipse (which is a 2d physics/tiling engine)
Everything works fine yet when i try to open declaration to classes I get Source not found
I can Change Attached Source...
but i wouldnt know what to change it too...
is there a way i can download the classes so i can view them on my computer (so far im stuck with googling each class and it slows down my progress immensely)
Is this suppose to be happening?
Can i somehow solve this problem or get my hands on some good documentation.
I fixed the problem by extracting the jar file with the JD GUI program. Then i simply opened the declaration and then clicked change attached source... and pointed it to the file (which is still zipped it doesnt work if you unzip it) Everything works well now :D

Classes folder not appearing in Groups & Files Xcode

The code files have suddenly disappeared from the left tree pane on my Xcode. I tried to drag and drop the classes folder from the file system but this starts giving syntax errors.
Please help.
If the project builds then you haven't deleted them, you've probably dragged them into another group[ by mistake :)
Open all the other groups and you might see the Classes folder as a subfolder. Just drag it back out again.
NB Go to Build->'Clean all Targets' and then build it again. If it builds without errors then my answer is probably right. If it doesn't build then I'm absolutely wrong :)

Interface Builder caching bad data (voodoo)

Sometimes IB will hold onto old or bad references, and I cannot seem to remove or edit them.
EDIT I have made this a wiki question with the intention of gathering more data on the phenomenon. Answers involving situations where other coders have encountered this are welcome.
This happened to me again last night with a table controller. When I created a spike project to try and reproduce the error, the system worked the way I anticipated. Then back in the actual project the bad behavior continued, even if I remove the xib file and all controllers involved.
Creating a whole new project with none of the original (problematic) xib and nib files worked correctly.
This question is not about the specifics of this incident but about this type of incident in IB.
Does anyone know more about this type of bad IB behaviour, and possibly a more stylish way to to eliminate it than nuking the project?
Note, removing the offending IB files and recreating them in the same project has not solved this for me in the past, only whole new projects.
Answers regarding examples of when/how this glitch has been observed/created are welcome as well.
I fixed this type of caching problem by clicking File > Read Class Files ... and pointing IB to my class files. Bingo, it read them fine, and everything worked. :-)
The only real suggestion I have is to file a bug report at http://bugreporter.apple.com/ with a reproducible project as the attachment; in my experience Apple do look at these things. That said, you say that re-creating the XIB in the same project didn't fix the bug. What about replacing the other end of the link; i.e. re-create the header file and use that new header with the existing XIB? Perhaps that's sufficient to prod IB into updating its model.
I just had a project where this happened and I was banging my head trying to get it to update properly in IB 3.2 (732). I really did not want to redo the xib from scratch. I tried drag/drop of the *.h files, restarting, reloading everything and it didn't work. I also tried File->Read Class Files which didn't work. Strangely though, File->Reload All Class Files worked like a charm.
I find that File > Read Class Files fixes it for a single nib file, however the nib doesn't remain in Sync with any future changes and the fix doesn't apply to any other files in the project either.
Restarting and/or clean building didn't help either, but new projects are fine. This has been happening to me in Xcode/IB ver 3.2.2 - so far the only solution has been rebuilding the code in a new project.
Maybe not the answer you want, but here it is: Do not use IB! :-)
I had troubles using it too, even when reproducing exactly the steps as described in some Apple docs, trying multiple times from scratch. So after 3 days I just gave up and started doing everything programmatically, implementing my program in half a day. I have never looked back since. I only launch IB occasionally to look at sizes, so I can feed them into my code.
It will probably be less easy to update my GUI over time, but if your story is a real recurrent problem, I'm glad I parted ways with the beast!
When you say old or bad references, do you mean it is trying to link UI elements to outlets or actions in a class that no longer exist? If that is the case then go to the connections panel (cmd-5) and select the object in your nib file. It should show you all the connections. Any where the text is greyed out and have an exclamation mark should be deleted (hover over and click the x).
In IB, you are only connecting to a "promise" of what your class will be like when the app launches. IB normally only lets you connect stuff that can fulfil that promise, but if you change the header in Xcode there's nothing IB can do about it besides warn you.
Try making a clean build of the code and then see if the old references remain in the xib
You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer.
Are you saving the header files? Interface Builder parses the content of your header files on disk, not the unsaved files in Xcode's editor. If you add an outlet to a header file, and switch back to IB without saving first, IB won't see the new outlet.
I had exactly the same problem with IB when I created a new project out of an old one.
I can synchronize IB with the new .h files but IB still gave the removed references (from the old project) when I right-clicked the object ( the class name "MainController" was the same from the old to the new ) even though those references did not exist in the updated code at all.
"You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer." I tried to clean the target but it did not work.
However, once I deleted the MainManu.xib and created a new one (there would be a bit work to design the interface by hand), the old references were gone.
I experienced the same problem. It happens when I open a project made with old Xcode version. Interface Builder does not sync correctly with Xcode. Yes, I can manually update the IB cache with the 'File->Read Class Files...', but even with this method garbage remains. I mean old IBOutlet and IBAction still shows up.
Just had this type of incident and fixed it by using XCode's refactoring to rename classes to different names. Seemed to get stuff restarted.
Reading the problematic class file again has solved this problem for me.
QUICK EASY SOLUTION: - no computer restart, no new project required . . .
Unfortunately none of the suggestions in this post have fixed this issue for me (aside from restarting my computer and then starting a whole new xcode project)
MY SOLUTION...
Anyway, the only other quick fix (that works for me with Perfoce at least), is to back out (revert) my changes in my revision control system. We are using Perforce, and this seems to work just fine.
I didn't have to create a whole new xcode project, no restarting the computer, no restarting xcode even, no manual deleting of files or references, no re-references classes, no click and drag garbage to deal with, no manual settings changes, etc.
DOWNFALL...
If you are walking all around xcode and the IB for a while, and have made a lot of changes, and then all of a sudden the issue occurs... you will then of course lose everything in the files you revert... QQ
glhf
-eric
SIDE NOTE...
this is a pretty bad bug, and definitely consumes a lot of time, especially if its your first time coming across this issue (and I'm sure everyone here realizes, that time is essential to a developer). This is the first time I've ever been disappointed with apple/obj c/xcode (started 2 months ago), and i sense this won't be the last : /

How do I make Xcode refresh its local copies of my project's image files?

I'm having some weird issues with Xcode, and this is pretty much impossible to find answers by simply googling around.
I have a few icon image files (just PNGs) in my Xcode project, and when I modify some of them in Photoshop, they don't get updated when I do another build in Xcode. In order to fix this I have to re-add the file again to the project, and then remove the old version of the file that is already in there in Xcode.
What am I doing wrong here? I'm updating/replacing the image file that is stored in my project's directory directly from Photoshop, so I assumed that it would just get reloaded and the new version would show up.
UPDATE: Looks like what happened was that when I first imported the image files into my project, they got added to my "Classes/" sub-directory. So when I was updating them, it was just adding them to the root of my project.
I had the exact same problem.
The following fixed it for me:
In Xcode, go to Project --> Clean
This will purge the old images from xcode cache and will show your new image
That's pretty weird. I'd suggest two things:
Check that you're not saving your
photoshop files into the wrong
directory. I know this seems
straightforward but its worth a
check. Make sure you're not saving
them into the build/ directory or
anything like that.
Before running again in the simulator, try cleaning all build targets first to ensure that your project actually builds again before launching the simulator.