Modify OS X app without source code using Swift - swift

The problem is the following.
The title for button FindName is wrong and it should be Search, another thing is that window title is misspelled: "DisplayUsrEmail"
I don't have the source code of the application.
My main requirement is to write the small application that will modify the current application and fix above problems.
I have to write the new app using Swift.
What I did:
1) It is quite simple to change the title of the button without coding. (FindName -> Search) I changed it in the Info.plist file.
2) It is also easy to change the app title (Executable file) in the Info.plist, but in my case, it doesn't change the window's title "DisplayUsrEmail"
3) I opened the apps unix executable file in the hex editor (used https://hexed.it/) and found there the title "DisplayUsrEmail". But the app crashes when I add the byte with symbol 'e'. ("DisplayUsrEmail" -> "DisplayUserEmail") I can just change the title with the same characters count, but it doesn't resolve my problem.
So, is it possible to write the new app that will modify the current one? If yes, what is the workflow?

The app is compiled through xcode and is a known fact that it is not possible to retrieve the source code from the compiled application.
To answer your question: no, it's not possible.

I don't think that this is at all possible. When an app is built, it's also codesigned to prevent any changes to it. If any changes are made, macOS can't (or refuses to) open the app. This is a security feature that prevents people from modifying applications to bypass security measures, licensing, etc. in the app. Since you've modified the app, you are seeing this security feature in action in the form of the app crashing when you attempt to launch it.
That being said, it MIGHT be possible to modify the UI elements only without affecting the executable. In the app's resources folder, there should be a file with a ".nib" extension. This is the compiled user interface which is where the incorrect spelling of the window and button are. If you modify this file ONLY, the UI elements might be correct when you launch the app again. It's also possible that this nib file is part of the codesigned bundle and modifying it will cause a crash, just as if you'd modified the executable.

Related

Best way to remotely update app settings in iOS

I am working on a application in which i have to update all app related settings remotely.
App setings include
Text Font
List item
Text Color
background Color
Images
Url etc..
My idea is something like this, the first time when the user install the app it start downloading all images and settings like text color, font etc.
And when ever any changes happen the app itself downlaod those changes and store it locally.
Currently i am using a constant file where i have written all required settings.
Tell me some best way to achieve this and also tell me where to save the settings.
If is there any sample app available please provide me the link.
Thanks.
You could try something like GroundControl. It updates values in NSUserDefaults from a file found on a web server.
If you have a constant file from which you read all your settings, you can place an identically formatted file on a server, (maybe have a "last updated" date saved inside these files). Upon every session init, try to download the remote settings file - if it is "later" than the one you have, or any settings is different than the one you have saved, save the newly downloaded file instead of the old one, and act upon the changes.
The settings' flags and vars may change instantly across the app, while downloading images for skin and UI occurs immidiately after this, and take effect after they have completed downloading (which may look awkward to the user) or, more plausibly, upon init of the next session.
IMHO, using NSUSerDefaults settings and downloading a remote plist with the same keys and structure is most convenient file format for settings stuff.
Also, you may place the remote file in a web service, and have the client send that web service the request for the file accompanied with a "my last updated settings are of the date X" - the date of the latest settings you have locally. Then, the server may return a file, or an "you already have the latest file" response.

Is the clipboard officially called "pasteboard" on iOS?

I am writing an iOS app and I just want to make sure I call it the appropriate thing. I'm used to clipboard but apparently Apple calls it a pasteboard on iOS. Googling doesn't turn anything specific up.
I see the class is called UIPasteboard but I'm just looking to verify the literature/end user communication uses this term as well.
Yes, UIPasteboard is the clipboard (or the service behind the copy and paste feature). Most users are unlikely to know what either pasteboard or clipboard means. If you're describing the feature you should probably use the simple 'copy & paste' terminology.
I have the same question: which string is preferable to show to the user?
"Copy"
"Copy to Clipboard"
"Copy to Pasteboard"
Looking at the standard built-in apps on iOS 12, it looks like the first form ("Copy") is used almost everywhere.
Doing some more research, I googled for pages containing "pasteboard" on site:help.apple.com, and found pages such as https://help.apple.com/voiceover/info/guide/10.7/English.lproj/_1128.html which include text like You can also copy the last spoken phrase to the Clipboard (also called the “Pasteboard”) by pressing VO-Shift-C. But note that this is a page for macOS, not iOS. When I searched for iOS pasteboard site:help.apple.com I got zero results, while searching for iOS clipboard site:help.apple.com got many hits, all of which suggests that Apple doesn't use the term "pasteboard" when addressing users (even though UIPasteboard is the name of the internal API).
Another data point is that the Simulator has a menu command Edit / Automatically Sync Pasteboard although (speculation!) maybe that's meant to be understood by developers not end-users?
I've got a similar problem in that I'm trying to display an error message if the pasteboard contents are "invalid" in the current situation. (In the app, there is a main tweet which has already been loaded in the main part of the window, but I also want to let the user select a second tweet if they've copied a Twitter URL to the pasteboard.) I want to say something like The tweet on the pasteboard could not be downloaded but I assume most users won't know what a "pasteboard" is, and even changing it to The tweet on the clipboard could not be downloaded isn't great IMHO. Removing the on the pasteboard/clipboard phrase is not an option because The tweet could not be downloaded won't work since it sounds like it applies to the main tweet already loaded in the main part of the window, not the tweet on the pasteboard. I could remove the message entirely, but then the user wouldn't know if they successfully copied an invalid link to the pasteboard; they could keep retrying because they think the copy-to-pasteboard failed, not the download-from-twitter failed.
Update 2019-07-20: I wanted to document how Google Chrome does it, because it seems like a good solution. When you tap into the search box to start typing a URL, it provides an extra option immediately below it saying "Link You Copied" followed by the link. I like this because "You Copied" aligns with the action the user took ("Copy") and avoids the whole issue of using "pasteboard" or "clipboard".
from ios development cookbook :
Pasteboards, also known as clipboards on some systems, provide a
central OS feature for sharing data across applications. Users can
copy data to the pasteboard in one application, switch tasks, and then
paste that data into another application. Cut/copy/paste features are
similar to those found in most operating systems. Users can also copy
and paste within a single application, when switching between text
fields or views.
so to answer your question yes, clipboard is called pasteboard in iOS.
Looking at the human interface guidelines, there is a picture of app showing a pop up menu with an option for Copy. So simply say Copy and do not mention pasteboard or clipboard
https://developer.apple.com/ios/human-interface-guidelines/interaction/3d-touch/

iPhone: Sequencing issue with creating file with "do not back-up" flag in Documents folder?

Our applications set the "do not back-up" flag as per Apple's requirements. Or at least we thought so. A recent submission has been rejected because the reviewer found a file without the flag set. We tested, re-tested and tested again and see that all of our files are created with the "do not back-up" flag. Hmmm!
This is not our first application using the same code base. We've had many others pass through with no issues even some quite recently.
So could it be a sequencing problem? We are copying a database file out of the download bundle that is used as the application's starting content; this content is then updated as the user gets more data. The initial database file can be large - as big as 2MB - depending on the application. We open a new file in the Documents folder, copy the database contents to the new file, close it, and then set the "do not back-up" flag.
Instead should we create an empty file and then immediately set the "do not back-up" flag, prior to opening it to overwrite the empty file with the database contents from the bundle?
I've asked the Apple reviewers this question but have not received an answer yet. I could simply try the different sequence and see what happens in the re-review, but I'd prefer to know what I should be doing and do it, rather than guess what the problem is and shoot in the dark.
So does anyone know of a sure-fire "Apple approved" way to copy out a (database) file from the bundle into the Documents directory and set the "do not back-up" flag? Can anyone shed light on any similar rejections and what they did to please the reviewers?
Having earned the Tumbleweed badge (= its a boring question) here is some information to answer it....
The way to set the "do not back-up" flag has changed between 5.0.1 and 5.1. The release notes for iOS 5.1 SDK has the following entry under "Backup"
iOS 5.1 introduces a new API to mark files or directories that should not be backed up. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute.
Apps running on iOS 5.1 and later must use the newer attributes and not add the com.apple.MobileBackup extended attribute directly, as previously documented. The com.apple.MobileBackup extended attribute is deprecated and support for it may be removed in a future release.
Note that iCloud was introduced in iOS 5.01, and this change was introduced in 5.1, which means that the app must adapt to the iOS specific version running on the device. One of our developers found the following Gist for code that handles pre- and post- iOS 5.1 devices.

Write setting.bundle in runtime

I can write at design time a setting bundle, but I need to make its content appear according to certain condition
can I do that , if yes any sample code, and where to put this code
Best regards
You can't dynamically create a Settings.bundle and write it out while your application is running on the iPhone. It needs to be included in the code signed application package.
What you can do, though, is customize your already created bundle's content & UI based on those certain conditions. E.G. different preferences load different strings or graphics.

Dynamic Version Numbering in a Default.png

I have a Default.png which includes a version number on it. Every time I update my app, I have to change it both in the lite and full version's default.png and default#2x.png. Hassle, no?
I'm pretty sure I've been going about this the wrong way. What should I do instead? (I would like to show a version number on launch, not just nix it altogether.)
Compile-Time Image Compositing
If your logo doesn't need to change other than the version number, then you can use your graphics library of choice at compile-time to refactor the png. Pseudo code below:
Pseudo-Code:
UpdateLogo(String logoName, String version)
{
WidgetImage MyLogo(logoName + ".png");
MyLogo.DrawText(800, 650, version);
MyLogo.Write(logoName + "Final.png");
}
UpdateLogo("Logo.png", "Version 1.0.0");
Compile that program and keep it around as a custom build tool. Then whenever you need to build your application you can compile Logo.png into LogoFinal.png. If you need help using XCode or other tools to generate image files I suggest you search for image manipulation tools separately from "dynamic versioning".
Ideally your version string will use constants defined in an easily-editable table or controlled by your build system. At the very least it will save you from opening up Photoshop every time you need to build your app.
For Display in a Running Application
You should be using a font to draw the version number on top of the logo. Then you can just include a resource file that is text-based and can be easily updated by automated tools for each build.
Sources
Can you create custom build rules for XCode based on file type?
Apple's Human Interface Guidelines say that the Default.png shouldn't be used as a splash screen; it should represent all of the UI controls the application will show, but without any localizable text or content. (Think of how the the built-in apps like iPod and Contacts behave.)
If you're doing it for a client and they demand it, you can always use the "But the app store might reject it for violating their terms!" argument.
Of course, this doesn't apply if you're not submitting to the Store or if you just don't care. :)
A technical add-on for the people posting above: make sure that any png compositing you're adding to the build process runs before pngcrush executes, so that you're not replacing an optimized image with a script-generated (and likely unoptimized) one. You may also run into weird issues if you try doing it after pngcrush runs (it not displaying), anyway.