I'm writing a command-line tool that other developers will run. I'd like to extract the bundle id of the app from their Info.plist file. I can read the plist using something like PlistBuddy or Python's plistlib but I don't know how to reliably extract the $PRODUCT_NAME variable. How can I do this from a shell script?
            Asked
            
        
        
            Active
            
        
            Viewed 1,274 times
        
    1 Answers
2
            
            
        I'd like to extract the bundle id of the app from their Info.plist file
You can get the bundle ID from the plist using PlistBuddy:
/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" Info.plist 
The product name isn't likely to be available as that information is stored in the Build Settings, not the Info plist.
 
    
    
        James Webster
        
- 31,873
- 11
- 70
- 114
- 
                    Yeah it just prints $(PRODUCT_NAME), are you saying it is impossible to get this value in a terminal shell script? – JeremyF Apr 15 '22 at 15:41
- 
                    Ooof. 10 year old question. I'm afraid I haven't been an active developer for the last few years. I don't know about grabbing details from the build settings via the terminal now sorry. – James Webster Apr 15 '22 at 16:14
- 
                    This is fine, I ended up taking a different approach to manage all our apps and automations. – JeremyF Jul 19 '22 at 19:01
 
    