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

Choosing root directory as output directory causes incorrect zipping behavior #20

Open
BradPatras opened this issue Sep 8, 2024 · 2 comments · May be fixed by #21
Open

Choosing root directory as output directory causes incorrect zipping behavior #20

BradPatras opened this issue Sep 8, 2024 · 2 comments · May be fixed by #21

Comments

@BradPatras
Copy link

When using the default output directory and when specifying the output directory and providing a path and folder name, outputDirectory(File(rootDir, "folderName")) the resulting zip file has the correct structure and format:

framework.zip
  ⌙ framework.xcframework
    ⌙ Info.plist
    ⌙ ios-arm64
    ⌙ ios-arm64_x86_64-simulator

However, if you pass in only a path as the output directory, for example: outputDirectory(rootDir) or outputDirectory(File(rootDir, "/")) the resulting zip file will contain the entire project, not just the xcframework.

This zip file is unusable by SPM and this issue makes it difficult to have the plugin generate the Package.swift file at the root of the repository (which is standard practice for swift packages).

framework.zip
  ⌙ framework
    ⌙ build
    ⌙ gradle
    ⌙ .github
    ⌙ .idea  
    ⌙ framework.xcframework
      ⌙ Info.plist
      ⌙ ios-arm64
      ⌙ ios-arm64_x86_64-simulator
    ⌙ etc.. etc..
@BradPatras
Copy link
Author

After digging in a little bit it seems like include("**/*.xcframework/") in CreateZipFileTask.kt isn't working or isn't being evaluated in time.

@BradPatras BradPatras changed the title Choosing output directory without folder name causes incorrect zipping behavior Choosing root directory as output directory causes incorrect zipping behavior Sep 8, 2024
@BradPatras
Copy link
Author

BradPatras commented Sep 8, 2024

After even more experimentation, it seems like the include could be updated to be:

from(outputDirectory) {
  include("${configuration.packageName.value}.xcframework/**")
}

Since we're already opening the child CopySourceSpec in the from(...) { closure, we shouldn't need the **/ part of the expression (we'll already be in the output directory where the framework folder is).

The second change is using the packageName.value instead of *.xcframework. This is because we know the name of the framework folder so using a wildcard seems redundant, and could potentially cause issues if for some reason there are multiple .xcframeworks in the user's output directory.

I tested this using both the default outputDirectory and using the project root and it works in both situations.

BradPatras added a commit to BradPatras/multiplatform-swiftpackage that referenced this issue Sep 8, 2024
…Fixes luca992#20

The wildcard that was used in the include was too permissive and would cause too many things to be zipped when the output directory was set to be the project root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant