How to take framework from one project to another Swift - swift

I want to ask how to take a framework from one project and implemented it in my project. So I am interested in using AntMedia, and I look it up in their website about how to implement it on my project, and all i get is a sample project. Right now I am having a problem at how to basically take the framework that is needed from this sample project to my project
screenshot of the sample’s project folders

In your project root, copy the Podfile from the sample and update it with your app target. I’m not sure I found the right pod, so here’s a guess of what might be in it.
target 'MyApp' do
pod 'AnyMediaToolbox', '~> 1.1'
end
Replace MyApp with your app target.
Then run a pod install inside your terminal
If you don’t have cocoapods installed, see: https://cocoapods.org
This will force you to use a workspace. See cocoapods documentation for more details

the simplest way would be to go to Project Settings, select target, choose General and under Frameworks, Libraries, and Embedded Content click on plus and in drop down menu where you will see Add Other... select Add Files and select the framework that you want to add

Related

How to use frameworks imported with carthage in swift playground

i have a swift project with some frameworks added via carthage. Is it possible to use those frameworks in playground inside project and how to use it, because
import Argo
doesn't work :(
This stopped working at some point. Sigh
What I do now is
Create a macOS > Command Line Tool.
Create a Cartfile with github "ReactiveX/RxSwift" and run carthage update --platform iOS
Go to the command line tool target and add the frameworks from Carthage/Build/iOS in Linked frameworks and Libraries
Add the playground files.
At this point I’m able to run the playground files.
🤷🏻‍♂️
A playground has access to external frameworks if it is part of a workspace that builds a target configured to access those frameworks.
If you want to add a playground to an existing carthage project, you only need to save the project as a workspace (File > Save as Workspace…), build the target, and you are done.
If you just want to distribute a playground with third party frameworks, you need to create a dummy workspace. Here is a step by step example for a playground with the RxSwift framework:
Create a new Xcode project of type Cross-platform > Other > Empty. Name it RxPlayground. This will create this structure RxPlayground/RxPlayground.xcodeproj and open a blank Xcode.
Download RxSwift with Carthage
Create a Cartfile with this line: github "ReactiveX/RxSwift" "swift4.0"
Run Carthage with carthage update --platform iOS.
Add a playground to the project.
Click File > New > Playground…
Choose the iOS > Blank template and name it Rx.playground
Right click the project node and choose “Add Files to RxPlayground”.
Select the Rx.playground and add it.
Create a workspace
Click File > Save as Workspace…
Save as Rx.xcworkspace
Copy the frameworks to the products directory.
Close the project and open the Rx.xcworkspace
Create a Cross-platform > Other > Aggregate. Name it RxAggregate
Create a New Run Script Phase with the following content:
cp -rv "${SRCROOT}/Carthage/Build/iOS/" "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"
At this point, Xcode and the Finder look like this:
Note that Carthage/ and Cartfile.resolved appear when you run Carthage, Without them, your playground will be only a few Ks.
Lastly, build the project (⌘B). Now you can use the framework in your playground:
//: Playground - noun: a place where people can play
import RxSwift
_ = Observable<Void>.empty()
.subscribe(onCompleted: {
print("Completed")
})
Sometimes the first time you build (⌘B) Xcode doesn’t notice the new framework (sigh). What I do is click on the target and back to a source file, or re-open the project. I don’t have an explanation why this happens.
In order for the framework to work within a playground, the project that produces the framework must be included in the workspace for your project. So to make this work you need to follow these steps:
If your project is not inside a workspace, create a workspace for your project by choosing File > Save As Workspace in Xcode.
Drag the .xcodeproj file from the Carthage/Checkouts folder into your workspace.
Run the build action on your framework target.
I solved it by copying the built frameworks to the Built Products Directory, where Playgrounds in the workspace also searches for frameworks.
Note: you also need to run lipo and strip away unused architectures from the FAT binaries.
See more here:
https://github.com/richardnees/CarthagePlaygrounds
Based #Jano's great answer (thanks for that), I created a fully functional playground to interact with Carthage frameworks:
https://github.com/backslash-f/carthage-playground
I included the Charts framework as an example:
I tested with latest Xcode.
"Works on my machine." 👍🏻
Found how to do this without converting to workspace and adding .xcodeproj file from the Carthage/Checkouts folder into your project.
This works if you have some framework target that contains all sources you want to use in playground. This framework must be in "Embedded frameworks" of your main target.
Add Carthage .framework to your project from Carthage/Build/IOS
Drag and drop it from your project tree into "Embedded
frameworks" for your main target
Add Carthage .framework to your
framework target as Optional(In target Membership)
Add import
"Your framework target" into playground
That worked for me

Sparkle 10.9 Linking Error

Having an issue where when trying to add Sparkle to my project with Xcode 5 running 10.9.
I have followed the tutorial to a T, but when I get to the point where I need to copy the framework and set its copy location that is where there seems to be no way to set the copy destination in the copy bundle resources section and it just puts the framework int the /Resources folder.
I have ready through this tread thoroughly and have tried all the suggestions here.
http://www.lists.apple.com/archives/xcode-users/2012/Aug/msg00249.html
I recompiled Sparkle from the latest source and set the Installation Directory to #executable_path/../Frameworks from #loader_path/../Frameworks I get the following error.
dyld: Library not loaded: #executable_path/../Frameworks/Sparkle.framework/
when I revert and try to re add the framework I get this error.
dyld: Library not loaded: #loader_path/../Frameworks/Sparkle.framework/
If I remove the framework from the link framework from binaries altogether and just focus on the Copy Bundle Resources then I get this error.
Unknown class 'SUUpdater', using 'NSObject' instead.
The tutorial is written for Xcode 4 I know. One step says to use Copy File Location but that seems to be gone in Xcode 5 any help is appreciated.
UPDATE
I found a work around but its very messy.
Add the framework to the "Add files to build" build step.
Unlink the sparkle framework.
Open Derived Data folder and then open the App Build, then browse to Resources. Move the sparkle.framework folder to the root of the app and place the framework into a folder named Framework in the root level of the app.
Remove the framework from the "Add files to build" step.
Re-Link the framework.
Rebuild the App and voila it works.
Basically your adding the framework in a Framework folder manually and then linking it up at the end. What makes it messy is that the build changes occasionally in the Derived Data folder.
I have the same problem. And I think I have solved it.
It happens because the Sparkle.framework isn't copied to Frameworks folder(where it should be), it is copied to Resources folder when you build the application. To solved it:
Download the source of Sparkle from GIT (https://github.com/sparkle-project/Sparkle) and open the project in Xcode 5;
Go to Build Settings of every targets, then find Base SDK, change the value to macosx.
Go to Sparkle.framework's Build Settings. Find Installation Directory, Change its value from #loader_path/../Frameworks to #loader_path/../Resources under Sparkle.framework's Build Settings.
Build.
Copy Sparkle.framework under Products group in Project Navigator to your project.
Say YES and take a self highfive.
I was suffering from the same problem, then I found this:
http://www.lantean.co/sparkle-in-sandbox-mode/
The key is to add the Sparkle.framework to the Frameworks folder using the "Copy Files" section from "Build Phases".

Build dependencies and static libraries in Xcode 3

I'm trying to get the example project for an SoundCloud API wrapper working using XCode 3. There are some few basic instructions at the start, but I'm having trouble:
QuickStart
In your terminal:
git clone
git://github.com/soundcloud/cocoa-api-wrapper.git
SoundCloudAPI cd SoundCloudAPI git
submodule update --recursive --init
In your Xcode project:
drag SoundCloudAPI.xcodeproj into your project
add it as a build dependency
add the static library as
a liked target
add "[relative path to
SoundCloudAPI]/Sources/SoundCloudAPI"
to your header search path in the
build settings
you can also include
the OAuth2Client headers by adding
"[relative path to
SoundCloudAPI]/Outsourced/OAuth2Client/Sources/OAuth2Client"
too (although you might not need
them)
I've completely ignored the part before In Your Xcode project. I think I've done everything correctly to add the build dependency following this post, the frameworks are still marked in red as if they were missing. Any advice?
Also the three points after that are also not very clear? Could someone explain these in a bit more detail? For example, where is the header search path? and where are the build settings?
Thanks so much!
Tip: Given that you've tagged this question with iphone, I'll assume you're building an iPhone app. In that case, you need to add libSoundCloudAPI.a as a direct dependency, but not SoundCloudAPI.framework.
To set the header search path in Xcode 3:
Ctrl-click your app's target (inside Targets in the Group & Files panel on the left hand side) and choose Get Info
Click the Build tab - these are the build settings! :-)
Set Configuration: to All Configurations, Show: to All Settings
In the Search Paths section, update Header Search Paths

How to integrate RestKit Framework (restkit.org) with xCode 4?

I followed the instructions on the github page but something is wrong (most certainly is me: P) but, Do you know about any good tutorial for integrate / use in Xcode4 RestKit?
Thanks!
Download the latest version from this Link http://restkit.org/
and extract the zip folder and you will find a ReadMe.md file which explains you steps to install for Xcode 4.x as shown below
Xcode 4.x (Git Submodule)
Add the submodule: git submodule add git://github.com/RestKit/RestKit.git RestKit
Open the project you wish to add RestKit to in Xcode.
Focus your project and select the "View" menu > "Navigators" > "Project" to bring the project file list into view.
Drag the RestKit.xcodeproj file from the Finder and drop it on your "".xcodeproj.
Click on your project's name in the sidebar on the left to open the project settings view in the right pane of the window.
In the middle pane you will see PROJECT and TARGETS headers for your project. Click on your project name, then select Build Settings along the top to open the Build Settings editor for your entire project.
Find the Header Search Paths setting. Double click and add a new entry. Add a search path to the "$(SOURCE_ROOT)/RestKit/Build" directory you have added to your project. DO NOT check the Recursive checkbox.
Find the Library Search Paths setting. Double click and add a new entry. Add a search path to the "$(SOURCE_ROOT)/RestKit/Build/$(BUILD_STYLE)-$(PLATFORM_NAME)" directory you have added to your project.
NOTE: This is only necessary if you are NOT using DerivedData.
Find the Other Linker Flags entry and double click it. Use the + button to add a new entry and enter -ObjC -all_load. Dismiss the editor with the Done button.
Locate the target you wish to add RestKit to in the TARGETS list in the middle of the editor pane. Select it to open the target settings editor in the right pane of the window.
Click the Build Phases tab along the top of the window to open the Build Phases editor.
Click the disclosure triangles next to the Target Dependencies and Link Binary with Libraries items.
In the Target Dependencies section, click the + button to open the Target selection sheet. Click on the RestKit aggregate target (it will have the bulls-eye icon) and click the Add button to create a dependency.
In the Link Binary with Libraries section, click the + button to open the Library selection sheet. Here we need to instruct the target to link against all the required RestKit libraries and several system libraries. Select each of the following items (one at a time or while holding down the Command key to select all of them at once) and then click the Add button:
libRestKitCoreData.a - Optional. Only necessary if you are using Core Data.
libRestKitJSONParserJSONKit.a
libRestKitNetwork.a
libRestKitObjectMapping.a
libRestKitSupport.a
CFNetwork.framework
CoreData.framework - Optional. Only necessary if you are using Core Data
MobileCoreServices.framework
SystemConfiguration.framework
libxml2.dylib - Optional. Only necessary if you are mapping from XML payloads and link libRestKitXMLParserLibxml.a into your app.
Verify that all of the libraries are showing up in the Link Binary with Libraries section before continuing.
Congratulations, you are now done adding RestKit into your Xcode 4 based project!
You now only need to add includes for the RestKit libraries at the appropriate places in your application. The relevant includes are:
#import <RestKit/RestKit.h>
// And if you are using Core Data...
#import <RestKit/CoreData/CoreData.h>
I found this tutorial very useful to make it work on xCode 4.0.
http://liebke.github.com/restkit-github-client-example/
I did my build following this steeps https://github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x and guoleii is right. But I needed to change the owner directory.
Have you seen this threads from RestKit's Google Group?
link 1
link 2
Try searching there. But for now, there seems to be A LOT of issues with RestKit and Xcode 4, there's even a YouTube video showing the problems (none showing a how-to).
did you build RestKit according to the wiki page "Installing RestKit in Xcode 4.x" on github.com/RestKit? i think there is a little mistake. here is my solution: 1. in "Build Phases" -> "Link Binary With Libraries", delete the RestKit.framework and add Security.frameWork 2. build again
then it works.
I just tried to install RestKit on a newly created Xcode 5 iOS 7.0 project. I tried downloading the project and following the steps above, but i was missing most of the content with in the RestKit/Vendor folder. After doing a bit of research i did the submodule tactic and that got me all of the information from those folders.
From the command prompt change directory into your project folder, for me it was
$ cd Documents/Projects/NewlyCreatedApp
From there you should run this command if you have no git repository
Note: you must download git to install this, if you have not already
$ git init
after that you must run these commands to download restkit into your project folder
$ git submodule add git://github.com/RestKit/RestKit.git
$ git submodule update --init --recursive
After that, you should go up to Nakkeeran's answer above and start from step 2, to set up the process. In step 7 you will be asked to add "$(SOURCE_ROOT)/RestKit/Build" to your header search paths, but upon closer inspection the RestKit framework no longer has the build folder so you should change that to "$(SOURCE_ROOT)/RestKit/Code" to fit the current version of Rest Kit
I hope this helps, and here is a link to the submodule information i posted.
RestKit Installation Submodule Method

Frameworks are 'red' in Xcode

I downloaded a project developed by Apple employees ( who taught course at Stanford on iPhone application development). Strangely , the frameworks are red.
http://img.skitch.com/20100730-kcjun96mp2pxnpg7w3x6njw57.jpg
I tried to locate coreGraphics.framework and UIKit.framework to add them again but i couldnt find them either.
Taimur
The red text indicates that the actual files are not at the path that the project has for them.
Get info on the framework and look under the General tab. The first section shows the name and path of the framework bundle itself. The most common cause of a problem with system supplied frameworks is that the path type has been changed to something that breaks the path. The default setting is Relative to Current SDK. Change the path until you get one that leads to the actual framework.
If you have the developer tools installed in a custom location, you are more likely to run into this problem. If you copy a project from someone with non-standard settings, you can encounter it as well.
Are you building for a Simulator or for Device?
Try building for Device.
Found a way to fix this automagically:
Right click your main Xcode project file (the blue one at the top ),
Get info,
'General' tab,
At the bottom, set 'Base SDK for All configurations' to your desired one.
Done!
Steps to fix this issue in M1 Macs:
Install "sudo gem install cocoapods-deintegrate cocoapods-clean" to install deintegrate if not installed.
Run "pod deintegrate" in terminal in your project folder to uninstall all pods.
Run "pod cache clean —all"
Run "pod install"
Go to Project Explorer Select "Pods" in blue
Select the each pods in the target section
Search for "Excluded Architecture" in Build Settings Tab under "All" sub category.
Add "Any iOS Simulator SDK" in both debug and release and set the value to "arm64"
Repeat this for each Pod with the error "Framework not found".
Clean Build the project.
#Taimur Hamza - Its happen (red color) following any one of reason,
Your downloaded project may be miss some required files
Before run the application at first time.
so, first you have to find that above reason is happen and try to solve via copy the framework from another running project and paste it your project.
I had faced this problem before. I got over it by copy the missing (in red) framework from my friend's Mac then copy it to the Framework folder.
This is the path of my framework folder:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks
You may need to change the path depend on your system or your sdk version.
Most likely you decided to remove some of the frameworks you don't need and you deleted them but selected "Move to Trash" instead of "Remove reference".
The problem is that this framework was not included in your project's folder. It sits in a System folder when it can be used by multiple projects. So not only did you cause the current project not to compile, but also all projects on your computer.
If you have any frameworks left, you can right-click on them and check "Show in Finder". Than you can find your deleted frameworks in the trash (if it's not wiped already), and put them back in the system's Frameworks folder.
If you can't find this folder, for me it was here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library
Of course, when you go in Applications folder and select Xcode, you have to right-click on it and click "Show Package Contents".
If you deleted your frameworks even from the trash, than I guess you could re-install Xcode...