Trouble building for iOS (Issue-4977)

#1

Hi! I’m an iOS developer, but I’m new to Defold and I really enjoy working with it so far. I’m having some trouble creating a development build to test on my device, though. No matter what I seem to try, my app crashes as soon as I launch it.

The device logs show the same thing every time, no matter how I’ve built the app/what provisioning profile I’m using: Crash Logs Gist

I’m using the latest Defold/macOS/iOS/Xcode versions and tried a provisioning profile created on the Apple Developer site as well as pulling one from inside a clean Xcode app build as detailed in the Defold manual. I made sure to set the correct bundle identifier in game.project. I’m installing the built .ipa file from …/build/armv7-darwin via Xcode > Devices & Simulators. I even wiped my drive and reinstalled macOS to make sure there wasn’t a strange certificate/profile mismatch error, but I haven’t had any luck unfortunately :frowning:

I really hope someone can give me some pointers, because I’d love to be able to use Defold for a new app!

0 Likes

#2
Failed to parse entitlements: AMFIUnserializeXML: duplicate dictionary key near line 12

Are you using custom entitlements for your app (using the ios.entitlements key in game.project)?
According to this code, Defold tries to merge the entitlements in your provisioning profile with the custom ones that you specify unless you also set ios.override_entitlements to 1.

Otherwise, check the entitlements in your provisioning profile. Maybe they actually are corrupt or something.

0 Likes

#3

Thanks for your reply! :slight_smile: I’m not using any custom entitlements; I’m actually just trying to run the default mobile project from Defold that I created from New Project > Mobile game. The only thing I changed in game.project was my bundle identifier.

I compared my downloaded provisioning profile with the embedded.mobileprovision inside the ipa archive bundle, and they don’t appear to differ.

I’ve deleted and created several provisioning profiles from the Apple Developer site at this point, so I wouldn’t think every one of them would be corrupt… The only capabilities I have enabled are the default ones – In-App Purchases and Game Center.

These are the build settings I’m using:

0 Likes

#4

Could you please run in terminal the following command:

codesign -d --entitlements :- your_app.app

and paste result here (you can hide your personal info).

It seems like there is two keychain-access-groups in this file for some reason.

2 Likes

#5

Thanks @AGulev ! There do appear to be two keychain-access-groups keys, yes.

Here’s the output – it isn’t formatting correctly here, so I’ll add it to a gist:

(I edited the BUILD DIRECTORY, MYTEAMID, and com.my.bundle.id.)

0 Likes

#6

Ok, I’ve checked my provisioning and found that I have only one element in keychain-access-groups, but I use old provisioning profile (I created it for a long time ago).

				<key>keychain-access-groups</key>
		<array>
				<string>MYKEYHERE.*</string>
		</array>

It seems like in new provisioning profile Apple has 2 elements as array in keychain-access-groups.

@astrochili has the same problem and I asked him to extract his entitlements directly from provisioning profile and he got this result:

                <key>keychain-access-groups</key>
        <array>
                <string>KEYHERE.*</string>
                <string>com.apple.token</string>
        </array>

This is the reason of the problem.

1 Like

#7

@AGulev Interesting! I confirmed that my provisioning profile has those same entries in it. Does this mean any iOS build created with a new provisioning profile won’t run? If so, I’m relieved it’s not my environment at least, but not sure where to go from here… :thinking:

@astrochili Have you had any luck getting an iOS build to run?

0 Likes

#8

With @AGulev’s help I found this workaround:

Build the game and get the YOUR_APP.app file. Then run in the terminal:

codesign -d --entitlements :- YOUR_APP.app

You will receive the output like this:

<?xml version="1.0"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="1.0">
    <dict>
        <key>application-identifier</key>
        <string>TEAM_ID.BUNDLE_ID</string>

        <key>keychain-access-groups</key>
        <string>TEAM_ID.*</string>

        <key>keychain-access-groups</key>
        <string>com.apple.token</string>

        <key>get-task-allow</key>
        <true/>

        <key>com.apple.developer.team-identifier</key>
        <string>TEAM_ID</string>
    </dict>
</plist>

Copy this output to any text editor and remove these two lines:

        <key>keychain-access-groups</key>
        <string>com.apple.token</string>

…and save as entitlements.plist.

Then just add this file to your Defold project and set it to Custom entitlements in the project settings.

1 Like

#9

Ticket for tracking: https://github.com/defold/defold/issues/4977

2 Likes

#10

@astrochili Thank you! I was able to get the build to run on my device using that technique. Have you submitted any production builds to Apple using this method yet, and if so, does anything need to change when using an App Store Distribution vs Development profile?

@AGulev Thank you for creating the issue and for your help with this! I’m glad the build is working, even if it’s just a workaround for now.

1 Like

#11

Can’t answer about production because don’t have any finished games on Defold yet.

But I think it’s really temporary bug affected by some updates by Apple that Defold will support in the next release. I think we should not worry.

2 Likes

#12

We shipped Interrogation on iOS a few months ago with no issues. Maybe they changed the format of the provisioning profiles since then.

2 Likes

#13

@astrochili That’s reassuring! Thanks again for helping me get up and running.

@dapetcu21 Good to hear that there weren’t any issues with the app review! And congrats on shipping, Interrogation looks really interesting! :slight_smile:

1 Like