Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When exporting an iOS Project will delete source code #89715

Closed
SAGESSE-CN opened this issue Mar 20, 2024 · 3 comments · Fixed by #89790
Closed

When exporting an iOS Project will delete source code #89715

SAGESSE-CN opened this issue Mar 20, 2024 · 3 comments · Fixed by #89790

Comments

@SAGESSE-CN
Copy link

Tested versions

  • Reproducible in v4.2.1.stable.official [b09f793]

System information

Godot v4.2.1.stable - macOS 13.6.5 - Vulkan (Forward+) - integrated Intel(R) Iris(TM) Plus Graphics 655 - Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz (8 Threads)

Issue description

when exporting an iOS Project to the exists directory parent, it will be remove it directly.

my all code is lost because of this!!!!

expect any warning or confirm or somethink.

Steps to reproduce

  1. create a new project, specify directory /xxx/project/mygame
  2. create a empty scene
  3. export iOS Project, specify export directory /xxx/project/
  4. you will lose all source code

Minimal reproduction project (MRP)

  • no need this
@bruvzg
Copy link
Member

bruvzg commented Mar 20, 2024

iOS exporter deletes binary_name + ".xcodeproj" and binary_name specifically, since these are the directories created during export. So if you use mygame as export name, it will delete it. No sure how to fix it (or if it should be fixed), since not deleting it will result in broken export if you export multiple times to the same folder.

@AThousandShips
Copy link
Member

AThousandShips commented Mar 20, 2024

We could for example search for a project file in the path, but it'd still be risky, as it could be in any nested folder, unsure how it could be done reliably, alternatively we could reqire that the folder is either empty (or does not exist) or contains some specific data from exporting

This is the relevant code:

{
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (da.is_valid()) {
String current_dir = da->get_current_dir();
// remove leftovers from last export so they don't interfere
// in case some files are no longer needed
if (da->change_dir(binary_dir + ".xcodeproj") == OK) {
da->erase_contents_recursive();
}
if (da->change_dir(binary_dir) == OK) {
da->erase_contents_recursive();
}
da->change_dir(current_dir);

We could also make the binary dir have some suffix making it unlikely to match your project directory in the case you name the binary the same

We could also enforce the export happening in specific places as well

@bruvzg
Copy link
Member

bruvzg commented Mar 22, 2024

This code actually is broken and will delete it only if there's no binary_dir + ".xcodeproj":

if (da->change_dir(binary_dir + ".xcodeproj") == OK) {  // enters dest/binary_dir.xcodeproj
	da->erase_contents_recursive(); 
} 
if (da->change_dir(binary_dir) == OK) { // if previous changedir was sucessfull, enters dest/binary_dir.xcodeproj/binary_dir which will not exist
	da->erase_contents_recursive(); 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants