FelixHerrmann / swift-package-list

A command-line tool to get all used Swift Package dependencies.
MIT License
135 stars 16 forks source link

Inconsistent Output for --output-type plist #124

Open laus102 opened 4 days ago

laus102 commented 4 days ago

We're trying to generate a secondary Acknowledgements-spm.plist file in our .xcworkspace because we are currently still using Cocoapods to generate an Acknowledgements.plist.

This way, while we are still in the process of moving our dependencies from Cocoapods to SPM, we can still display accurate acknowledgements for both managers (and avoid getting sued).

Real Output Desired Output
image image

The output on the right is what I believe swift-package-list generated one time, however I have yet to be able to replicate these same results, as now the tool only produces .plist files of the format on the left.

The file on the left produces a blank Acknowledgements page in the iOS Settings page for the app.

The file on the right produces a functional Acknowledgements page.

Most notably, the file on the right features the key PreferenceSpecifiers while the file on the left doesn't.

Am I missing a command line argument, or some other "gotcha"?

The command we're using:

swift-package-list 
    [...].xcworkspace 
    --output-type plist 
    --custom-file-name Acknowledgements-spm-1 
    --output-path [...]/SupportingFiles/Settings.bundle

The file structure:

/ Settings.bundle
    Acknowledgements-spm.plist
    Acknowledgements.plist
    Root.plist
FelixHerrmann commented 4 days ago

Thanks for reaching out! I already see the problem, using the plist output will just generate a plain property list from the array of packages equivalent to the json output, this will not work with a settings bundle because this requires specific keys; what you want is the settings-bundle output, if not already present it will created the necessary folder/file structure of a Settings.bundle (including localization), if it is already present this tool only "owns" Acknowledgements.plist and the Packages subdirectory.

Based on what you've send this seems to overlap with what you get generated from Cocoapods, which tool are you using and can you configure the filename there?

laus102 commented 19 hours ago

Hi, i'm taking your advice and using the settings-bundle output, utilizing the build tool plugin.

I am receiving this error when trying to build to iOS.
image

Any tips?

FelixHerrmann commented 17 hours ago

Pretty sure you've added the executable to your app target, just remove that there. But in your special case I think you have to generate the bundle manually so you know where it is to add the plist from cocoapods to it. Let me know if you need further guidance, I'm confident we will get this dual setup working for you!

laus102 commented 14 hours ago

Ok one more...

image image

But i'm getting the following error:

image

FelixHerrmann commented 14 hours ago

I see the issue, because you are using Cocoapods you have to use a workspace. Once a project is part of a workspace the Package.resolved is located in the *.xcworkspace file. So to tell the plugin what to do in that non-default scenario you have to create a swift-package-list-config.json file in the root of the project, as explained in the Build Tool Plugin section; in your case the following config should be sufficient:

{
    "projectPath" : "YourWorkspaceName.xcworkspace"
}

But, as mentioned before I don't think we will be able to achieve a mixed Cocoapods/SPM solution with a SPM plugin because the output is somewhere deep inside of the DerivedData directory; manual invocation or build script the generates the Settings.bundle into your project file structure is what I would do. If you can explain me how you generate the Cocoapods acknowledgment file I can try to build that on my side and provide an example repo or something.

laus102 commented 13 hours ago

@FelixHerrmann Screenshot 2024-10-07 at 4 43 05 PM

My strategy right now is to create a separate .plist file within the Settings bundle, one for Cocoapods, and one for SPM.

Not the prettiest, but at least we won't get sued 🤷

If you have any better ideas i'm all ears 😂

laus102 commented 13 hours ago

image

With the Cocoapods post_install looking like this:

post_install do | installer |
    require 'fileutils'
    FileUtils.cp_r('Pods/Target Support Files/Pods-XXXX/Pods-XXXX-acknowledgements.plist', 'XXXX/XXXX/SupportingFiles/Settings.bundle/Acknowledgements-cp.plist', :remove_destination => true)
FelixHerrmann commented 11 hours ago

Yep that is exactly the way you have to combine it; looks like you are free on the Cocoapods side in terms of file naming which is good.

If you have any better ideas i'm all ears 😂

From what you've send I cannot tell how you generate the SPM side but Cocoapods looks good.