Changing default parameters of Mogenerator - xcode

I'm trying to make Core Data objects inherit from my own custom class rather than NSManagedObject. I started using Mogenerator and noticed that it has a --base-class arugument which does exactly what I want.
The problem is that by default it doesn't use this parameter, and so every time I save my data model file, it sets the inherited class to NSManagedObject. Is there any way to add this additional parameter to the script so that it works as I want it to every time I save the .xcdatamodel file?
If not, is there any other way I can easily run this command from Xcode? I was thinking about creating it as a User Script. The problem is that I don't want it hardcoded to this project's files. This is an example of the command line I need to run:
mogenerator -m MyProject.xcdatamodeld/MyProject.xcdatamodel -O Classes --base-class MyManagedObject
Ideally, it should find the .xcdatamodel file of the current project. As I have no experience in mac development, I would appreciate it if you could point me in the right direction and tell me which commands will be the most useful to me if do indeed make this script myself.

From the Mogen readme
Xmo'd: model comments that start with
-- are passed as args to mogenerator. This allows accessing command-line
options such as --base-class. (David
LeBer)
In Xcode, get info on the actual .xcdatamodel file and in the Comments tab enter xmod and then the args. That should customize Mogen as you wish.

I suspect for this question, filing a bug on github will get Wolf's attention. I am not sure he goes to this site.

Related

Is there a way to make a service container file in laravel through command line?

I want to make a command line to make all modules i need in every single project in laravel..I have searched a lot but i can't get a direct answer.
If you want a shortcut to generate all the needed files for routes/controllers/models/views, I would suggest this amazing package to use. It makes your life easier and it saves some time for the routine steps you have to do when you need a new module.
Laravel-Modules

How to Hide the source code in xcode?

I am writing an app using applescriptobjc in xcode, and while making the archive I see the source code is still inside the package, is there a way to hide it or transform it completely to binary code?
Thanks
I may be a year late to the discussion but I asked the same question around the same time as you did last year and hope that the answer I got will satisfy your own question. Here is an extract answer from
my own question:
When you save the AppleScript file you have the option of checking "Run Only" - in that case the script is compiled into a new form that can be run exactly as the original script, but it is not meant for further editing/development.
It doesn't mean that the run-only file is complete protected or non-readable, but parts of your code, comments, etc. are not included or not easily readable.
If you want to do more you'll need a code obfuscator if you still want to use AppleScript - however I'm not sure if one exists on the market, or you need to develop your own.
As you can see, a simple way to do this is:
Open your final AppDelegate.applescript file in Script Editor on the mac.
Select: File > Export...
2.1. Don't change the file name but override the archive file
2.2. BEFORE SAVING: Choose Run-only checkbox from the save options but leave the File Format as Script
Now your file cannot be opened in plain text as it is set to Run-only. Please remember that it is not a 100% read-proof solution, but works great for small projects (provided you are not rushing the final export and don't forget to perform the above mentioned steps before handing it over to the customer).
I hope you can make the most of this answer and still deem it useful. Let me know how you get on or whether you have any more questions. Perhaps you have since found a far better solution (or just an alternative), if so, I am still looking for the next best thing in source code protection.
In Xcode 9.2. (and maybe earlier versions) you can find under Build Settings the item OSACompile and can choose to compile to an executable only directly from Xcode.

Core Data "Codegen" for existing project in Xcode 8?

So, I understand that Core Data's new "Codegen" feature puts class files into "Derived Data" instead of your project... which is nice.
However, recently in the past it created two separate classes... one that you could manually delete and regenerate, and another that could contain your code/methods for those objects.
I tried turning "Codegen" but it doesn't seem to create the file for our code. How is this supposed to work if we want to add methods to Core Data objects? — Does anyone know how to get it working like before, just without the extra duplicate files, or is there some reason we shouldn't be doing that?
If you want to add your own code to the class then just set the Codegen dropdown to Category/Extension and it will only generate MyClass+CoreDataProperties.h and MyClass+CoreDataProperties.m into Derived Data, which you then need to include at the end of your MyClass.h header file, like before.
btw; it can be a bit finicky getting it to work properly as this setting sometimes doesn't save after you change it, so try save manually before you go to another file and then check the setting saved after. Also clean your project before you build or it might not generate the files.

NSFileCoordinator correct usage

when writing a file using NSFileCoordinator i need to specify the correct NSFileCoordinatorWritingOptions. Although they are explained in detail, I am not sure when to use which one. The available options are:
NSFileCoordinatorWritingForDeleting
NSFileCoordinatorWritingForReplacing
NSFileCoordinatorWritingForMoving
NSFileCoordinatorWritingForMerging
For example, what option is the correct one if I want to create a file (a plist for example)?
Wich one when I modify a file?
Can someone explain the NSFileCoordinatorWritingOptions for a better understanding?
I agree, documentation is not complete on that front, and hard to understand. And no sample code is available even for basic operations like these.
I try to think of these options in the perspective of other apps that have that specific file open, that helps getting the whole picture.
Pass no option (0) to simply update the file and notify others of your changes.
Let's say you are deleting a file that TextEdit currently displays, by providing the NSFileCoordinatorWritingForDeleting option, you're telling TextEdit to close the file as it does not exist anymore (or it could propose to save it to another place if it's in memory). It acts because of deletion.
If you're overwriting a file (as opposed to updating a file), you want about that same behavior for other apps. That's NSFileCoordinatorWritingForReplacing.
NSFileCoordinatorWritingForMoving says other apps to track the file to it's new location, so that it can be later updated.
NSFileCoordinatorWritingForMerging asks other processes to first commit their changes so that you can then merge your own changes with those.
To answer your question, you should use NSFileCoordinatorWritingForReplacing when creating a new file (even when no file exists, as it was to appear in the mean time from another app, you'd be replacing it with your own, unrelated contents). And NSFileCoordinatorWritingForMerging should be used when updating an existing file with new data, as it allows integrating the latest changes to that file immediately (instead of doing later with conflict resolution).

How to customize generated Source Code Using Altova Mapforce Project

Background: When I generate the code for my mapping project, only one map will run, regardless of which file type I send in to the command.
I would like to modify the project code generation so that when the maps are generated the applicationConsole.cs allows multiple files and file types, and chooses the appropriate map based upon the parameters I send in.
so far, my project contains 4 maps, each one is different and has a parameter indicating whether or not to run the map. Once the code is generated, the applicationConsole.cs does not differentiate when running the maps. the first map listed in the applicationConsole.cs is run and the others are not. if the first map matches the given parameters, the output is correct, but if the next file coming in does not match, the console closes rather than moving on to the next map.
I am trying to avoid direct manipulation of the applicationConsole.cs, due to having to generate the code frequently.
the question: Does anyone know how to modify the output of Mapforce Project code generation to add a switch for map type based on file type?
In altova mapforce Application Install Directory,there is one SPL Directory. this is generate auto generate code as per your selected Language.
Take the backup of that Directory and modify SPL Directory code as per your requirement.
You need to learn SPL (Spy Programming Language) .
http://manual.altova.com/Mapforce/mapforce-enterprise/index.html?cgthewaytospl(spyprogrammingla.htm
If you need anything else then please inform me here. I have Good command on Customize the SPL.
Thank you
Take a look at refactoring under Java and C#
Really when you look at the stub code generated and you need to combine a couple maps the first refactoring task is to rename the namespace, Altova uses it's namespace as a default, so a mapa namespace would be helpful mapb namespace etc.
I'll provide the C# examples
http://msdn.microsoft.com/en-us/library/vstudio/6kxxabwd.aspx
Then you have the console app so you want to copy the applicationConsole.cs and rename it your project name or class name and then extract the method
http://msdn.microsoft.com/en-us/library/vstudio/0s21cwxk.aspx
Finally you would want to extract the interface so as to return the exception Constructor
http://msdn.microsoft.com/en-us/library/vstudio/fb3dyx26.aspx
and:
http://msdn.microsoft.com/en-us/library/tz6bzkbf.aspx
What you would have is a project with your start-up being the original applicationConsole.cs that you copied and renamed in a project or solution folder. When you update the map you should be able to over-write the code in that folder with what Mapforce generated.
This file was generated by MapForce 2013r2sp2.
YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
Refer to the MapForce Documentation for further details
This is what you will see in that file, use the technique outlined above and the tool is very easy to use. If you are a desktop programmer the refactoring might be new but it saves allot of time and effort down the road and makes the product complete.

Resources