Re: Xcode Framework wrapper for Library ( Exposing library headers)
Re: Xcode Framework wrapper for Library ( Exposing library headers)
- Subject: Re: Xcode Framework wrapper for Library ( Exposing library headers)
- From: Jonathan Mitchell <email@hidden>
- Date: Mon, 06 Feb 2017 22:48:59 +0000
Its been a while since I wrapped my little noggin around this issue but perhaps this will help:
https://github.com/mugginsoft/Single-Object-Prelink-Framework-Demo <https://github.com/mugginsoft/Single-Object-Prelink-Framework-Demo>
There is a thread too, but the Apple list server seems to be on the beer again:
https://lists.apple.com/archives/xcode-users/2014/Apr/msg00079.html <https://lists.apple.com/archives/xcode-users/2014/Apr/msg00079.html>
Jonathan
> On 6 Feb 2017, at 22:04, Mr steve davis <email@hidden> wrote:
>
>
> I would be so grateful if someone could help me, I have been banging my head a against a brick wall for days on this now.
> Here’s a sample project if it helps… http://www.thingsidoatwork.co.uk/MyProject.zip <http://www.thingsidoatwork.co.uk/MyProject.zip>
>
> I'm creating a Framework wrapper round a static library. The header (MyLibrary.h) needs to be accessable from the ViewController.m file in MyProject
>
> MyProject
> MyFramework
> MyLibrary.h
> libMyLibrary.a
>
>
>
> #import "ViewController.h"
> @import MyFramework;
>
> @implementation ViewController
>
> - (void)viewDidLoad {
> [super viewDidLoad];
>
> [[[MyLibrary alloc]init]test];
> }
>
>
> I have set MyLibrary.h to public
> MyFramework.h contains the line #import <MyFramework/MyLibrary.h>
> 'Embedded Binaries' is set to MyFramework
> When I run the above code I get...
>
>
> Undefined symbols for architecture x86_64:
> "_OBJC_CLASS_$_MyLibrary", referenced from:
> objc-class-ref in ViewController.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
>
> The only way I have found to solve this problem is to create a private Class in MyFramework (called TestClass) and allocate MyLibrary. I assume this forces MyLibrary to be linked at runtime and accessable from ViewController.
> But this is ugly as hell, what am I missing?
>
> #import "TestClass.h"
> #import "MyLibrary.h"
>
> @implementation TestClass
> - (id)init {
> if (self = [super init]) {
>
> [MyLibrary alloc]; //solves the problem of MyLibrary being accessable from ViewController
> }
> return self;
> }
> @end
>
>
> Is there a compiler flag I’m missing that would help? I have tried all-load -ObjC etc but no luck.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden