Resizetizer One or more invalid file names were detected - visual-studio-mac

I can't get rid of this build error in my .net maui app in Visual Studio for Mac 2022 v17? The build output says:
/usr/local/share/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/6.0.300-rc.3.5667/targets/Microsoft.Maui.Resizetizer.targets(511,9): error : One or more invalid file names were detected. File names must be lowercase, start and end with a letter character, and contain only alphanumeric characters or underscores:
When I copied the image files into the resource/image folder they did have invalid characters, but I renamed the files to only have valid lowercase alpha numeric letters but still visual studio is just broken. I've cleaned the project, manually deleted bin and obj folders, restarted the solution and visual studio and even booted the whole machine with no success. I've even tried to delete all images but no luck.
There must be some other cache that is still holding invalid references of the error message is simply wrong and is thrown for some other related reason. Any help finding this issues would be greatly appreciated.
Edit
I have now created a new project (MyMauiSolution) and one by one copied the folders from the old solution to see where it would break. After all files are coped into the new project it still works. So now I have 2 solutions with more or less exactly the same files/images, where one is working and the other is not?!
I have even tried diffing the folder structures, but there are no differences?!
myiMac:Projects user_x$ diff -rq BlueWhaleMaui MyMauiSolution
Files BlueWhaleMaui/.DS_Store and MyMauiSolution/.DS_Store differ
Only in BlueWhaleMaui: .git
Only in BlueWhaleMaui: .gitignore
Only in BlueWhaleMaui: BlueWhaleMaui
Only in MyMauiSolution: MyMauiApp

This is likely caused by the existence of a hidden file in the Resources\Images directory created by the Mac operating system when using the Finder to manipulate files in that directory. (.DS_store)
The .DS_store is not visible in Finder even when 'Show All Files' is turned on, so to confirm:
Open the Terminal application
Change to your project's Resources\Images directory
Perform the command 'ls -la' in the Resources\Images directory
Confirm the existence of the '.DS_store' file (or any other 'dot' file)
There are two solutions (one a workaround, really)
Simply use the Terminal application window to delete the file
Edit your project (csproj) file to exclude the .DS_store from resizing
If you delete the file using terminal the issue will return the next time you use Finder to manipulate files in that folder/directory.
Alternatively, open your project (csproj) file and find the section that defines the MauiImage resources in your project. It should look something like this :<MauiImage Include="Resources\Images\* />
Change that from a single wildcard to a list of more specific patterns to include:
<MauiImage Include="Resources\Images\*svg />
<MauiImage Include="Resources\Images\*png />
<MauiImage Include="Resources\Images\*jpg />
This should include only files ending in these image-type file extensions in the resizing process and skipping the .DS_store file.

I had the same problem. As a workaround I deleted 'Images' folder (after backed up), create a new 'Images' folder and restore the images.

Related

Moving files around in XCode and IOS 7

I move some files into a subdirectory but now I get linking errors saying files can't be found. Where do I go (like a projects file) to tell XCODE where to look for the new files?
I tried removing everything and adding them back in but I still get missing files even though they are one directory in and added to the project.
Select a file in left panel, open inspector panel on the right and choose a path to file there.
Note: it's more efficient to do that if your files are organized into folders; that way, you only need to change the path to folder and the elements are relative to it.

move an xcode 4.5.1 project to different folder

I have created a rather large application in xcode and wish to move the files somewhere else on my computer.
Could this process be as simple as dragging the project folder to a different place in finder or will something mess up?
Moving the .xcodeproj files will not cause any issues as long as xcode is closed when you migrate the files and you delete the old files.
When xcode is next launched, if you browse and open the proj file from the new directory, all the references will be set to the correct destinations
on a side note it always pays to keep the old files in a .old folder when migrating projects to avoid issues.
As long as the files are kept in their respective folders, next time you run a build in xcode, the references to the new directory the proj file is in will be updated.
As another side note, i just tried to do this and it messed up for me. Typically, any references will switch over, but i had a linker error: ld. it was trying to link to an external library that was contained within the old folder. i had to go to build settings->search paths->library search paths and change that to the new folder location. that worked for me.

Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file

I was trying to merge branches and it resulted in the error "Unable to open project… cannot be opened because the project file cannot be parsed". I then tried to take the advice of other stackoverflow responses (namely to edit the file to remove the corruption), but was unable to edit the file. It appears that this is actually a directory, so maybe the structure of this changed with version 4.4 of xcode and since the response to Unable to open project... cannot be opened because the project file cannot be parsed was written.
I then tried to restore myProject.xcodeproj from my time machine backup. This does not work because it says that I don't have permission to access myProject.xcodeproj. I tried to change the permission of that directory, but that did not help.
I closed and reopened xcode. Now the error is:
Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file.
How can I fix this problem in xcode version 4.4? Can it be restored from the previous snapshot or archive or version in xcode. Can it be restored with time machine. I would like to avoid rebuilding the entire project.
The simplest thing to do is probably to
Checkout myProject.xcodeproj from source control. This will contain the changes that were causing you to be in conflict last time.
Redo the project changes that you made since the last time you committed to source control
commit/push to source control.
In the future, when you get a conflict in the project file, take a look at myProject.xcodeproj/project.pbxproj. Often it's just new files in the project that have been added at the same place. In this case you just need to delete the conflict metadata and resolve the conflicted state.
In the end, what I had to do was
'cp -R ...TimeMachineBackup/myProject.xcodeproj ...myProjectArea/myProject.xcodeproj'
Then I had to do the following in myProjectArea:
git reset --merge
This allowed me to open the project and switch branches back to my main branch.
not a pleasant experience
Another way this can happen is if you've been using sudo for some reason with pods or the editor - if the file exists under yourApp.xcodeprojectroj directory but xcode is complaining it can't find it - Go to your project root and do:
sudo chown -R yourusername:staff ./*
For others looking at this issue, the cause in my case turned out to be, that the "conflict text" from a git merge had crept into the actual file:
<<<<<<< HEAD
F0FDA2D61B99EB80007DB99D /* Aptron-mCollegix.xcassets */,
=======
F08CFAAA1BC1E9EE00A5B6F5 /* Aptron-mCollegix.xcassets */,
>>>>>>> hotfix/Column_Text_Cut-off
opening the project.pbxproj in a text editor made the fix easy.
I found my own solution to this issue.
The cause of the bug is that the .xcodeproj file is missing its containing pbxproj file, right? This is usually present when you right click your .xcodeproj file and click 'Show Package Contents'. However, in your own case, it's been deleted, through some mistake or other of git versioning.
As you can't really generate a .pbxproj file, the solution I found was to go to the original project folder location, which I had used to create the repository. To be honest, you could probably simply create a new project also, as long as it has the same bundle identifier and such! As this project's xcodeproj file will correctly contain a .pbxproj file, replacing the files in the XCode environment with your own project's files will allow the .pbxproj file to update based on these files.
Therefore, after opening this original project folder (/new project folder), in the XCode environment, I then removed all the files within the project, and replaced them with the corresponding files from my project which I was unable to open the xcodeproj file of. I had to fix a few resulting bugs here and there, stuff involving build phases and such not lining up, given you've just copied in a bunch of new files. But after fixing a few small errors, the same project in this new location was eventually able to run no problem!
Finally, I took this successfully running version of the project, and copied in all the files, .xcodeproj file, project folder, test files and all, into the original repository location, deleting the files from the repository before hand to avoid confusing overwriting of files (you can cut and paste the old repository files to a new location if you want to be safe, and don't fancy deleting them!). Then open the project in XCode from the repository location, build and run it on your simulator/device to make sure everything lines up (and fix any small bugs you may need to), and voila! Your project is now able to be committed, pushed, and ran!
This isn't the cleanest solution, and you may have to do similar things across various branches if they've all been corrupted. However, if you don't have access to a Mac time machine, and the other solutions aren't working for you, this is possibly the most straight forward way of having a working .pbxproj file again!
Oh, and I removed the .pbxproj from my gitignore. I'm not sure if it's actually find to have it in your gitignore or not, but I'd recommend doing your own research on that subject, I'm not certain myself!
Good luck!
I was able to get this working without commandline stuff like this:
Go to Time Machine drive in Finder.
Navigate to desired backup.
Drag it to where I want it. This will complain about not having permission to access the .pbxproj
Right-click the xcodeproj you just dragged out, select "Show Contents".
Right-click the xcodeproj in the Time Machine backup folder, select "Show Contents".
Drag the .pbxproj you see inside to the destnation you just created with the drag in #3.
Now it should work.
It seems you can generate the file again with:
swift package generate-xcodeproj
although you could see this message:
warning: Xcode can open and build Swift Packages directly. 'generate-xcodeproj' is no longer needed and will be deprecated soon.
generated: ./BokenEngine.xcodeproj
with xcodebuild > 13.4.1:
xcodebuild -version
Xcode 13.4.1
Build version 13F100
If anyone wants to find the missing project.pbxproj file then try opening the .xcodeproj with some code editor and you will find the file there. And note that i had backup of my application in my other pc so i found that file there so you mist have backup of your project somewhere in order for this to work.
In my case the issue was that there were actually 2 folders with .xcodeproj suffix
The actual one was located in MyApp/MyApp.xcodeproj
Somehow another one with the same name MyApp.xcodeproj got added to root folder, with the following contents:
project.xcworkspace/contents.xcworkspacedata
project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
So deleting this corrupt(?) xcodeproj solved the issue.

What does exclaimation point symbol mean for files during XCode commit?

When committing changes to an SVN repository from within XCode some of the files have the "!" symbol in the right column (see screen capture).
What does this symbol mean and what should I do w/ these files? It seems to be any time a file is deleted from the project.
It means that the file is known to the version control system, but missing or damaged locally. Here's a list of SVN status codes:
http://knaddison.com/technology/svn-status-code-cheat-sheet
Often the solution to this problem is to go into the folder containing these files, and remove the .svn folder from it. In particular, this should work if the problem started happening after you copied/imported folders/files from another project (already under version control) into your current project. The issue is that the .svn folders are not portable cross project/repository. Trying to import a .svn folder from somewhere else just causes the version control system to get confused.

xcode archive build fails with error Copy .strings file Error : Failed to remove

When building the project for distribution using the Archive build mode, the following error appears. When building in debug or release mode everything works fine. The mentioned directory is empty. The directory permissions are set to full access for the current user. Any ideas?
CopyStringsFile /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj/Localizable.strings ProjectName/Resources/es.lproj/Localizable.strings
cd /Users/username/Coding/proj/game/ProjectName
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
builtin-copyStrings --validate --inputencoding utf-8 --outputencoding binary --outdir /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj -- ProjectName/Resources/es.lproj/Localizable.strings
error: failed to remove /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj/Localizable.strings: “Localizable.strings” couldn’t be removed.
This happened to me when I had duplicate references to a folder added to the project. Deleting the duplicate references fixed it.
Ok, i figured it out:
I don't exactly know why Xcode wanted to delete a file that wasn't existent at that location in the first place, but it think it had to do with the project file which was broken for no apparent reason.
The way i fixed it was to just delete all the Localizable.strings files from the project ( i had 6 for different languages each in its own .lproj directory ) and then add them again one by one. –
I also face this type of problem. But what I did is just clean up project "Product -> Clean" and rebuild it fix this problem
I had the same problem ... anyway, these 2 steps definitely solved it:
Make sure the Localizable.strings files are encoded in UTF-16 instead of UTF-8. So if you need to convert them you can do it in XCode by choosing the files and changing the Text Encoding to UTF-16 in the File Inspector
remove the references to the files from your project and re-add them. This should fix the CopyStringsFile error.
I had the same problem and simply cleaning didn't fix it.
I have multiple Build Configurations set up in order to output different apps with different bundle identifiers and a custom script that copies some files. When creating new Build Configurations with new custom files, these files were automatically added to the "Copy Bundle Resources" Build Phase when my script was already taking care of them.
So what I needed to do was simply to remove them from the Copy Bundle Resources list in MyTarget > Build Phases.
Please check this before trying other mentioned steps :-
In my case it was the disk space. I had to free up some space before running it again.
I had same problem: “Localizable.strings” couldn’t be removed. It occurred almost randomly -> when you try to build whole project (after switching git branches or cleaning project) -> Copying Localizable.strings files. I had 4 localisations in my app.
I have tried all mentioned solutions but none of them helped me:
1) project was set up correctly
2) UTF-8 is recommended by Apple itself (https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html).
Finally I found one more thing. It turned out that my generated (used fastlane poeditor_export plugin) Localizable.strings file had no last line (CR symbol). Added LF (new line feed) symbol to the end of file and build process stopped throwing error.
File was not compliment with POSIX standard (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206).
Hope this will be helpful to someone ;)
BTW, same issue thread: Localizable.strings error - compiler says file is missing
In my case my .string file was referenced at different location in Xcode sidebar but its actual disk location in computer was different. I moved the file to the referenced location (as same in Xcode) in my computer and it worked well.

Resources