Where you are located is a factor. I live in the Pacific Northwest and our black bears around here are small and skittish compared to the ones in the upper Midwest and East. Fish and Game did a study a few years ago and the average size was around 150lbs.
Now, I grew up in the woods and spent most of my youth exploring the mountains on horseback and on foot with nothing but a .22lr six-gun.
Having encountered dozens of black bears, I have never had one not run away at the first sight/smell of me. Same with cougars. Had a wolf check out my camp and watch me and my dog set up camp last summer. That was creepy.
But I do understand that hogs are a bit more temperamental and should be your main concern.
The first rule of cartridge effectiveness when it comes to animals is penetration. Mammals like bears and hogs have a lot more muscle and denser bones to bust through than humans.
The .45 acp is the worst choice because of it's large diameter and slower velocity. It's great on thin skinned humans, but doesn't penetrate very well with animals. I once stopped on a highway when another car had hit a deer and a deputy pulled up to investigate. He decided to put the deer out of it's misery with his .45 acp S&W 4506. He fired from about 6' away into the head. The first shot bounced off the deer's skull. As did the second. He finally found a flat part of the skull to get the bullet to penetrate and put the deer out of it's extended misery. That was pretty eye-opening to me and there have been countless other examples of similar failures to penetrate I've heard of over the past couple of decades since.
Now, 9mm is what I carry for my CCW, for now. I prefer the .40 S&W, but 15 rounds of hot 9mm in the same space as 10 rounds of .40 S&W has me currently carrying the Glock 19.
I used to carry a .40 S&W for my woods gun a few years ago and felt it was adequate for wolves and cougars and two-legged threats. I started reloading my own ammo and even casting my own solid lead bullets. With 190gr hard cast lead bullets in the .40 S&W loaded pretty hot, I did not worry.
But, I ended up buying a Glock 29, which is their compact 10mm. It is the best choice I have found for defense against woodland critters while being compact, light, reliable, and having acceptable capacity and stopping power for everything except large bears. As in 600lb Grizzly bears.
The great thing about the Glock 29, is that you can buy cheap .40 S&W ammo and shoot it in the stock Glock. No changes whatsoever. It works. Not sure about the XD series.
The downside to the 10mm is ammo cost. Plus, most commercial 10mm ammo is little more than warmed up .40 S&W. You can buy excellent HSM and Buffalo Bore 200gr hard cast loads that will stop a train, but they are expensive and have quite a bit of recoil.
If you reload, then 10mm is the answer.
I don't have any experience with the XD 10mm, but I have owned XD pistols in the past and like them, and I currently have an XDS 40 that I carry occasionally.
I think the advantages of the Glock platform are is the incredible amount of aftermarket support for them as well as the ability to fire .40 S&W for cheap practice rounds.
For mine, I've added a 4.5" KKM barrel for increased velocity for maximum effectiveness...