iOS framework resource files - frameworks

I have created a framework with bundle files. Bundle files are under resource folder inside the framework. So my problem was whenever someone need to integrate the framework in their project then they have to drag and drop the bundle file from framework resource folder to project. Is possible to programmatically link the framework resource file and read it inside the project?

To include the resource bundle, select the target of your framework, and in the Build Phases > Copy bundle resources, click on the + button and add any resource bundle which you wish to have packaged into your framework.
When you build the framework, the resource will be copied. Make sure that this file exists though or you'll get a build error.
If you go in "Edit Schemes" for your framework project, in the "Build" section, you can add the resource file, so that when you will build the framework, it will also rebuild the resource bundle.

Related

Link a binary framework to both Pod Target and main app project

I have a library project which was installed via Pod into my main project. That library project use a framework. I didn't or actually couldn't embed that framework in the library project cause of making Umbrella Project and this is not recommended by Apple.
So I tried to embed it in my main project but the library project in Pod couldn't see it so that lead to error "No such module"
So how I can link the framework which embedded in the main project to that library pod target.
Ok. I'm able to make it work. Just drag the folder on main project which contain the framework in your pod target project framework search path. It will automatically transform a path like this
"$(SRCROOT)/../"

Create Swift framework (revisited)

I have read Create and import swift framework (and many more) but it does not work. Here's what I did: I created a vanilla framework and added a simple Test.swift.
This builds with no issues and I guess that this should be a valid framework containing my Test class.
Now I import this framework to another vanilla app:
But trying to access my framework fails:
With the information available from your question, "no such module" can mean that you either aren't linking against the framework, or the framework is not in the framework search path. Further, it looks like you have dragged the built framework directly into the dependent project, because I don't see the project where FW.framework included either as a top-level project in a workspace, or as a project dependency (i.e. you have not dragged FW.xcodeproj into the project navigator when you have FrameworkUse open). There are a few ways to resolve this:
Drag FW.xcodeproj into the project navigator somewhere under the FrameworkUse project (this will add FW.xcodeproj as a subproject to the FrameworkUse project). Then go to build settings and a) add the FW.framework target as a target dependency to the FrameworkUse target, b) add the framework (from the Products group under FW.xcodeproj) as an embedded binary.
Drag FW.xcodeproj to the top level in the project navigator when you have FrameworkUse project open. Xcode will ask if you want to create a new workspace (unless you already had a workspace open, at which case FW.xcodeproj will be added to the workspace). Similarly as with the above option, go to build settings and a) add the FW.framework target as a target dependency to the FrameworkUse target, b) add the framework (from the Products group under FW.xcodeproj) as an embedded binary.
If you really want to depend on the built FW.framework instead of expressing a build dependency to it with either option 1 or 2, you need to a) add the framework as an embedded binary, and b) go to Build Settings and add the directory containing the FW.framework (whose location you can find by opening it in Finder into "Framework search path", for instance "$(PROJECT_DIR)/Frameworks" if Frameworks under the project directory is where you place built frameworks).

iOS Static Library as a Subproject of a Project That Has Custom Build Configurations?

I'm trying to share code between multiple Xcode projects. I've followed Apple's notes on creating a static library subproject within a project:
http://developer.apple.com/library/ios/technotes/iOSStaticLibraries/iOSStaticLibraries.pdf
This works great! However, when I follow the same instructions using my own project, I find that the header files I make public in the static library can not be found by code within my app.
This is because my project uses custom build configurations. I have one for Ad Hoc builds, App Store builds, etc.
For example: when I build the project using a build config called "Ad Hoc", the static library subproject builds the Release configuration and copies its public headers to a folder called "Release". The main project then fails to build, complaining that it can't find headers that I'm importing from the static library. The errors appear in the Issue Navigator as: Lexical or Preprocessor Issue
So my question is: how do you set up a static library as a subproject of a project that has build configurations that the library doesn't?
I came across this issue when making my custom project templates.
Add "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)" to the "Header Search Paths" and "User Header Search Paths" for any build configurations you use Archive with and make sure it is set to be "recursive" as opposed to "non-recursive". This will tell your app to search the "Release" directory in your build directory for header files.
The problem is that for Debug builds ALL header files are copied to a single directory under derived data. But when you archive the files are copied to a folder named after the build configuration. So when you do a "Ad Hoc" build all your files get copied to the "Ad Hoc" folder but your static libraries files get copied to the "Release" folder. These folders sit side by side beside one another and unless told to do so the header files will only be searched for under the "Ad Hoc" folder.
Here is the GitHub commit for my project templates where I fixed the problem
https://github.com/reidmain/Xcode-5-Project-Templates/commit/e465aa3d5c82118cc0d5af3a7f6f094d86b1ec63

How to add Sharekit to existing project

How to add sharekit to existing project for sharing on social networks.
Following instructions from sharekit wiki.
If i add sharekit.xcodeproj to my project i see only one target in share kit but in sharekit wiki it shows four targets.
When trying to add ShareKit's targets as depenedencies to your project's build phase: your project's app target - build phases - target dependencies add 2 new targets from ShareKit subproject: "Static Library" and "Resource Bundle". I dont find any static library and resource bundle.
Please help how to add sharekit in project.
what i did to find these targets ;
Right click on your your project navigator in xCode, then choose Add files to ...
then choose submodules in your project folder and add.
After that you will find "Static Library" and "Resource Bundle" in targets dependencies.

Libxml in a library for ios

I have created a cocoa touch static library that contains functionality that I want to include in several apps. This library is linked to libxml and I have the header search path /usr/include/libxml2. The library builds correctly.
I include this library in another xcode project as a reference (by dragging the library xcodeproj file into my app xcode project. I also setup the target to have the library as a direct dependency, setup the header search path to include /usr/include/libxml2, and add libxml2.dylib in the frameworks.
The problem is, when I try to build the project is has a build error:
Libxml/tree.h: No such file or directory.
I initially had this problem trying to build the library and solved it by adding the header search path and framework into the project for libxml2.
Incidentally, i have another app that uses the library but does not use libxml, it builds and runs correctly.
So the problem seems to be using libxml in both the app and a linked library.
Anybody any ideas?
Yours hopefully,
Neil.
You probably need to add the include path /usr/include/libxml2 to both the target and the project.
To add it to the target, right click on the target and select Get Info.
To add it to the project, go to the Project menu > Edit Project Settings.
In both cases, make sure you've selected Configuration: "All Configurations".