How to unlink a framework on program start - objective-c

I am developing for iPhone OS 3.1.3 and I need to use Dropbox API.
The problem is the Dropbox API requires at least iOS 4.2. Ok.
I decided to save the possibility of using the program under 3.1.3, but if it is 4.2 and higher, there will be Dropbox functionality.
To use Dropbox framework I needed to link another frameworks:
Security.framework
QuartzCore.framework
I have done this.
When I link Dropbox.framework to my project, the program works great on iPhone Simulator, but it cannot be started on my iPhone 3.1.3. There is an error in Output:
dyld: Symbol not found: _kSecAttrAccessible
Referenced from: /var/mobile/Applications/C1FC10E5-0A36-4DEB-BD27-5028C205C89D/Bus Time.app/Bus Time
Expected in: /System/Library/Frameworks/Security.framework/Security
in /var/mobile/Applications/C1FC10E5-0A36-4DEB-BD27-5028C205C89D/Bus Time.app/Bus Time
So the question is:
Can I detect the iOS version on the program start and unlink the framework?
Or could you offer an another way to use dropbox for 3.1.3?
Thank you for your answers. I appreciate it.

You cannot programmatically unlink a framework at runtime.
You can programmatically link a framework at runtime, e.g. by using the NSBundle APIs, or dlopen, or various other ways. If you do so, you have to then manually load the ObjC objects and/or C symbols you want.
Alternatively, you can weak-link the framework, which makes the runtime do most of the work for you. If it's there, it will be loaded in at startup, and all of its ObjC objects and C symbols will be available to you. Otherwise, all of its ObjC objects and C symbols will be null. So, all you have to do is check for null to decide whether to run the code that needs that framework.

Select the Security framework in your file list.
Expand the right sidebar (View > Utilities > Show Utilities).
Under 'Target Membership' change 'Required' to 'Optional.'

Related

Is there any DSYM file for .framework (besides app)?

I am a new guy in OC programming. Now I am involved in a framework development project.
I know the framework works as a library, which contains a group of methods. It's not an application that can run on devices.
Actually, our framework will work with customer's application. We want to investigate what happened inside our framework when customer's application crashed. So I want the 'DSYM' file of our framework, instead of an application.
As far as I know any iOS application does have corresponded 'DSYM', but I didn't find the 'DSYM' of our framework.
Does iOS framework project have 'DSYM'? If it does have, how can I obtain it?
By the way, I am using Xcode 8.1.
Thanks!
According to my observations, .dSYM files are generated for iOS dynamic framework built with Release configuration only.
After build succeeds, the debug symbols files can be found at these paths, for a device and simulator, respectively:
<Build_Root>/build/Release-iphoneos/<Product_Name>.framework.dSYM
<Build_Root>/build/Release-iphonesimulator/<Product_Name>.framework.dSYM
, where
<Build_Root> is usually a subdirectory within Derived Data directory;
<Product_Name>is the name of your framework.
Yes, you can generate dSYMs for dynamic frameworks. There are a few relevant build settings that control whether and where these files are generated:
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym,
DWARF_DSYM_FOLDER_PATH = "$(CONFIGURATION_BUILD_DIR)",
DWARF_DSYM_FILE_NAME = "$(PRODUCT_NAME).dSYM"
Obviously, you can set these to whatever you want, either in your project's build settings in Xcode (the project.pbxproj file) or as arguments to xcodebuild (depending on how you generate your framework).
DSYM (Debugging SYMbols) files generally store the debugging symbols for your app. And if app crash any where symbols replaced with appropriate method name so that it could help developer in a readable form. And for that you can use the crash log and they can be find in the iPhone where the app is installed. Each app and device have their own crash log.
Also please check this link it might help you.
Read Crash Report
Upload Symbols for iOS Framework
Hopefully these might help you or guide in the right direction.

Compiling/Running Cocoa Project implementing NSSharingServicePicker in 10.7.x

I am learning about Objective-C/Cocoa and have downloaded the source code to a popular TeX typesetter and loaded up the project in XCode to play around with it. Compiling fails, and all of the error messages I have seen (so far) have to do with something called NSSharingServicePicker not being recognized. I gather (from this SO question and this Apple documentation page) that this is a class not available in 10.7.x. It therefore makes sense why the code won't compile on my Lion machine.
My question is, I guess, why I am able to run the downloaded package of TeXShop on 10.7 at all? (According to the website, this version is for OSX 10.7 and up.) I am interested in making a few minor changes to this project; am I not able to check my changes/compile unless I'm using a Mountain Lion machine? Is there some kind of update I can download for coding/compiling purposes?
Assuming you are using Xcode 4.6.*, you should be able to set your project to use the 10.8 SDK and get past the compile errors. (That's the "Base SDK" build setting.)

What will happen if a framework get deleted from an app?

I was asked a question, what will happen when a framework is accidentally deleted from your device may be iphone or mac?
Whether your application crash or it will work without any error?
Please provide me answer with explainations.
You may get linking error. If framework folder is inside the application means its runtime linking.
OS X embeds an "install name" inside each dynamic library. This
install name is the path to where the library can be found when dyld
needs to load it. When you build an application that links against a
dynamic library, this install name is copied into the application
binary. When the application runs, the copied install name is then
used to locate the library or framework.
$ otool -D /Applications/Google\ Drive.app/Contents/Frameworks/Python.framework/Versions/2.6/Python
/Applications/Google Drive.app/Contents/Frameworks/Python.framework/Versions/2.6/Python:
#executable_path/../Frameworks/Python.framework/Versions/2.6/Python
so if you will delete Frameworks folder you will get Dyld Error.
Dyld Error Message:
Library not loaded: #loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle
Referenced from: /Applications/Transmission.app/Contents/MacOS/Transmission
Reason: image not found
If a framework is deleted, only software linking to that framework would be affected.
If it is a system framework, expect your system to start failing.
If it is a 3rd party framework, it should be limited in scope of impact.
If it is in your app bundle, and your app is code-signed, the removal of the bundled framework should prevent your app from launching.
It depends on if the application needs access to the framework you have removed.
If you application requires the framework then it will not compile.
If you dont need it, it will just compile like normal.

Google Api 64bit Objective-C

I want to implement in my Mac application the google API for uploading file on Gdocs, sadly I discovered that Google api for Objective-C are still in 32bit while my app is in 64bit with the new ARC support.
So before converting my app to 32bit I tried to build the google api in 64bit, I downloaded the .diff patch found here:
http://code.google.com/p/gdata-objectivec-client/issues/detail?id=30
and applied it.
Then I tried to rebuild the Google api in 64bit and it succeded (before there were errors), so I copied the Gdata framework in my project and I was able to build it without errors.
BUT, when I click play this is the error I retrieve:
dyld: Library not loaded: #loader_path/../Frameworks/GData.framework/Versions/A/GData
Referenced from: /Users/Xeo/Library/Developer/Xcode/DerivedData/GdocSync-fpcfhxbalzflkxdigudsndijtiol/Build/Products/Debug/GdocSync.app/Contents/MacOS/GdocSync
Reason: image not found
The framework is linked, I set it in the frameworks to link, soI don't really know how to do this, I would like to waste another bit of time before converting the app to 32bit!
EDIT: i was able to build it under xcode 4 with arc support only adding the sources into my app and building directly from there as explained in the google wiki.
No luck with the framework!
Try deleting the derived data from your app in the Xcode 4 organizer, give the target a good scrubbing and build again.

json-framework doesn't work with iPhone SDK 3.0

I can't seem to get my app to compile when using JSON-framework http://code.google.com/p/json-framework/ with iPhone SDK 3.0.
My app compiles fine for the simulator, but when I go to compile for my device I get a 'codesign error' code 1. I've followed all of the installation instructions correctly, and when I remove the 'Additional SDK' reference and 'Other Linker Flags: -Obj-C -ljson' it compiles just fine...but obviously I then can't use JSON in my app.
Any ideas?
You may want to just switch to the code version and not link in the static lib.
It should compile and work fine on 3.0.
On my own project, I too ran into this problem. I was not able to build my app for iPhone OS 2.x using the iPhone 3.0 SDK.
The fix was to set the following at the project level (Get Info):
BaseSDK to iPhone Device 3.0
iPhone Deployment Target to iPhone OS 2.x
Code Signing Resource Rules Path to the same 2.x plist (e.g. /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/ResourceRules.plist)
The last bit allows a distribution (app store) build to code sign correctly... Otherwise you'll encounter an error "object file format invalid or unsuitable" since the code signer by default will use the same resource rules as the BaseSDK (i.e. 3.0), which is unsuitable for a 2.x app.
Also, be sure to clear any of the above settings at the target level (again, via Get Info).
Phew.
Codesign error means you do not have a valid provisioning profile for the device you are trying to compile to, using the current built settings.
Can you build and deploy sample apps to your phone?
I started using the lovely json-framework for the iPhone but then suddenly found that if I compiled for anything greater than 2.1 for a device, that it would pop up with:
Codesign error: “object file format invalid or unsuitable”
It took me a long time to figure out what was going on, but thanks to a blog post, the fix is this:
On the project settings, on the build tab, search for “Code Signing Resource Rules Path” and set “$(SDKROOT)/ResourceRules.plist” as its value.
I’m not sure how it works as it looks like that is the path it already has, but hey, it seems to work!
that solves the codesign error i was getting, but now I cant compile on 3.0 for some other reason. i'm going to try to link to the code rather than the library.
Sounds like an issue you would want to discuss with the developers, see the support group.
It seems like the code signing isn't extending to the framework. Have you tried linking the framework differently?
And for French persons, here is a tutorial too here too (en Français)
But for your problem I think it's not about JSON but more with your key developer.