Invalid 'Podfile' file syntax error, unexpected $undefined, expecting '}'

20,154

Solution 1

Assuming you correctly copied your Podfile over there needs to be a newline between those two lines.

platform :ios, '7.0'
pod 'RestKit', '0.21.0'

Also as of a relatively new version of CocoaPods you actually don't need that first line, the command line tool will determine the correct OS based off of your project's settings.

Edit:

From the new output you posted it looks like your Podfile isn't actually a plain text file. You should recreate it in an editor like Sublime Text and make sure it saves as a plain text file.

Solution 2

I got error

Invalid `Podfile` file: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
pod 'MBProgressHUD'

becasue I was declaring Pod files like

pod 'SlideMenuControllerSwift',
pod 'MBProgressHUD'
pod 'SDWebImage'

there is one "," (colon mark) in above podfile name pod 'SlideMenuControllerSwift',. I just removed the colon mark. It worked.

correct way:

pod 'SlideMenuControllerSwift'
pod 'MBProgressHUD'
pod 'SDWebImage'

Solution 3

I was faced same problem when, I changed my MAC.

1- Make setup - Pod setup or update

So I created a new test project -- And open terminal Run these command

cd /path your project
pod init
// add any pod in your pod file 
pod install

and then you can update pod in your old project .

Share:
20,154
user2885928
Author by

user2885928

Updated on September 14, 2020

Comments

  • user2885928
    user2885928 over 3 years

    I am trying to install a pod in project. But i am getting this error:

    Invalid 'Podfile' file syntax error, unexpected $undefined, expecting '}'.

    Podfile contains:

    platform :ios, '7.0' pod 'RestKit', '0.21.0'
    

    The terminal shows following message:

    [!] Invalid `Podfile` file: compile error
    /Users/work/Desktop/tg/RESTKitDemo/Podfile:1: syntax error, unexpected $undefined, expecting '}'
    {\rtf1\ansi\ansicpg1252\cocoartf1265
    ^. Updating CocoaPods might fix the issue.
    
    #  from /Users/work/Desktop/tg/RESTKitDemo/Podfile:1
    #  -------------------------------------------
    >  {\rtf1\ansi\ansicpg1252\cocoartf1265
    #  {\fonttbl\f0\fmodern\fcharset0 Courier;}
    #  -------------------------------------------
    

    Can i know what is the problem with my podfile?

  • Keith Smiley
    Keith Smiley over 10 years
    From the new output you posted it looks like your Podfile isn't actually a plain text file. You should recreate it in an editor like Sublime Text
  • Marco
    Marco over 8 years
    @Keith, your mention about deleting the first line was very helpful today. Thanks a lot.
  • Kunal Gupta
    Kunal Gupta about 7 years
    same was the case with me , i has accidently added an extra alphabet after declaring the pod.