How can I find bundle id and package name for iOS in a Xamarin forms app? I'm able to find the package name of Android in Android manifest but no clue about iOS.
3 Answers
Look inside your info.plist
file. You'll see a key called CFBundleIdentifier
and it's in there.
Here's an example:
<?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>CFBundleDisplayName</key>
<string>My App Name</string>
<key>CFBundleName</key>
<string>MyBundleName</string>
<key>CFBundleIdentifier</key>
<string>com.example.myappidentifier</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>10.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>CFBundleVersion</key>
<string>47</string>
</dict>
</plist>
Other interesting keys are CFBundleShortVersionString
which have your app's version number (the marketing version number such as 1.0, 1.1.0 etc), and CFBundleVersion
which include your build number (1, 2, 3, etc).
Also note: .plist files are an XML format. You'll notice the <dict>
line that starts off a dictionary section. Inside that you'll see a series of <key>*</key>
lines, each followed by a value for that key, which could be a simple type like a string, or a more complex type like an array or even another dictionary etc. When reading/editing a .plist file, the value for each key is right below the key. In this example, the CFBundleIdentifier
has a value of com.example.myappidentifier
.
If you need to read your bundle id in code, you can add this property to a class in your Xamarin.Forms iOS project:
public String BundleId => NSBundle.MainBundle.BundleIdentifier;
With Xamarin.Essentials: App Information you can get that info and displayed inside your app
// Application Name
var appName = AppInfo.Name;
// Package Name/Application Identifier (com.microsoft.testapp)
var packageName = AppInfo.PackageName;
// Application Version (1.0.0)
var version = AppInfo.VersionString;
// Application Build Number (1)
var build = AppInfo.BuildString;
For further info take a look at this https://docs.microsoft.com/en-us/xamarin/essentials/app-information?context=xamarin%2Fxamarin-forms&tabs=android