13

I recently had to duplicate my own frameworks to be able to link them from the native watchOS 2 extension, because the platform is different. So for every framework X I have an X-watchos counterpart. Everything works fine in the simulator and when building directly to my devices, and it wasn't until I tried to archive that I got this linking error:

Linking error

I ran lipo -i on the built watchOS framework and sure enough, its archs are arm7 and arm64 instead of armv7k.

When I looked further into the built directory I noticed this:

Derived data structure

Both versions are symlinks to the same file, and because the have the same product name, they're being overridden. I could make them have different names, but that would make importing them really cumbersome.

Note that this is not a problem for 3rd-party frameworks because Carthage is already building them in separate directories.

EDIT 08/22/2015: I've filed a radar with a sample project: http://www.openradar.me/22392501

EDIT 08/24/2015: This has been acknowledged in Xcode 7 Beta 6 release notes as a known issue:

known issue

EDIT 09/9/2015: Xcode 7.1 Beta release notes hint that this is fixed, but I haven't confirmed it yet.

NachoSoto
  • 1,743
  • 13
  • 17

2 Answers2

1

This is working for me in Xcode 7.1.

Porter Hoskins
  • 571
  • 3
  • 12
0

I’m using a similar configuration with my own frameworks, but I set a different name when creating it in each platform (MyFramework and MyFramework-watchOS). Don't forget to set a common product name manually (mine is MyFramework on both) in the build settings tab of each framework.

CarlosGz
  • 396
  • 2
  • 6
  • That is exactly my configuration: as I mentioned, the target names are different (X and X-watchos) but the product name is X. – NachoSoto Aug 21 '15 at 14:16
  • Sorry, my fault. I took an example from an Apple sample project "Lister" and from a last year video session about frameworks and It is working fine in one of my projects... Hope you find a solution soon – CarlosGz Aug 21 '15 at 15:58
  • Could you link to that project? I'll take a look and maybe I'll see what's different there :) – NachoSoto Aug 21 '15 at 20:14
  • Of course: https://developer.apple.com/library/prerelease/ios/samplecode/Lister/Introduction/Intro.html make sure you are downloading the latest version. Please let us know how you finally solved your issue – CarlosGz Aug 22 '15 at 09:58
  • The sample project reproduces the same problem: `ListerforwatchOSiOSandOSX/Swift/ListerKit (watchOS)/ConnectivityListsController.swift:11:8: Module file was created for incompatible target armv7-apple-ios9.0: /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/ArchiveIntermediates/Lister/BuildProductsPath/Release-watchos/ListerKit.framework/Modules/ListerKit.swiftmodule/arm.swiftmodule`. I've filed a radar with another sample project: http://www.openradar.me/22392501 – NachoSoto Aug 22 '15 at 21:37
  • 1
    It’s so well explained, let’s see if its fixed in the next Xcode beta version – CarlosGz Aug 24 '15 at 07:48
  • Hey, as I suppose you had noticed (according to the release notes) that the new Xcode beta 6 seems to fix the Archiving issue. I have used a different product name for the watchOS framework as the notes indicates: “Workaround: Use a different product name (using the PRODUCT_NAME build setting) for the watchOS version of your framework. (22183332)” but after that, I’m not be able even to run the project because Xcode can’t find my framework’s headers files… I hope you get luckiest and can brin me some light on it. – CarlosGz Aug 26 '15 at 15:31
  • Yeah I added an EDIT to my question. That's not really a fix, more like an acknowledgement of the bug. As I pointed out in the original question, changing product names was always on the table, but that makes everything a lot more complicated. – NachoSoto Aug 26 '15 at 15:53