Sharing fast code and maintaining code in one place [framework / library]

I would like to create a Swift structure and import it into other projects. Obviously, I would like to share my code using the structure in question. I could find here one related question.

Create and import high-speed frames

and some online tutorials that didn't seem to bring anything useful to me. So here is what I have:

  • An Xcode project (with a CocoaPods generated .xcworkspace), which is the actual application that should use the framework.
  • A "Cocoa" Xcode "construct, which is a framework.

What are the steps to include framework (2) in annex (1)?

I tried using the method described in the related question above, but when creating it says that it does not find the actual source files.

<unknown>: 0: error: no such file or directory: '/path/to/project/MyFrameWork/SomeClass.swift'

Where /path/to/project/ is obviously just a placeholder ...

Bounty goal:

Suggest a viable option, how could I use a set of classes efficiently. I need to be able to reuse code from one project easily and be able to maintain this code in one place . It should also be compatible with iOS7, so dynamic libraries probably won't do this for me. Any workflow that allows me to do what I described above will be a winner. thanks

+7
ios frameworks xcode swift
source share
3 answers

To help others, here is a continuation of what I did:

Due to the fact that at the time of this writing, iOS8 is used by approximately 81% of Apple users with mobile devices, I decided that I would go on the CocoaPods route. (I mention this because iOS8 requires the use of Swift dynamic libraries). And since I'm still starting out with my project, I decided why not just start with iOS8 ...

I basically created a new library by doing something on these lines (note: CocoaPods needs to be installed on your system!)

 pod lib create <YourLibraryName> 

And changing the contents of the .podspec file created in the process.

Add the source code to the folder created for your library (or source_folder specified in the .podspec file) and create a git repository. Now you can use this library in every project that also uses CocoaPods by adding

 pod 'YourFrameWork', :git => 'https://path/to/your/repo.git' 

Hope this helps.

+2
source share

I don't know if this is the answer, but I will say it anyway. Create a framework project in Xcode and put it on github. Then you can create a framework with Carthage

0
source share

Here is a good tutorial that I found.

What do you need to do?

 [sudo] gem install cocoapods --pre 

.Podspec file

 Pod::Spec.new do |s| s.name = 'MotionKit' s.version = '0.6' s.license = 'MIT' s.summary = 'CoreMotion Made insanely simple' s.homepage = 'https://github.com/MHaroonBaig/MotionKit' s.social_media_url = 'https://twitter.com/PyBaig' s.authors = { 'Haroon Baig' => ' haroon.prog@gmail.com ' } s.source = { :git => 'https://github.com/MHaroonBaig/MotionKit.git', :tag => s.version } s.ios.deployment_target = '8.0' s.source_files = 'MotionKit/*.swift' s.requires_arc = true end 

Now test the newly created Pod

It is time to check your block to make sure it is working properly. Quickly create a pod file in a test project and add the following line to it.

 pod '[s.name]', :git => '[s.source]' 

in your case:

 pod 'MotionKit', :git => 'https://github.com/MHaroonBaig/MotionKit.git' 
0
source share

All Articles