Adding a framework to XCode 4 - objective-c

of course i did research before posting my question.
I looked at
How to "add existing frameworks" in Xcode 4?
Adding Framework in Xcode 4
Adding an OpenGL framework in Xcode 4
XCode 4 adding dylib
but whole thing is becoming wrong.
My goal: Add (CorePlot) framework to XCode Mac project (not an iPhone one)
My environment: OSX Lion 10.7, SDK Lion, XCode 4.1 (4B110)
My steps:
Opened XCode, created new project
Downloaded CorePlot into my libraries directory (like ~/Applications/LIBS)
Opened project preferences, via (+) opened dialog to add framework
Add existing framework (+ copy files to dest. group if needed)
Selected directory was ~/Applications/LIBS/CorePlot/Binaries/MacOS/CorePlot.framework/
DnD CorePlot to Frameworks Group
Added CorePlot to Build Phases > Link Binary with Libraries
and ran my project
what I got is this error message:
dyld: Library not loaded: #loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/metralight-hjuvuwlhgohrtdeepvcymnsaxomc/Build/Products/Debug/metralight.app/Contents/MacOS/metralight
Reason: image not found
And in fact, when I looked into given directory (app bundle) there was no directory Frameworks and so the linking cannot be successful
I have searched one more, and found, that I can create Build Rule and copy files into final binary bundle via some script, but is this only way how to do this?
Isn't there some option to just turn on/off copying linked frameworks to final bundle?
Note that CorePlot target '.framework' has Dynamic Library Install Name set to #loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot, so it is looking in right place in final binary bundle

After adding framework via "Add existing framework"
Go to Project Settings > Build Phases
In right bottom corner click Add buid phase > Copy Files
Select Destination > Frameworks
Drag&Drop framework to files list
And that's it.

Another important detail here - you must have the "Runtime search path" to be defined in the projects, it's empty by default.
Something like this:
LD_RUNPATH_SEARCH_PATHS = #loader_path/../Frameworks

Related

Missing fonts when building/running Appcelerator app from XCode

I've recently updated from Titanium w/3.5.0.GA SDK to Appcelerator Studio w/5.2.0SDK and can no longer build and run the appc (5.1.0 CLI) generated projects in XCode (7.2.1) without losing the ability to display my custom font resources (app/assets/fonts).
When building a project for iOS in studio (latest 4.4.0) and deploying to connected iPhone 6 (running 9.2) all fonts appear correctly in app. However when building and running the <projectname>.xcodeproject that is generated by appc during this process the same fonts do not show?
Is this related to https://jira.appcelerator.org/browse/TIMOB-19818 ? Is there any fix on the horizon if so?
I have always relied on modifying the generated projects to include other asset catalogs and manually alter the build and version numbers prior to appstore submission so am very curious to find a solution to this issue - all help much appreciated!
FYI - for reference, I've tried to build the same project generated in Titanium studio w/3.5.0.GA within the Latest XCode (7.2.1) as above and the fonts still work correctly so this issue seems to be with Appcelerator Studio with CLI 5.1.0 and SDK 5.2.0 combination.
You can follow this below two steps. This is a workaround, might work for you.
Step 1: Grab resource files from debug ipa:
a. Build a debug version for your iPhone device.
b. After the app has successfully launched on your iPhone, navigate to the ipa file in the debug build folder. Click right on the file (or cmd-click) and choose to uncompress the file
c. In the extracted archive find the payload file. Also right click on the file (or cmd-click) and choose to show its contents.
d. You should now see your resource files and folders. Select all the required files and folders and copy them in some new folder.
Step 2: Add files to XCode project
a. Open the build XCode project with XCode
b. In the left column right click (or cmd-click) on your project
c. Choose "Add Files to [project name]"
d. In the file dialog multiselect your files and folders you copied from the debug ipa in step 1
e. That's it. Now archive your product and submit it.

Xcode: how to build a static library project correctly?

This question will be easy for Xcode pros but for a MonoTouch developer it seems to be impossible to resolve. :-)
I'm using Xcode 4.5 and I want to target iOS 5.1 and above and iOS Simulator 5.1 and above.
I have a a library project here and it is coming with a prebuilt binary named "DemoLib" (no extension and it is 11MB in size). The library is a fat lib for Simulator and iOS 5.1+.
I can use that library without any problem.
However if I try to build the library myself, I end up with a "DemoLib.a" file (notice the extension and the size of 30MB). How can I get the same build result? What is a .a file compared to the file without extension?
I tried to build the project "for running", and "for archiving" in Xcode. Both results in the same 30MB .a file.
I was expecting some dropdown in Xcode where one could select "DEBUG" or "RELEASE" build and the latter one would create the smaller lib.
Of course I could never tell without seeing the framework's project file. Having said that, there is an excellent guide to creating and compiling iOS frameworks here: https://github.com/jverkoey/iOS-Framework
Using the above guide, you should be able to recreate your framework's project from scratch, add the files you have to it, and properly compile it.
Hope this helps! :)
Did it come with a Makefile? Create a new target, set the build settings of the target to what's in the Makefile, then set your project to depend on that new target.
A file with the .a is a static library, which means it depends on nothing external and all the code it needs is compiled inside it. I think no extension generally implies dynamic library, which means it'll depend on some dependencies being present on your system to link against. Maybe that's why the .a is so much bigger. I think Xcode will build static by default because iOS does not allow the use of dynamic libraries.
The dropdown for what to build is in your scheme. Command+shift+< to view your scheme. Within the scheme you can edit which environment each method of building will use.

Loading Growl in my Mac app: Unable to read symbols

I am trying to load Growl so I can use it in my Mac app, but I keep getting this error:
warning: Unable to read symbols for #executable_path/../Frameworks/Growl.framework/Versions/A/Growl (file not found)
warning: Unable to read symbols from "Growl" (not yet mapped into memory).
What does this mean and how can I fix this problem?
I guess there is a step I missed. Don't forget to do these steps:
Download the Growl framework from the Downloads page.
Copy the Growl framework to your application's project folder (or any subdirectory of it).
Add the Growl framework to your project, making sure that all the relevant target checkboxes are checked. The header files in the framework use UTF-8 encoding.
Add a Copy Files phase to your application's target (App target > Build Phases > Add Build Phase).
Get Info on the Copy Files phase.
Set the destination to “Frameworks”, with no subpath (clear the field).
Drag the framework from the group tree into the Copy Files phase.
From now on, your application will compile and link using the Growl framework inside its bundle.
Make sure you have the latest version of Growl installed on your machine, as well as the latest framework (build the Growl framework project that your app is using).

How do I use a new framework I have built?

I have had some issues with the AWS IOS SDK framekit, since it was not built to work with OSX apps. I found a modified version of the SDK that Brad Larson created.
The directory structure looks something like:
AWSiOSSDK.framework/
src/
--Amazon.Runtime/
--Amazon.S3/
..
--AWSCocoa/
----AWSCocoa_Prefix.pch
----AWSCocoa.xcodeproj
----etc
--include/
So if I go into the xcode project, and build AWSCocoa it compiles. But when I look at the timestamp on the AWSiOSSDK.framework, it hasn't changed. So I don't know what compiling this AWSCocoa gets me, or where I can find the files it creates. So assuming that building AWSCocoa.xcodeproj is supposed to build a new version of the framework compatible with OSX development, where do I find and link what I've built?
The AWSiOSSDK.framework bundle is a precompiled framework, probably left over from my earlier experiments in making a Mac version of this (since you can't use frameworks like this with iOS, only static libraries). Ignore that.
If you are using Xcode 4, your built framework will be created somewhere in your ~/Library/Developer/Xcode/DerivedData/ directory. To find where it lies, go to your project navigator in Xcode 4, expand the Products group, right click on AWSCocoa.framework, and select Show in Finder. This is no different from any other third-party framework you would compile.
Nominally, you'll want to add this framework as a target dependency in your application so that it is built alongside that. You'll also have to make sure that the framework is copied into the appropriate location within your application bundle so that it can be used by your application at runtime.

Can't add (Growl) Framework to Release version of my App

I've created a new App and want to test it in a release version. So I copied the Growl Framework to my project folder and added into XCode.
Then I copied the new files in the target in my project and copied the Growl.framework to the new "Copy Files" Framework folder in "Targets". When I debug my project, it's all right, but if I change the version to "Release" and then Build, there is the Red "1" on my XCode icon in the Dock. I dont know why this error comes; I've searched in Google but I can't find anything.
Can anyone Help me please?! Here is the Picture of my Copied Files:
XCode http://b1.s3.quickshareit.com/bild15ead2.png
Try ordering the Copy Files phase above the link phase.
When i debug my Project, its all right, but if i change the Version to "Release" and than Build -> there is the Red "1" on my XCode icon in the Dock,
Well, what does the error say?
alt text http://b2.s3.quickshareit.com/bild23a027.png
"malformed object: Unknown load command 5"
This usually indicates that you have a binary that was built on a later version of Mac OS X (e.g. SnowLeopard) and you're trying to link it on an earlier version of Mac OS X (e.g. 10.5 Leopard).
Ensure you have a correct version of the Growl framework for your development environment and OS.