Xcode fails to link iOS + watchOS targets against universal shared framework

Originator:regexident
Number:rdar://33845255 Date Originated:August 11 2017
Status:Open Resolved:n/a
Product:Xcode Product Version:Xcode 9
Classification:Bug Reproducible:Always
 
Summary:
Given an iOS + watchOS project with a shared framework with the following xcconfig:

```
PRODUCT_NAME = $(TARGET_NAME)
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator
DYLIB_INSTALL_NAME_BASE = @rpath
OTHER_SWIFT_FLAGS = -DXcode

SDKROOT[sdk=iphone*] = iphoneos
VALID_ARCHS[sdk=iphone*] = arm64 armv7 armv7s
IPHONEOS_DEPLOYMENT_TARGET = 10.0
TARGETED_DEVICE_FAMILY[sdk=iphone*]  = 1,2
LD_RUNPATH_SEARCH_PATHS[sdk=iphone*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks

SDKROOT[sdk=appletv*] = appletvos
TVOS_DEPLOYMENT_TARGET = 10.0
TARGETED_DEVICE_FAMILY[sdk=appletv*] = 3
LD_RUNPATH_SEARCH_PATHS[sdk=appletv*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks

SDKROOT[sdk=watch*] = watchos
WATCHOS_DEPLOYMENT_TARGET = 3.0
TARGETED_DEVICE_FAMILY[sdk=watch*] = 4
LD_RUNPATH_SEARCH_PATHS[sdk=watch*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks

SDKROOT[sdk=macosx*] = macosx
VALID_ARCHS[sdk=macosx*] = x86_64
MACOSX_DEPLOYMENT_TARGET = 10.13
LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks
```

Xcode produces the following warning:

```
Target 'SharedFramework' of project 'UniversalFramework' was rejected as an implicit dependency for 'SharedFramework.framework' because its SDK is platform 'com.apple.platform.iphoneos' and it needs to match platform 'com.apple.platform.watchos'
```

alongside the following linker error:

```
ld: framework not found SharedFramework
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

I have attached a sample project with each setup step committed into git.

Steps to Reproduce:
Build the sample project either using "Build all" aggregate target or going through targets one by one.

Expected Results:
Builds successfully

Observed Results:
Linker error for watchOS target.

Interestingly the macOS target works fine with the shared framework.

Version:
Xcode 8, Xcode 9

Comments


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!