Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Adjust as dependency for my framework, but getting error my framework get consumed #582

Closed
IamSaurav opened this issue Dec 15, 2021 · 20 comments

Comments

@IamSaurav
Copy link

Failed to build module 'ABC.xcframework' for implementation due to the errors above. The textual interface may be broken by project issues or a compiler bug

@uerceg
Copy link
Contributor

uerceg commented Dec 15, 2021

Hi @IamSaurav,

I am not entirely sure I understand your setup. Can you exaplain it a bit more in detail and what kind of error are you getting?

@IamSaurav
Copy link
Author

IamSaurav commented Dec 15, 2021

Sure @uerceg I have a project (ABC) which is shared as framework. ABC internally use Adjust though pod. I want to create ABC.xcframework and share with other who will be using it. Earlier this was a .framework but now when I create XCFramework and when someone use it in their project, it throws error.

The error are ->

  1. Failed to build module 'ABC.xcframework' for implementation due to the errors above. The textual interface may be broken by project issues or a compiler bug

  2. 'ADJEvent' is not a member type of class 'Adjust.Adjust'

When you create XCFramework you need to enable BUILD_LIBRARY_FOR_DISTRIBUTIOn="YES, which I did.

Primary reason is Name of the Class is same as name of the Framework. (Both are Adjust)

@genadyb
Copy link
Contributor

genadyb commented Dec 16, 2021

Hello @IamSaurav,
We would like to assist you in resolving this issue and we'd like to get more details about your setup.

First of all, could you look at the following thread - is this the same issue you have?

Second,
Could you kindly provide us with the following information:

  • How have you integrated the Adjust framework into your (ABC) framework via cocoapod - as static library or as a dynamic one.
  • What type is your framework (ABC), your are building the xcframework based on? Dynamic or static?
  • What Xcode version are you using?
  • In case you build your products using any custom script, please share it if possible.

Looking forward to get the detailed information to help you with this issue.

Thank you,
Genady.

@IamSaurav
Copy link
Author

@genadyb Thanks for replying. I did look at the thread but it's hacky way to solve as it find and replace string in compiler generated file .swiftinterface. This may break at any time.

I have attached the sample project, please have a look.

How have you integrated the Adjust framework into your (ABC) framework via cocoapod - as static library or as a dynamic one.

  • It's a static framework

What type is your framework (ABC), your are building the xcframework based on? Dynamic or static?

  • Static

What Xcode version are you using?

  • Xcode 13.1

In case you build your products using any custom script, please share it if possible.

  • There is no custom script, I just build targeting both Simulator and Device, then execute the xcodebuild command to generate XCFramework.
    xcodebuild -create-xcframework -framework ~/Desktop/ABC/ABC_sim.framework -framework ~/Desktop/ABC/ABC_device.framework -output ~/Desktop/abc.xcframework

AdjustIssue.zip

Screenshot 2021-12-20 at 11 58 52 AM

@IamSaurav
Copy link
Author

Team, Any update on this issue?

@genadyb
Copy link
Contributor

genadyb commented Dec 28, 2021

Hi, @IamSaurav .
Thank you for providing these details.
We are back from our vacation next week, so we will be in touch shortly.

Thank you,
Gena.

@genadyb
Copy link
Contributor

genadyb commented Jan 17, 2022

Hi, @IamSaurav .
Sorry for a bit delayed answer.

We looked into this issue and would like to clarify some things:

  • From the example projects you've sent us, we see that your ABC library is a dynamic framework and not the static one as you mentioned.

  • Adjust SDK has been integrated using cocoapods as a dynamic framework too - you are using use_frameworks! in the Podfile.

If this configuration is correct, you will have to distribute your ABC framework along with Adjust framework, because ABC framework doesn't contain Adjust symbols.
We think that it's the exact reason why you've added the Adjust framework as a pod dependency in your example HostApp project, that, again, contradicts the goal of single ABC framework distribution.

In addition to all mentioned above, it's not clear whether you want to expose Adjust public interface/classes to ABC framework consumers (it was done implicitly in your ABC framework project).
In this case you will have to distribute ABC framework together with Adjust framework as well.

So, assuming the configuration and a way of usage in the example projects you've sent is correct, and you are distributing both frameworks, there is indeed an issue you clearly described:
ADJEvent is not a member type of class 'Adjust.Adjust'

And it does related to Adjust project/podspec.
Unfortunately, in addition to Adjust SDK podspec name Adjust, the project contains also the main public interface class Adjust.
It causes the swift compiler to fail resolving symbols correctly.
Please see the following thread with link to a Swift known and open issue.
https://stackoverflow.com/a/66551277

So, the fastest way to resolve you problem, as I already mentioned in previous comment, is to remove a redundant Adjust word in all *.swiftinterface files in your ABC.xcframework / ABC.framework.

In your example case, from:

// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.5.1 (swiftlang-1300.0.31.4 clang-1300.0.29.6)
// swift-module-flags: -target arm64-apple-ios15.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -module-name ABC
@_exported import ABC
import Adjust
import Foundation
import Swift
import _Concurrency
public class EventManager {
  public init()
  public func logEvent(event: Adjust.ADJEvent)
  @objc deinit
}

to:

// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.5.1 (swiftlang-1300.0.31.4 clang-1300.0.29.6)
// swift-module-flags: -target arm64-apple-ios15.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -module-name ABC
@_exported import ABC
import Adjust
import Foundation
import Swift
import _Concurrency
public class EventManager {
  public init()
  public func logEvent(event: ADJEvent)
  @objc deinit
}

Currently, we cannot support it automatically using our podspec - we will have to either alter Adjust SDK project (might have a backward compatibility implication for current Adjust SDK users) or publish a new podspec and it might take a while.

If you are not supposed to expose any public Adjust symbols, you might consider to integrate Adjust SDK as a static library framework.

Please let us know whether it's a possible option for your use case, then we can look into this solution.
Some work should be done there from our side as well, since it's also not automatically compatible to be integrated into swift frameworks via cocoapods.
Please assist in clarifying your framework configuration/usage details, I mentioned above, and let us know what's the best way we can help you to solve this issue.

Thank you,
Genady.

@IamSaurav
Copy link
Author

IamSaurav commented Jan 19, 2022

@genadyb
Manually finding and replacing Adjust. is not a reliable solution. It may break in future releases. Can you provide a stable version of your framework which resolves this issues.
Best solution I can think of is to rename it and publish as a major version. This issue other devs also might face so it's better to resolve now.

@uerceg
Copy link
Contributor

uerceg commented Jan 19, 2022

Hi @IamSaurav,

I definitely think that we're on the same page when it comes to what the best solution is. 👍 Unfortunately, we are not able to this in short notice. As you might have noticed, major releases haven't been something we were up to lately (it's been more than 7 years since v4 was released). However, we are currently working on pretty big SDK update (feature and structure wise) which we aim to release as v5 later in 2022 and this is the moment when we can also pack this breaking change (among others which v5 will bring) into that release.

In the meantime, we are unfortunately unable to introduce any breaking changes to existing users. Thing which might be done (not a huge fan of it since it's not really tidy, but it might work) is to maybe consider pushing new pod to Cocoapods repository where we would fork official SDK version and add the changes so that SDK can work in setup described in this issue. And then the day when v5 is released, we would retire that pod and ask people who are using it to switch to official pod. What are your thoughts on this idea?

@IamSaurav
Copy link
Author

@uerceg
Second approach that you mentioned is to access Adjust from your fork sounds like an apt solution for time being, but can you explain how exactly you will be publishing the fix from the Fork and through cocoapod.
And how we will be consuming it and what will be changes we will have ti do.

@uerceg
Copy link
Contributor

uerceg commented Jan 25, 2022

Hi @IamSaurav

We will try a different approach (we'll be testing it this week). Separate pod remains an option, but easier solution might be to make changes which will make our SDK to play nicely with your use case as part of a separate public iOS SDK repo branch and then you can add Adjust via Cocoapods from that branch. Some changes specific to this might be needed to be done on your end (currently appears that we might need rename Adjust class into something else, potentially AdjustSdk and only change you'd need to do would be to replace [Adjust methodCall]; in your app with [AdjustSdk methodCall]; while using SDK from this branch. Fixes and patches wise, you would not need to worry, we would make sure to always update this branch with each new SDK release.

Will keep you posted on the topic.

@genadyb
Copy link
Contributor

genadyb commented Jan 26, 2022

Hello, @IamSaurav.
Thank you for the patience.
Please do the following changes:

  1. Please replace an Adjust reference in your framework's and application's pod files with the following line:
    pod 'AdjustSdk', :git => 'https://github.com/adjust/ios_sdk.git', :branch => 'podspec'

  2. Please change the module name you're importing in your framework's and application's code from Adjust to AdjustSdk.

Please let us know if it works for you.
Thank you,
Genady.

@IamSaurav
Copy link
Author

IamSaurav commented Feb 10, 2022

Thanks @genadyb for helping on this. However we can't define branch in podspec dependency, because Adjust is a dependency of our framework. So when we will release our framework we need to add Adjust as dependency in podspec.

eg.
s.dependency = 'Adjust', '~> 1.0.0'

May I know when can we expect a release the fix?

@IamSaurav
Copy link
Author

@genadyb Any ETA for the Xcframework support?

@wweevv-johndpope
Copy link

wweevv-johndpope commented Sep 5, 2022

Because there's a package.swift you can try this
https://github.com/unsignedapps/swift-create-xcframework

brew install mint
mint install unsignedapps/swift-create-xcframework
swift create-xcframework --list-products
swift create-xcframework Target1 Target2 Target3...

UPDATE -
there's a known swift problem for xcframeworks where class + module can't be same name
swiftlang/swift#56573
workaround is rename one of them.

@Aditi3
Copy link
Member

Aditi3 commented Oct 14, 2022

XCFramework support has been added in our latest release version 4.32.1.

In case you have any other questions/concerns about this one, feel free to comment/reopen it. Cheers!

@Aditi3 Aditi3 closed this as completed Oct 14, 2022
@IamSaurav
Copy link
Author

IamSaurav commented Oct 14, 2022

@Aditi3 @genadyb Still the same issue is reproducible! Please reopen the bug
Screenshot 2022-10-14 at 2 27 12 PM

@arnaumartifont
Copy link

do we have any news on that? I've been trying the same so far with a custom framework instead of Adjust and looks like it's a limitation to the system itself.

@dagronf
Copy link

dagronf commented Dec 18, 2023

I stumbled across this bug while trying to fix a similar issue in my own library. Seems to be a name resolution limitation of the Swift compiler at this point.

https://forums.swift.org/t/frameworkname-is-not-a-member-type-of-frameworkname-errors-inside-swiftinterface/28962

@genadyb
Copy link
Contributor

genadyb commented Dec 20, 2023

Hello, @dagronf .
Thanks for the input.
Yeah, we are aware of the root cause for that issue.
Unfortunately, aligning our repo to be supported by this use case will produce a backward compatibility break for existing customers.
We are hard working now to release next generation version (v5) of our SDK in 2024.
There we will take care of this issue as well.

Thank you.
Have a great holidays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants