Swift / Xcode 6 - info.plist error

597 views Asked by At

I was messing around and I antecedently deleted the info.plist from my project I went to the bin but it was not there either. I tried running the game and it gave me this error:

error: could not read data from '/Users/PC-NAME/Docs/filename/filename/filename/Info.plist': The file "Info.plist" couldn't be opened because there is no such file.

Is there anyway that I could get all my code working again as I have put in hours and hours. I know it was stupid to mess around the the plist and that I should of made a back-up but I did not :/

2

There are 2 answers

0
Vakas On

To create .plist use File – New – File in Xcode and create a Resource file of type Property List. Select Next and name the file Info (the plist file type will be created automatically).

enter image description here

Make sure you mention the right package when creating the file as xcode will again give you the error if it doesn't find it at

'/Users/PC-NAME/Docs/filename/filename/filename/Info.plist'

0
Sandeep On

This is the minimum version of the content of info.plist file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>com.$(PRODUCT_NAME:rfc1034identifier)</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>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
</dict>
</plist>

Create a new file in the root directory of your project and name it info.plist. Now, paste this content inside the info.plist file and you are good to go.

Note, that if you were using storyboard it is not defined any longer. So, you will have to go to Project Target setting, General tab and set the storyboard manually by yourself.

You dont need to import the info.plist to xcode project. XCode tries to find it inside the physical folder structure. However, it is good to have it grouped inside your application. So, just drag the file into your project and uncheck copy if needed option.

One other thing to be careful, is that if it happens that you copy the info.plist in some wrong folder location, xcode might still complain. You could either place it in correct folder structure inside the root directory of your application or go to build settings for your target -> Search for Info.Plist File, and give location of the file manually.