Bug 187653 - libwebrtc.dylib Objective-C classes conflict with third-party frameworks
Summary: libwebrtc.dylib Objective-C classes conflict with third-party frameworks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-07-13 12:12 PDT by David Kilzer (:ddkilzer)
Modified: 2018-07-13 13:08 PDT (History)
8 users (show)

See Also:


Attachments
Patch v1 (122.57 KB, patch)
2018-07-13 12:32 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2018-07-13 12:12:11 PDT
libwebrtc.dylib Objective-C classes conflict with third-party frameworks that build using the same source base.

<rdar://problem/41896685>
Comment 1 David Kilzer (:ddkilzer) 2018-07-13 12:16:00 PDT
Here are the commands I used to add the attributes:

$ perl -pi -e 's/^(\@interface (RTC[^\s<;:]*)[^\(\)]*)$/__attribute__((objc_runtime_name("WK_$2")))\n$1/mg' `egrep -l -r '^@interface RTC' Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework | grep -v UnitTests`

$ perl -pi -e 's/^\@protocol (RTC[^\s<;:]*)/__attribute__((objc_runtime_name("WK_$1")))\n\@protocol $1/mg' `egrep -l -r '^@protocol RTC' Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework | grep -v UnitTests`

Note that the easiest way (when merging upstream changes) to update this is probably to remove these attributes, merge the update, then rerun the commands above.

We may also want to consider upstreaming a change that lets anyone define their own prefix for Objective-C classes and protocols to make this easier.  For now, we're doing the simplest thing possible by using the attributes directly (as I didn't want to introduce a header file that must be included in many other header files).
Comment 2 David Kilzer (:ddkilzer) 2018-07-13 12:32:31 PDT
Created attachment 344967 [details]
Patch v1
Comment 3 David Kilzer (:ddkilzer) 2018-07-13 12:33:29 PDT
(In reply to David Kilzer (:ddkilzer) from comment #1)
> Here are the commands I used to add the attributes:
> 
> $ perl -pi -e 's/^(\@interface
> (RTC[^\s<;:]*)[^\(\)]*)$/__attribute__((objc_runtime_name("WK_$2")))\n$1/mg'
> `egrep -l -r '^@interface RTC'
> Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework | grep -v
> UnitTests`
> 
> $ perl -pi -e 's/^\@protocol
> (RTC[^\s<;:]*)/__attribute__((objc_runtime_name("WK_$1")))\n\@protocol
> $1/mg' `egrep -l -r '^@protocol RTC'
> Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework | grep -v
> UnitTests`

I should note that this is the only source file that's NOT covered by the commands above:

Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm
Comment 4 WebKit Commit Bot 2018-07-13 13:08:45 PDT
Comment on attachment 344967 [details]
Patch v1

Clearing flags on attachment: 344967

Committed r233812: <https://trac.webkit.org/changeset/233812>
Comment 5 WebKit Commit Bot 2018-07-13 13:08:47 PDT
All reviewed patches have been landed.  Closing bug.