Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Addind a Third-Party Framework to the iOS-Framework #83

Closed
loretoparisi opened this issue Mar 18, 2014 · 10 comments
Closed

Addind a Third-Party Framework to the iOS-Framework #83

loretoparisi opened this issue Mar 18, 2014 · 10 comments

Comments

@loretoparisi
Copy link

Supposed to add a 3rd-Party framework the iOS-Framework, how to export this in the generated framework?
Let's say the Serenity framework project has a External.framework. As soon as I build the Serenity.framework linking the External.framework ( I added this .framework to the "Link Binary With Libraries") and add it to the Third Party example app, I have got an error:

Undefined symbols for architecture i386:
"OBJC_CLASS$_SBNotificationHub", referenced from:
objc-class-ref in Serenity(Widget.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

that is the object defined in the static framework External.framework I'm linking by the Serenity.framework in the ThirdParty app.

So far I have to import again the External.framework inside the ThirdParty project to make it work properly.

@GSatko
Copy link

GSatko commented Mar 26, 2014

See: #67

It is a bit funny, this is what I want to do with my SDK. I don't want the External frameworks hard linked to my framework product. Unfortunately I can't figure it out as I'm using both iOS-Framework and various Cocoapod frameworks, every time I build it is including the entire libPods.a.

Thus when I shove my framework into a dependent project I get to see the glorious duplicate symbols for AFNetworking and such.

@loretoparisi In your case this is the intended functionality of frameworks, if you are dependent upon other frameworks, for example CoreData.framework you simply have to make sure that the documentation for the framework you are designing includes a blurb for saying "Hey you need to include CoreData.framework in order for this to function", there are compiler warning flags you can set as well to warn the users of your framework that something is wrong.

@loretoparisi
Copy link
Author

Thanks. I can add that it's ok when you are including Apple's .framework packages, but in my case I have more than own frameworks from the same company (for different reasons) and I would like to pack them all together:

By example I would like to have a structure like that:

AppBundle
  | ----------- BundledFramework
                          |----------------- CoreData.Framework (so Apple it's ok), et simil.
                          |----------------- CompanyCoreFramework (we can see it as external as well)
                          |----------------- 3rdPartyFramework (external lib only)
                          |----------------- Another3rdPartyFramework (external lib only)

So it's easy to include all Apple's framework or ask other developers to include them. But in my case I have other frameworks (proprietary frameworks) that I cannot share to external developers. I can only bundle in my static library, wrap them and distribute them in my static bundled library framework.

@gtasko
Copy link

gtasko commented Apr 24, 2014

I need to accomplish the same task.

Is this resolved?

@kodeshpa
Copy link

@gtasko Follow this article. "Avoiding Dependency Collision".

http://pdx.esri.com/blog/2013/12/13/namespacing-dependencies/

@gtasko
Copy link

gtasko commented Apr 24, 2014

@kodeshpa Thanks, will read it in a moment. Also I followed to the #67 issue which is what I want to make and the conclusion is to use the libtool command tool to embed the framework.

libtool -static -o "${SRCROOT}/Products/YOURProject.framework/Versions/A/YOURProject" "${SRCROOT}/Products/YOURProject.framework/Versions/A/YOURProject" "${SRCROOT}/AFolder/ThirdParty.framework/Versions/A/ThirdParty"

The above should work, need to test it though.

I understand all the problems I introduce but it is what I've asked to. I also disagree in the process, but in the end it is a good practice and learning about all the libraries/frameworks internals.

Thank you for your answer.

@loretoparisi
Copy link
Author

@gtasko So using the libtool -static -o the static the ThirdParty.framework/A/ThirdParty will be embedded as a ThirdParty.a static library?

@gtasko
Copy link

gtasko commented Apr 25, 2014

@loretoparisi Yes, I have tested it and it works fine for me.

@gtasko
Copy link

gtasko commented Apr 26, 2014

@kodeshpa The tutorial needs some more specifications. Like we need to add in both the static libraries targets (project and ext) the compile source, if we don't then the ext compile sources are not just copied to the resulting .a with only adding it as dependency.

I followed all the instructions and nm -a libext.a or libMyLibrary.a has the AFNetworking (I test with) still with the AF prefix, I suppose it should be ABCAF****, right?

@gtasko
Copy link

gtasko commented Apr 26, 2014

OK, now I've made some improvement. I get the following in a test client that I also added AFNetworking as my static library which I generated .framework and linked to the client.

Undefined symbols for architecture i386:
"OBJC_CLASS$_SLK_AFHTTPRequestOperation", referenced from:
objc-class-ref in ResolveDependencies(MakeHTTPRequest.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

See the SLK prefix is what I set in the run script. But it seems that it can't find the symbols in the .framework.

Also I should mention that I had to add the AFNetworking classes to both static libraries target so it can be included in the main library target binary, or else it wasn't.

Any idea why I have the above issue with linking?

@Radhika-Geek
Copy link

@GSatko Can you please explain how to use this script and where.

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

No branches or pull requests

5 participants