I am new in iphone i am create application with static library. I am create static library and use this but when we launch the app in device this is give error -objc class refrence. i am not recognize how to solve this
have you linked the library in the project settings? check the field library search paths and put the path to the library there. check this for target settings also. Plus add the library to frameworks via right click->add->existing files.
I've had to add the -all_load linker flag to avoid problems with libraries that use categories on externally defined classes.
Here's some more information on it.
What does the -all_load linker flag do?
Related
I have started a small collection of helper code in a Swift Package for my own needs. If i include this package in my main project using Swift Package Manger and try to build it using Xcode Cloud, i get the following error:
ITMS-90334: Invalid Code Signature Identifier - The identifier
'AppulizeStandardTools-55554944b34e30d285943c0fa8b9aecb5744a53e'
in your code signature for 'AppulizeStandardTools_BFA0AAD86B154A1_PackageProduct'
must match its Bundle Identifier 'AppulizeStandardTools'
I haven't set any identifiers or code signing manually with regards to the package and the Package.swift is very simple.
What am i doing wrong here?
I lost half a day trying to figure this out, documentation is not plentiful on it atm.
It appears to be related to how XCode Cloud handles the signing for dynamically embedded frameworks... Not ideal if you are using a microcomponent architectural pattern.
Fix for this:
Go into your main target (executable) -> Frameworks, Libraries and Embedded Content section -> Change your frameworks to:
Embed & Sign => Do Not Embed
Go to Build Settings for each Framework and change the Mach-O Type from Dynamic to Static
There are some implications about how this would effect device memory, I found it to be pretty negligible in my case.
dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from: /var/containers/Bundle/Application/
Reason: No suitable image found.
Explanation of the error:
Your app could not able to find the AFNetworking Dynamic Framework in #rPath. This is the place (rPath), where we should need to place our third party or our custom Dynamic Frameworks for the system to search for Dynamic Frameworks. So that system will search the rPath folder and will load them lazily instead of statically.
Solution:
If you are using Cocoapods, then cocoapods will itself do this step for you. Let me know if you are not using Cocoapods. If you still face the problem, just run Pod install once again..
if you are building your own libraries then you should place them in embedded binaries.
It seems what you are using in AFNetworking is iOS11+, yet you've required it for your project, so when iOS10 searches its directories to find it, it finds nothing. The fact that the error says 'image' is just a fault on Apple's end.
Fix:
Under your project settings go to included frameworks, find AFNetworking and set the status flag from required to optional. Then, wherever you would use AFNetworking in your project, wrap it in the following:
if (#available(iOS 11.0, *)) {
//your AFNetworking code here (for iOS11+)
} else {
//comparable non-AFNetworking code here (for iOS10-)
}
Or just make your project require iOS11 under the deployment target flag.
I had the same issue, in my case the problem was that I had a certificate expired and marked as "always trust". I fixed it using the default setting for the certificates and deleting the expireds
I needed to create a framework (which requires a static library) for a project I'm working on. I used this tutorial to create the framework, then copied the static library into the project and it worked.
But, when I dragged the framework to an iOS project, it shows a ton of errors.
`Undefined symbols for architecture i386:"_OBJC_CLASS_$_SomeClassFromTheStaticLibrary",referenced from:_OBJC_CLASS_$_AnotherClass in MyFramework`
What I think is happening is that the iOS project wants to recompile the framework and it cannot, because it can't locate the static library. All errors disappear if I add the static library to the iOS project. This is what I want to avoid.
Basically I want to have the iOS project -> Framework -> Library instead of having the library in both the project and the framework.
I have tried adding the static library as a resource in the framework, but it didn't work.
I doubt this is possible. When you think about what is happening you will see the problem.
The framework is compiled and the static library is processed so that things like extra symbols are stripped out
The app is now compiled and linked against the framework which may or may not have had the symbols that the app is requiring
I did get this to work if ONLY the framework was using the static library (logical) but I can't find a way to share the code across the framework & the app.
If a symbol is hidden (either via Symbols Hidden by Default/GCC_SYMBOLS_PRIVATE_EXTERN being set to YES or __attribute__ ((visibility ("hidden"))) being applied to certain symbols), then that symbol will be available when statically linking the library, but not when dynamically linking the framework.
Ensure that the static library's symbols are not hidden, and you should be able to access them from your app.
I have followed this link to create custom framework. I have static library inside my framework and it works fine with that.
I have copied his steps in my blog for my understanding along with a script to make it universal.
I am trying to install app on device through private frameworks provided by xcode located at
/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/
path.There are two frameworks
DTDeviceKit
DTDeviceKitBase
These are also used by "iPhone Configuration Utility". I want the main header files of these framework.
I tried
#import <DTDeviceKit/DTDeviceKit.h>
but I get compiler error because the DTDeviceKit.h is not found.
I set the
library search path="$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks"
other linker flag=-framework DTDeviceKit -Wl,-rpath -Wl,/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks
options.
Anyone has done anything like this? or
Is there any way to know the header files inside a framework?
As header files for private frameworks are not included in the SDK, you will need to reverse eningeer header files from the binary. class-dump is a nice utlity that helps a lot here :
I have added an extension to NSData (base64 extension), which I kept over a separate infrastructure class lib project. But when i use this method from my main project i am getting an error like this: "-[NSConcreteData encodeBase64]: unrecognized selector sent to instance 0x121e60'".
But if i keep the same class in my main project itself, this will execute with out any issue.
I call this method in the following way:
[dev setToken:[token encodeBase64]];
Please suggest why this is not working if i put the extension in another project. (I am already using some other extensions, eg. for NSDate, like this with out any issue.)
Is this on iPhone OS 3.0? The 3.0 SDK broke the use of -ObjC, but you usually are able to link in categories for a static library by adding the -all_load option to Other Linker Flags within your target application.
The issue is that the metadata necessary to configure a category is usually stripped by the linker because it appears to be dead. If you add the "-ObjC" LDFLAG to your project it will tell the linker to link all the potential ObjC info even if it appears to be dead.