Adding ITSAppUsesNonExemptEncryption to Info.plist for iOS builds (SOLVED)

#1

One of the things I’d like to do is to add in the key ITSAppUsesNonExemptEncryption to my Info.plist for my iOS build. Defold game.project lets me specify a path to an Info.plist that I need to maintain, but I’d rather not do that since keeping it “in sync” with the Info.plist that the Defold build process generates “out of the box” is likely to result in an overlooked source of bugs.

Ideally, it would be nice if the Defold build would generate its Info.plist then let me specify a second Info.plist which gets “laid on top of” the generated one, letting me override values or add new key/values from the one I specify? Maybe with a boolean option “merge” which by default can be “false” (to preserve backwards-compatibility) but if set to “true” would merge the two.

Right now, what I’m doing is doing a build with no ios.infoplist set in game.project and taking a copy of the default Info.plist and stuffing it in assets/ios/base.plist. I have my customizations in assets/ios/custom.plist. I then use PlistBuddy to merge the two:

$ cd assets/ios
$ rm Info.plist
$ /usr/libexec/PlistBuddy -c "Merge base.plist" -c "Merge custom.plist" Info.plist

I can then set ios.infoplist to /assets/ios/Info.plist and build.

Alternatively, is there a way to specify a “custom build command” that could kick off an executable (shell script, or any other platform-compatible build script) during the build process for each platform target, where I could stuff those commands, to automate this?

Thanks, everyone! I’m really enjoying getting to know how to do stuff in Defold. This is a fun game in and of itself :wink:

0 Likes

#2

Well, there’s Bob, the command line build tool, but there is no way to hook into the build process when building/bundling from the editor.

1 Like

#3

Ooh! Bob sounds like a great option, although it’s throwing an error at me trying to resolve … I guess I’ll try reporting it?

Edited to ask: Where should Bob issues be reported?

0 Likes

#4

What error is that? I’m guessing that it’s the lack of --auth and --email. These two options are currently required even though your dependencies might not be behind basic auth (yes, this will be fixed).

java -jar bob.jar --auth foobar --email bob@acme.com resolve

EDIT: Ah, I see now that this was the issue: Bob the builder fails when path contains spaces

1 Like

#5

Did you figure out a more elegant way of doing this using bob?

I have everything for the continuous delivery working but this plist thing is still causing me issues :slight_smile:

I prefer not to override the plist with my own because I don’t want to potentially introduce problems by not keeping it in sync with the one that Defold would generate. Is there anywhere you can access a generated plist file from the engine before calling bob -bundle?

0 Likes

#6

Bob.jar contains the info.plist so you can extract it from inside bob (jar files are zip files).

2 Likes

#7

Awesome, thanks @britzl

If I were to use this plist template in the .project files ‘plist’ property - would bob bundle replace the tokens in it?

0 Likes

#8

If you copy this file out to your project, and refer to it from game.project, then yes, the templated arguments will be replaced as usual.

3 Likes

#9

When using Plistbuddy to set the key on the plist, its throwing up an error due to the placeholders that exist in the template plist file in bob. I’m wondering if anybody knows how to circumvent this at all without having to regexp it into the plist. I’m guessing in the bob build scripts you just do a simple find/replace on the tokens.

Here is the error:

[exec] Error Reading File: Info.plist
[exec] Encountered unknown tag {{ios.pre_renderered_icons}} on line 42
0 Likes

#10

We use Mustache to do the string replacements, but you can ofc use whatever tool suits your need. E.g. Python + a sax-parser will let you insert your strings where ever you need it.

Also, if you want to go the regexp way, I personally use this regex site a lot to create various patterns. I don’t think I’ll ever really learn regex by heart, but I’m definitely using them a lot nowadays. They’re a good tool to learn if you are programming or writing various scripts etc.

1 Like

#11

Tell me about it. Throughout my career regex has caused nothing but suffering! Thanks for the heads up on a couple of those tools though :slight_smile:

0 Likes

#12

Might be useful for @dossy, I wrote a very primitive python script that extracts the plist from bob and appends the encryption exception tag:

import re
import os

from zipfile import ZipFile

def extract_without_folder(arc_name, full_item_name, folder):
    with ZipFile(arc_name) as zf:
        file_data = zf.read(full_item_name)
    with open(os.path.join(folder, os.path.basename(full_item_name)), "wb") as fout:
        fout.write(file_data)

extract_without_folder("bob.jar","com/dynamo/bob/bundle/resources/ios/Info.plist", "")

with open ('Info.plist', 'r+w' ) as f:
     content = f.read()

content_new = re.sub('<dict>', '<dict>\n\t<key>ITSAppUsesNonExemptEncryption</key>\n\t<false/>',         content, flags = re.M)

with open ('Info.plist', 'w' ) as f:
     f.write(content_new)
0 Likes

#13

With the “Custom entitlements” introduced in Defold 1.2.144, is it possible to add the ITSAppUsesNonExemptEncryption more easily?

I haven’t been able to find an example of what this file should look like on the forum or otherwise.

0 Likes

#14

If you set the ios.override_entitlements = true and then set your file to ios.entitlements then your file is used as-is.

0 Likes

#15

I’m unfamiliar with how plist files work, so bear with me. I get this error:

With this “entitlements” file:

And this config:

0 Likes

#16

Did you set the ios.override_entitlements? (edit: I now see that you do)
(edit)
When you do, you’ll pass in the full entitlements plist.

If you don’t, then it tries to merge the file with the entitlements in your mobileprovisioning profile.
And, if you don’t have that key there, you’l get that error message.

(edit)
My bad, it should say override_entitlements = 1

3 Likes

#17

Fantastic, now it builds fine. Thanks!

1 Like

iOS bundling fails (SOLVED)