MisterDA / love-release

:love_letter: Lua script that makes LÖVE game release easier
MIT License
451 stars 27 forks source link

Mac App is "Incomplete or Damaged" #31

Closed thelukester92 closed 8 years ago

thelukester92 commented 8 years ago

When I install and run on my Mac to build a Mac application, the resulting file will not open and says that the app is damaged or incomplete. When I view the Info.plist generated, I can see why; the plist is not actually closed correctly.

I fixed the error on my end by updating macosx.sh, removing the first part of the sed command (it appears to be deleting the UTExportedTypeDeclarations array; I removed that so that the array is left in place). I'm not sure what the purpose of removing the array was, but it somehow damaged the app.

MisterDA commented 8 years ago

As explained in LÖVE documentation Game_Distribution#Creating_a_Mac_OS_X_Application,

When modifying the file SuperGame.app/Contents/Info.plist make sure to change the values of the following XML-tags: CFBundleIdentifier, CFBundleName and remove the section UTExportedTypeDeclarations which ensures that Mac OS does not associate all .love files with your app.

So here you have the purpose of UTExportedTypeDeclarations.

I haven't yet launched an app, but generated one and the Info.plist seems like valid xml to me.

The problem might be that this code eats more that it should from the plist.

sed -i.bak -e '/<key>UTExportedTypeDeclarations<\/key>/,/^\t<\/array>/d' \
    -e "s/>org.love2d.love</>org.${AUTHOR}.$IDENTITY</" \
    -e "s/$LOVE_VERSION/$GAME_VERSION/" \
    -e "s/Love.icns/$icon/" \
    -e "s/>LÖVE</>$TITLE</" \
    "${TITLE}.app/Contents/Info.plist"

In the lua port I use this snippet to achive the same thing:

infoPlist = infoPlist:gsub("\n\t<key>UTExportedTypeDeclarations</key>.*</array>", "")
    :gsub("(CFBundleIdentifier.-<string>)(.-)(</string>)", "%1"..project.identifier.."."..project.package.."%3")
    :gsub("(CFBundleName.-<string>)(.-)(</string>)", "%1"..project.title..".love%3")

Both outputs the exact same file, and I wrote them separately. I don't think the problem comes from here.

But there is a lot of things that could have gone wrong. It's been a while since I haven't tested love-release, but I don't recall the osx build failing. Odd ! I'll try some more things soon.

thelukester92 commented 8 years ago

So for some reason, -e '/<key>UTExportedTypeDeclarations<\/key>/,/^\t<\/array>/d'is taking more out than it should. By removing it, the code works, but as you noted it goes against the documentation and will cause other problems. The </dict> and </plist> are missing from the end of the plist file when I run the script as it is.

MisterDA commented 8 years ago

This was not the problem, I don't know where it came from. I've just tested it with the new Lua implementation and it works without any problems. On newer macs, check if you can launch apps from non-signed developers (something like that).