A noob's Info.plist conversion to Twitter Kit 3 issue

ios

#1

Hi,

Update in a reply below

I’m fairly new to programming, so please bear with me.

I’m getting this error "couldn’t parse contents of ‘filepath/Info.plist’: The data couldn’t be read because it isn’t in the correct format" when I try to add the twitter kit 3 kit code.

1.I’ve tried to add the Twitter Kit 3 code while I’ve commented out the fabric code that’s there.
2.Placement doesn’t seem to make a difference matter (adding code after top or before the bottom of info.plist.)

I can’t seem to find the answer to on any forum that makes sense to me. I’ve updated the code in the app delegate and this is the only thing in the way of allowing me to move on. Do I need to update the code handeling the login portion before this works as well?

This is what my info.plist looks like while it fails (again I’ve tried with the Fabric code commented out). I’ve redacted keys and names.

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>Access to photos is required for posting</string>
	<key>Fabric</key>
	<dict>
		<key>APIKey</key>
		<string>redacted</string>
		<key>Kits</key>
		<array>
			<dict>
				<key>KitInfo</key>
				<dict>
					<key>consumerKey</key>
					<string>redacted</string>
					<key>consumerSecret</key>
					<string>redacted</string>
				</dict>
				<key>KitName</key>
				<string>Twitter</string>
			</dict>
		</array>
	</dict>
<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UIAppFonts</key>
	<array>
		<string>OpenSans-Regular</string>
		<string>OpenSans-Light</string>
		<string>OpenSans-Semibold</string>
	</array>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UIStatusBarTintParameters</key>
	<dict>
		<key>UINavigationBar</key>
		<dict>
			<key>Style</key>
			<string>UIBarStyleDefault</string>
			<key>Translucent</key>
			<false/>
		</dict>
	</dict>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>Redacted</string>
			</array>
		</dict>
	</array>
	<key>FacebookAppID</key>
	<string>Redacted</string>
	<key>FacebookDisplayName</key>
	<string>Redacted</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>fbapi</string>
		<string>fb-messenger-api</string>
		<string>fbauth2</string>
		<string>fbshareextension</string>
	</array>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>twitterkit-<consumerKey-redacted></string>
                </array>
            </dict>
        </array>
        <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>twitter</string>
            <string>twitterauth</string>
        </array>
</dict>
</plist>

#2

Update: I found this terminal command here: https://stackoverflow.com/questions/19642102/xcode-cannot-parse-contents-of-info-plist

It pointed out this line ‘twitterkit-’ . So ,I deleted ‘TwitterKit- and the <>’ and just added the key in their place. The app builds now without failure. Is this correct?


#3

Close!

the <consumerKey> in the docs means that whole string should be replaced by your consumer key, including the < and >.

If your consumer key was 98237yhufhliuy9428huwn, then the relevant part of the plist would be:

<array>
  <dict>
    <key>CFBundleURLSchemes</key>
      <array>
        <string>twitterkit-98237yhufhliuy9428huwn</string>
      </array>
  </dict>
</array>

FWIW, what you’re doing here is specifying URL schemes your app can open. When a user signs in via the Twitter app, the Twitter app will try to open a url like this: twitterkit-98237yhufhliuy9428huwn://login_callback. Since you’ve told iOS that this is a URL scheme you want to handle, iOS will open your app and pass in this URL.

If you leave off the twitterkit part, when the twitter app tries to open that url, no app installed can handle it.

Happy hacking!


#4

@sammybauch Thanks so much! I appreciate the time you took to provide me with this insight and help.