Hi We have an application that contains two modules (user and admin),
Both share some common code related to a few features.
As per requirement, we need to create two apps (user and admin),
How can we share the code efficiently between two projects?
Thanks in advance.
You have basically three ways if you're working on an iOS app :
Apple's way: Frameworks.
Making a CocoaPod. This is really convenient if you want to share the module, and can be easily integrated in XCode.
Swift's way: Swift Package. In my opinion this slightly less convenient but is completely platform-agnostic, so you can reuse your code even on other platforms.
Related
I am new to iOS development, so please excuse me in case my question sounds trivial.
I am planning to introduce MVP or VIPER pattern. I am from Web background and in web application we used to follow different layers/dlls (for model, view, common etc.). Does it make sense to follow the same layered approach (frameworks in this case) in iOS and or it will be overkill? I have not come across any sample project (based on MVP) which create different framework for model, View and Presenters? It would be great if someone can share any sample project (based on MVP) which we can use as a starter project.
Thanks In Advance
In iOS, we generally use MVC - Model/View/Controller. So, if you're looking for the analog in the iOS world, that's it. If you're saying that you've really dug into MVC and there's something that you find deeply unsatisfying, and therefore want to introduce a different pattern, then that's a different question.
So, no, the sort of logical separation of responsibilities that you see in approaches like MVC is not overkill. In fact, the division of "view" and "controller" classes are fairly central to everything we do (e.g. UIView subclasses, UIViewController subclasses, etc.), so the only thing you really have to do is design appropriate "model" classes and you're off to the races.
But, in answer to your question, you don't generally use separate framework targets for the model, the views, and the controllers. That probably would be overkill. Usually you can keep track of everything through through judicious use of Xcode groups/folders within your project. We generally only pull stuff into frameworks for more technical or logistical reasons (live views, app extensions, sharing code between multiple apps, etc. ... see WWDC 2015 Building Modern Frameworks for discussions of when you'd generally use frameworks).
But to the question of MVC vs MVP or VIPER (or MVVM or whatever). I'd suggest that you simply embrace the shared spirit of all of these patterns (namely the separation of responsibilities) and apply it to your iOS MVC code. Once you've got some iOS experience under your belt, you can then re-evaluate this pattern question.
If you're starting with iOS developement and is looking for a good architecture, go with VIPER. It's not at all an overkill as long as you:
1 - Automate VIPER files generation
2 - Automate VIPER modules initialization
To accomplish both requirements above, use this Xcode plugin (https://github.com/natangr/ViperTemplate) to generate and intialize VIPER files automatically. It works like charm!
And read this post https://www.ckl.io/blog/best-practices-viper-architecture to get more tips on how to automate things when using VIPER.
I do use it, even for very small projects (160h of development)
How to go about designing a multi-platform app that offers In-App-Purchase?
I'm working with JUCE (Win/OSX/Lin/iOS/Andr).
I know that iOS allows IAP. So I'm guessing OSX also does. I would suspect Windows and Android also provide something similar. I doubt Linux provides anything as it is decentralised by nature.
So maybe I would have to write 4 separate IAP modules, and maintain 4 separate stores. Yuck! I don't want to do that. I recoil from duplication.
Is there any way to unify IAP across these different platforms?
The ideal solution would be single store to maintain, and a single C++ API to access it.
But is this even possible? I think Apple explicitly forbid any kind of store/monetising outside of their system. But http://soom.la/ seems to provide some work around for Unity3D.
The api will be same, but the platform specific functionality has to be separate. This way you have one repository and for a given platform build, pull the required code. Here is an example "Upload XML data to MySQL or NoSQL"
I have a whole project developed under iOS which is a sales channel / ecommerce app which is a white branded product.
It mainly relies on a webapp but the native container handles a lot of features (session management, additional services, register to push notification) which is not only intented to make distribution on AppStore possible.
Thus, lot of code within the application delegate, use of several libraries through CocoaPods, etc.
Now, some of our customers whould love to integrate this ecommerce in their existing native apps, for instance, as a tab in a UITabBarController.
What is the best approach to do so ? Considering notably that both AppDelegate must be called, etc?
Thanks
I would advice to refactor your code and extract as much as possible to add it into your own Framework if you really want to keep it clean and have a good way of providing support to your customers. (refactor in a way so that it is easy to use for external projects, for example providing delegates/blocks in a matter that is straight-forward to implement).
A great starting point for learning how to create (Objective-C) iOS Frameworks can be found at https://github.com/jverkoey/iOS-Framework.
Any dependency (external library) you use for building the Framework will become a dependency for the project that will use your framework, unless you can add the source in your Framework.
Also take a look into providing documentation using Doxygen, AppleDoc, etc ;-)
I'm new to web in general and django (python web framework) as well.
I find python easier to work with but most of my colleagues prefer java.(play framework)
Would it be possible to mix them in a web application?
Would it be easier if I just dump django and start using play?
Someone in Integrating Django and Rails mentioned 'messaging', and I wonder what he meant by that.
It's definitely better idea to jump into the Play (or django) then mixing both solutions. Reason is one, fundamental. Although it is possible to mix one framework with other, or even mix frameworks from many languages, first... you need to know all elements at least very well. Then you can search for most optimal ways for connecting them and use the best parts from each, to get best possible result.
As de facto Play's and djangos approaches are very similar I see no good reason for trying connecting them, especially, when bigger part of the team uses one solution, the best option is to follow them.
While, as you wrote - you're new to the django as well, that switch should not be a problem. You can just in future write similar project in django and compare productivity, performance etc. Maybe then you'll convince your colleagues for trying something else.
BTW: Messaging between two apps should be done with documented API's, just consider each other as a 'foreign' service. You can share database, but make sure that frameworks don't duplicate functionalities.
In other words - if you'll write a ContenteManager in django, make sure, that Play guys connect to the DB as a client, or vice versa, don't try to mix responsibility between two solutions (even if written in the same language/framework) cause you'll fail.
I think messaging between two separate frameworks is possible by a number of ways :
intensive exchanging data-files (we're back to DOS days...)
sharing the same database (not described in books , but I've seen it )
communicating trough key-value store as a common data-source
All those solutions are the same if you put diesel fuel in your Ferrari .
Anyway , if you step on a framework you don't like , probably it has some kind of database , that you can use . My advice is to abandone the old and ugly framework , instead of learning to work with it - burden in your hands (soundgarden) .
I read several questions on programmers.stackexchange.com to determine if this question is better asked there. I think this question belongs on SO, but I'm not completely sure.
I have a basic knowledge of Objective-C and UIKit. I have read, a few years ago, most of Cocoa Programming for OS X (2nd Edition) by Aaron Hillegass; this is where the majority of my knowledge stems. The rest is from various sites, SO questions, the SDK documentation, and small personal projects (both OS X and iOS).
I am starting an iOS (specifically, iPhone) project for the university at which I work. This application will have distinct sections with distinct functionality. Some examples of "sections" would be: a virtual student ID card, current semester's class schedule (for the user), a campus map, etcetera. I want to be able to add new sections easily in future versions of the application. Thus, I want to design the project such that a section is an independent, from the main project, group of code (as much as possible).
In addition to being able to add new features by creating new modules, I want the project to be usable by more developers that just myself. That is, I want other developers on my team to be able to develop new modules for the application by following a "best practice."
Currently, I am basing my project around a UITabBarController with my "modules" being new UIViewControllers and NIBs. I get the feeling that this might not be an optimal way of establishing my project. Thus my question:
What are some best practices for such a project as I have described?
I think you're on the right track. UIViewControllers are a good way to break this up.
UITabBarControllers are often awkward when you have a lot of options; a welcome screen with a table view of possibilities might be more expandable. See, for example, Facebook's left panel or the built-in Settings app.
I typically find that the hard part about reuse in iOS projects is not the view controllers (which are typically well isolated) but the underlying infrastructure such as that for network requests, data storage, account management, etc. You might want to start with an existing framework for this (like, say, Parse or RestKit), or at least look at how they break things up.
On the topic of good, reusable iOS design, you might find Matt Gemmell's post about API design helpful, if not exactly what you're looking for.
establish conventions for coding style and resource location.
develop static libraries.
if your static libraries require their own resources (which can be a necessary pain), you may want to use bundles for your resources to minimize resource collisions.
centralize your build configuration files, rather than attempting to define each setting in each project (use xcconfigs).
then you can configure these libraries as dependencies in your app projects, and build, link, and copy appropriately.
one important note: i often err towards C and C++ symbols in these cases (where applicable) because ObjC symbols (and what they reference)cannot be stripped. this can reduce a lot of 'binary fat' where not used. so your 'core' libraries and libraries which deal mostly with symbols declared in other libraries (e.g. system libraries) may be in C and C++, and your higher level abstractions and derived types may be in ObjC.