thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
64 stars 4 forks source link

fix: fixed a copy error during template instantiation. #54

Closed MGlolenstine closed 2 years ago

MGlolenstine commented 2 years ago

I've added mkdir command that creates missing folders that would otherwise throw errors during the setup.sh template creation.

cp: cannot create regular file 'macos/Classes/Plugin.swift': No such file or directory
cp: cannot create regular file 'macos/plugin.podspec': No such file or directory

Notes:

SecondFlight commented 2 years ago

I've noticed similar issues, though strangely I don't remember encountering this when creating the template. Instead, I get an error in rid_build if I delete the swift files, even though they seem fully autogenerated. I may be misunderstanding something, but it seems odd to me that a bindgen file would need to exist to be recreated. This also means I can't .gitignore the files, since collaborators would then be unable to build the project.

This may be unrelated enough to merit a separate PR, and if so I'm sure I'll get to it at some point. But if you fixed it as part of this PR, I also wouldn't complain :)

MGlolenstine commented 2 years ago

I'm not sure how most of the plugin/ folder stuff works anyways. I'm just fixing errors as I come across them. It might be because I'm on Linux, and some folders fail to create by default. This isn't a breaking error, but it only gets printed during the template creation. I'm not using macOS, so I don't know if it breaks the created project for iOS and macOS or not.

I'll be trying to keep it in check, as I've finally started working with RID :)

thlorenz commented 2 years ago

@SecondFlight I think this is unrelated to what you're describing. The duplicate is harmless as it is using -p which does nothing if the directory already exists (on the second call). Merging this of course though since it's still a bug to have the duplicate. Thanks @MGlolenstine and sorry for the delay.

thlorenz commented 2 years ago

Actually on second read they aren't duplicates they are folders needed on macos. I can see why this causes issues on Linux since swift isn't used there. Can we wrap those dir creations in an operating system check instead similar to the below @MGlolenstine ?

if [[ $OSTYPE == 'darwin'* ]]; then
  echo 'macOS'
fi

Checking uname should also work (as in the last example here)

MGlolenstine commented 2 years ago

@thlorenz Thanks for pointing out the needed os-isolation for dir creation. I'm wondering if I only need to create them on Linux or Windows as well.

MGlolenstine commented 2 years ago

Something like the above would probably be the intended way to fix this. We only copy the template files if it's darwin. Or is there another catch that requires those files on other platforms as well?

EDIT: No, that won't work because if the darwin platform is still wanted for cross-platform development, it'd still have to be generated.

I should probably lock the dir creation instead. However, I'm unsure how I'd check for Windows.

EDIT n°2: Negation seems to solve the problem :)