Reputation: 139
I have an Xcode workspace which features a project with an iOS Application target, and another project with a Framework target. The framework target is dependent on another framework, which is integrated in the form of an xcframework
:
Using regular OtherFramework.framework
would require it to be linked to MyFramework
and then embedded in MyApp
even though MyApp
doesn't require the framework itself. However when integrating with xcframework
, this project then fails to build with a No such module 'OtherFramework'
error.
Project settings:
Removing OtherFramework.xcframework
from the MyApp
target fixes the build issue, but then causes library not loaded
errors as the framework is not present in the application.
Demo project here: https://github.com/msaps/XCFramework-Link-Issue
How are you meant to link an xcframework
in an application and link in a dependent framework?
pyckamil just posted this article which explains the issue in detail: Everything wrong with XCFrameworks.
It turns out Xcode has an optimisation for the ProcessXCFrameworkLibrary
step which extracts the correct .framework
from an .xcframework
for the active build architecture. This is only run once which causes issues for additional targets that try to link the same framework.
This issue is resolved in Xcode 12.0
Upvotes: 10
Views: 14984
Reputation: 11
I had this issue as well after using xcframework
instead of framework
. So I changed my project structure:
The MyFramework Peoject
embed OtherFramework.xcframework
,Then make it exported using @_exported import OtherFramework
in MyFramework Project
. And the MyApp
just link MyFramework
but can both import/use MyFramework
and OtherFramework
.
BTW, It seems to custom the @rpath
and manual codesign the OtherFramework
.
Upvotes: 1
Reputation: 139
UPDATED - Resolved in Xcode 12.0
shinsuk came up with a reliable workaround that works by adding architecture-explicit framework search paths to ensure the correct .framework
within an XCFramework is found.
Details can be found in the README.
Upvotes: 3
Reputation: 971
IMO, It seems not xcframework issue.
Check out this answer: https://stackoverflow.com/a/59435627/2661407
Umbrella frameworks are not supported on iOS, watchOS, or tvOS.
OtherFramework.xcframework should be signed and embedded in your host app.
and add "@executable_path/Frameworks" setting into your MyFramework.framework > Build settings > Runpath Search Paths.
Upvotes: 1
Reputation: 1
I had the same issue as you, and after seeing your pbxproj I think it can be solved the same way.
Change your framework search path to recursive (either through UI or manually editing the pbxproj "$(SRCROOT)/../Frameworks"
=> "$(SRCROOT)/../Frameworks/**"
), like so: https://github.com/msaps/XCFramework-Link-Issue/pull/1/files
Upvotes: -1
Reputation: 93
Check build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
check the response Getting error "No such module" using Xcode, but the framework is there
Upvotes: 1
Reputation: 364
I had an issue like that as well. First, make sure if you have MyFramework.framework file within the same directory as MyApp.
Second, when building MyFramework.framework, make sure that OtherFramework.xcframework is as well in MyFramework's project directory.
And one more thing, check target SDK versions. They should be somewhere on the same level.
Upvotes: 0