Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8811301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:19:46+00:00 2026-06-14T03:19:46+00:00

I am building a static library for controlling an iOS external accessory. As part

  • 0

I am building a static library for controlling an iOS external accessory. As part of this, I want to present a minimal set of public headers to be distributed with the compiled library.

I have a class that needs to be public, but I want to create some framework private methods on it. I created a category for one of the public classes to add the private methods, including an initializer. This works fine for the project tests, but generates -[MyClass initMethodDefinedInCategory:]: unrecognized selector sent to instance error.

Category header:

#import "MyClass.h"

@interface MyClass (LibraryPrivateMethods)
- (id)initMethod:(NSData *)data;
- (int)someOtherMethod:(NSData *)data;
@end

Using class

#import "MyOtherClass.h"
#import "MyClass.h"
#import "MyClass+LibraryPrivateMethods.h"

@implementation MyOtherClass

#pragma mark - Instance Methods
- (id)initWithData:(NSData *)data
{
    self = [super init];
    if(self)
    {

        MyClass *mc = [[MyClass alloc] initMethod:data]; // errors here
        _property = mc;
    }
    return self;
}

I have tried adding the -ObjC linker flag as suggested in this Apple tech note. I also tried adding the -all_load flag as suggested in this SO answer.

EDIT: Realised I was only adding in XCode build, forgot to check build script, given below.

set -ex

INSTALL_PATH=$WORKSPACE/artifacts
[ -z $INSTALL_PATH ] || INSTALL_PATH=$PWD/artifacts

rm -rf $INSTALL_PATH
mkdir -p $INSTALL_PATH

PROJ=$SRCROOT/MyLib.xcodeproj

xcodebuild -project $PROJ -sdk iphoneos INSTALL_ROOT=$INSTALL_PATH/device install
xcodebuild -project $PROJ -sdk iphonesimulator INSTALL_ROOT=$INSTALL_PATH/simulator install

lipo -create -output $INSTALL_PATH/libMyLib.a $INSTALL_PATH/device/libMyLib.a $INSTALL_PATH/simulator/libMyLib.a
mv $INSTALL_PATH/device/Headers $INSTALL_PATH
rm -rf $INSTALL_PATH/device $INSTALL_PATH/simulator

# create zip for distribution.
(cd $INSTALL_PATH; zip -r ../MyLib-release.zip libMyLib.a Headers ../documentation/LibraryDocs/html ../documentation/LibraryDocs/docset)

Where abouts would I add the -ObjC flag to the build script?

Is there any reason that you cannot have an initializer method in a category? It seems possible as this Apple doc says

Category methods can do anything that methods defined in the class
proper can do. At runtime, there’s no difference. The methods the
category adds to the class are inherited by all the class’s
subclasses, just like other methods.

I then tried using a class extension, but i am not sure how to make the method visible to the framework classes only.

@interface MyClass ()
- (id)initMethod;
@end

If I then call [[MyClass alloc] initMethod] from another class in the library, I get a ‘No visible @interface for MyClass declares the selector initMethod’ error.

How can I make a method on an object only accessible to other classes in the framework and is not exported in MyClass.h ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:19:47+00:00Added an answer on June 14, 2026 at 3:19 am

    Could not get this to work within time allocated for the problem. I ended up removing the category and moving the initializer code into the MyOtherClass initWithData method.
    This compiles fine and works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a static library for use in an iOS project, and I want
I'm building a static library for iOS, and implemented the first unit test in
I'm building a static library that will be used in multiple iOS apps. In
I'm building a static library, MyLibrary , for iOS in Objective-C that bundles together
im building a small static qt library using VS2010, unfortunately, mysql got this error:
I made a static library with GCC. Building of the library was OK. When
I want to build a static library that requires openssl for iPhone. It can't
Possible Duplicate: Stable way to embed open-source code into static library in iOS? I
I'm building .lib ( static library ) for a large project and I'd like
I'm building a Cocoa Touch Static Library. How should I decide whether to copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.