Set WatchKit app name in Apple Watch app on iPhone without affecting User-Agent header

Originator:n.morev
Number:rdar://20952278 Date Originated:14-May-2015 11:53 AM
Status:Closed/Duplicate of 19880212 also Closed Resolved:iOS 9
Product:iOS Product Version:8.3
Classification:Other Reproducible:Yes
 
Summary:
During development of our WatchKit app we discovered that in order to set pretty and localizable WatchKit app name in Apple Watch app on an iPhone we need to change CFBundleName property in Info.plist file of the host app target. Before that it was set to $(PRODUCT_NAME) value. This turned out to be problematic because changing CFBundleName also affects the default value of User-Agent header in all HTTP requests made from the app.

We don't want to change the User-Agent header because our backend servers and statistics depend on it. Also, we'd prefer not to set User-Agent header explicitly on each NSURLRequest, because it involves a lot of code changes and it can be error-prone.

Steps to Reproduce:
1. Create a new WatchKit app project.
2. Set CFBundleName key to some value.
3. Add localized values for that key in strings file.
4. Run the watch app on simulator or on device.
5. Add any NSURLConnection HTTP request code to the host app target without explicitly setting User-Agent header value.
6. Run the host app several times with different localization settings and sniff HTTP request using Charles or some similar app.

Expected Results:
User-Agent header does not depend on CFBundleName key of the host app and stays the same for all localization settings. 

Actual Results:
User-Agent header contains localized and url-encoded value from CFBundleName key.

Version:
Xcode Version 6.3.1 (6D1002), iOS 8.3 (12F70)

Configuration:
iOS Simulator

Comments

The original report on this issue, Bug ID 19880212, is closed. The issue was resolved in iOS 9.

Duplicate of 19880212 (Closed)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!