Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Commit

Permalink
Use Framework Versioning to prevent Runtime Duplicate Symbols
Browse files Browse the repository at this point in the history
Summary:
`FBControlCore` has some provisional Framework Version build settings enabled and is the only of the 4 Objective-C Frameworks to do so. `XCTestBootstrap` does not have versioning, but is embedded in both `FBSimulatorControl` and `FBDeviceControl` just like `FBControlCore` is. This poses a problem when `FBSimulatorControl` and `FBDeviceControl` are both loaded into the same process:

1) `fbsimctl` loads `FBSimulatorControl`, `dyld` loads the Frameworks in `FBSimulatorControl.framework/Frameworks` of `FBControlCore` & `XCTestBootstrap`.
2) `fbsimctl` loads `FBDeviceControl`, `dyld` loads the the Frameworks in `FBDeviceControl.framework/Frameworks`.
3) `FBControlCore` is not loaded as it has the same Framework version as was loaded in #1
4) `XCTestBootstrap` is loaded *again* since it has no versioning information
5) `dyld` complains about duplicate symbols at runtime.

Adding Versioning to `XCTestBootstrap` has the effect that `dyld` will be smart enough to not complain about duplicate symbols in `XCTestBootstrap`. This means that we can keep `FBSimulatorControl` as being completly (and independently) redistributable as a Framework as it will continue to bundle its dependencies, but also prevent runtime duplicate symbols.

Reviewed By: marekcirkos

Differential Revision: D3533943

fbshipit-source-id: bf9bc7562a1a4a6275d6d6089bf2da4825c9637e
  • Loading branch information
lawrencelomax authored and Facebook Github Bot 2 committed Jul 8, 2016
1 parent bb2d1ec commit c01ae50
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
12 changes: 12 additions & 0 deletions Configuration/Framework.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Adding 'Versioning' to the Framework will ensure that Duplicate Symbol Scenarios do not arise when the Frameworks are independently distributed
// Since FBSimulatorControl/FBDeviceControl both embed XCTestBootstrap & FBControlCore, the versioning of these Frameworks will ensure that dyld
// is aware of the embedded Frameworks in these Targets being identical and won't attempt to load them twice.

CURRENT_PROJECT_VERSION = 1
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1
DYLIB_CURRENT_VERSION = 1
DYLIB_INSTALL_NAME_BASE = @rpath
FRAMEWORK_VERSION = A
VERSIONING_SYSTEM = apple-generic
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/Frameworks
13 changes: 3 additions & 10 deletions FBControlCore/FBControlCore.xcconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// Import Shared Configuration
// Import Shared & Framework Configuration
#include "../Configuration/Shared.xcconfig"
#include "../Configuration/Framework.xcconfig"

// Target-Specific Settings
CURRENT_PROJECT_VERSION = 1
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1
DYLIB_CURRENT_VERSION = 1
DYLIB_INSTALL_NAME_BASE = @rpath
FRAMEWORK_VERSION = A
INFOPLIST_FILE = $(SRCROOT)/FBControlCore/FBControlCore-Info.plist
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/Frameworks
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBControlCore
PRODUCT_NAME = FBControlCore
VERSIONING_SYSTEM = apple-generic
PRODUCT_NAME = FBControlCore
5 changes: 2 additions & 3 deletions FBDeviceControl/FBDeviceControl.xcconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Import Shared Configuration
// Import Shared & Framework Configuration
#include "../Configuration/Shared.xcconfig"
#include "../Configuration/Framework.xcconfig"

// Weak-Link Xcode Private Frameworks
OTHER_LDFLAGS = $(inherited) -weak_framework DTXConnectionServices -weak_framework DVTFoundation -weak_framework IBAutolayoutFoundation -weak_framework IDEFoundation -weak_framework IDEKit -weak_library $(DEVELOPER_DIR)/../PlugIns/IDEiOSSupportCore.ideplugin/Contents/MacOS/IDEiOSSupportCore -weak_library $(DEVELOPER_DIR)/../PlugIns/IDESourceEditor.ideplugin/Contents/MacOS/IDESourceEditor

// Target-Specific Settings
DEFINES_MODULE = YES;
INFOPLIST_FILE = $(SRCROOT)/FBDeviceControl/FBDeviceControl-Info.plist
LD_RUNPATH_SEARCH_PATHS = @loader_path/Frameworks
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBDeviceControl
PRODUCT_NAME = FBDeviceControl
2 changes: 2 additions & 0 deletions FBSimulatorControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@
AA9B24D71D07F9BB00CEE14F /* FBiOSTargetPredicates.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBiOSTargetPredicates.m; sourceTree = "<group>"; };
AAA46E431C0CB92A009D6452 /* FBSimulatorControl.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = FBSimulatorControl.xcconfig; sourceTree = "<group>"; };
AAA55F641D0088E800BC4824 /* FBControlCoreTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = FBControlCoreTests.xcconfig; sourceTree = "<group>"; };
AAA5DE491D2F8F71008A36ED /* Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Framework.xcconfig; sourceTree = "<group>"; };
AAAA67C41BC4FED200075197 /* FBSimulatorControlFixtures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBSimulatorControlFixtures.h; sourceTree = "<group>"; };
AAAA67C51BC4FED200075197 /* FBSimulatorControlFixtures.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSimulatorControlFixtures.m; sourceTree = "<group>"; };
AAAA67C71BC5018500075197 /* TableSearch.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = TableSearch.app; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1308,6 +1309,7 @@
AA633F8A1CFD788F00A59C5F /* Configuration */ = {
isa = PBXGroup;
children = (
AAA5DE491D2F8F71008A36ED /* Framework.xcconfig */,
AA633F8B1CFD788F00A59C5F /* Shared.xcconfig */,
);
path = Configuration;
Expand Down
5 changes: 2 additions & 3 deletions FBSimulatorControl/FBSimulatorControl.xcconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Import Shared Configuration
// Import Shared & Framework Configuration
#include "../Configuration/Shared.xcconfig"
#include "../Configuration/Framework.xcconfig"

// Weak-Link Xcode Private Frameworks
OTHER_LDFLAGS = $(inherited) -weak_framework DVTFoundation -weak_framework DVTiPhoneSimulatorRemoteClient -weak_framework CoreSimulator -weak_framework SimulatorKit

// Target-Specific Settings
DEFINES_MODULE = YES;
INFOPLIST_FILE = $(SRCROOT)/FBSimulatorControl/FBSimulatorControl-Info.plist;
LD_RUNPATH_SEARCH_PATHS = @loader_path/Frameworks
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.FBSimulatorControl
PRODUCT_NAME = FBSimulatorControl
3 changes: 2 additions & 1 deletion XCTestBootstrap/XCTestBootstrap.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Import Shared Configuration
// Import Shared & Framework Configuration
#include "../Configuration/Shared.xcconfig"
#include "../Configuration/Framework.xcconfig"

// Target-Specific Settings
DEFINES_MODULE = YES;
Expand Down

0 comments on commit c01ae50

Please sign in to comment.