Wrapping – Export Hype HTML to an App 🎁

exportscripts

(Mark Hunte) #21

Hmm.

I have not done any submits to AppStore. But I have used sand boxing and saving files on my own apps. I normally have not needed to create directories but I am not sure why it does not work for you.

I set up the entitlements with read/write to

 do {
                try FileManager.default.createDirectory(atPath: NSString(string:"~/Pictures/foo").expandingTildeInPath, withIntermediateDirectories: true, attributes: nil)
            } catch let error as NSError {
                print("Directory Error: \(error.localizedDescription)")
            }

This works ?.


#22

HA HA! It looks very close to what I ended up using. I didn’t realize how much time passed. I was working on this problem for the last four hours, while the Winter Olympics played in the background. I was away from my Mac Mini, so I wasn’t watching the thread.

I actually tried the tilde part. It just ended up making a directory with a tilde. :smiley:

The problem was that I was trying to save to the real desktop folders, but the “sandbox” creates folders under the App ID… com.photics.wrapping …so I just saved the files there. I don’t think people are going to care where they’re saved, just as long as they can pull them out of the folder. Surprisingly, it took me a long… LONG time to update the write file code to match the new path.

Here’s the result…

Directories

func createDirectory(pathy: String) {
            do {
                try FileManager.default.createDirectory(atPath: targetPrefix + "/" + pathy, withIntermediateDirectories: true, attributes: nil)
            } catch let error as NSError {
                print("Directory Error: \(error.localizedDescription)")
            }
        }

Files

do {
    try texty.write(to: URL(fileURLWithPath: targetPrefix + "/" + appName + "/testy.txt"), atomically: true, encoding: String.Encoding.utf8)
} catch {
    // oops!
}

This is taking way longer than I thought it would. But considering how many times I thought about giving up, from when I started this project about six months ago, the app is really REALLY close to launch. The plan is to add iOS and fix the remaining issues tomorrow.

  • How to open the folder, so the user can pull the files out of there?
  • How to scale and save images?
  • How to copy the user’s HTML directory and put it with the other “wrapping” files?

Even if I can’t fix those problems, I can use the app to generate the script. But first, I need some sleep.


(Jonathan Deutsch) #23

I’m a little uncertain on what you’re doing and what technology set you’re using. If you need to save something on the user’s behalf, it is strongly recommend you use the NSSavePanel which would then give sandbox access to that path. You can write a directory there and can put anything inside of it.

NSWorkspace. If you’re using AppleScript you can use a Tell "Finder".

You could use NSImage but honestly the sips command line tool may be easier.

Wouldn’t this just be part of the save process to do the copy? (NSFileManager/cp)


#24

The replies from @MarkHunte and @jonathan are great. The problem is they’re basically after I figured it out. I’d probably have the app online already, but I had a bit of a catastrophe today. With all the testing of the app, I end up deleting lots of Xcode projects. That’s what the app does. It makes Xcode projects. In the morning, I was doing great. But in the afternoon, I started getting tired. I didn’t realize that I was deleting the main “Wrapping” template and not a random test template. I lost a lot of work.

…and since I wasn’t on my main computer at the time, I wasn’t running Time Machine. :scream_cat:

There was a lot of work to recreate. It was bad, but not horrible, as I remembered a lot of what I had to do.

Oh, I’ve been wondering that myself. :smile:

I was just watching the Olympics, wondering why I’m doing all this development stuff, not just going snowboarding. It looks like a lot of fun. Heh, then they cut to what one of the guys looked like in the hospital. Today’s data loss was bad, but not that bad! I think I’ll stick with development.

It’s all Swift 4. The multiline strings are really nice!

I tried using AppleScript, but I ended up using NSWorkspace. It was easier than I thought. (The problem is getting the paths straight.)

It’s funny reading the responses on Stack Overflow. Heh, they have to break out the answers in different versions. Here’s what you do for Swift 1 & 2, and here’s what you do for Swift 3… and now Swift 4.

I laughed at how silly it is to get the current year… and people make fun of JavaScript and PHP. Apple does seem to be moving in the right direction with Swift. But with all the frustration I’ve been having with Apple lately, I’ve been wondering if my next computer will be a Linux machine. So far, probably not. These technical challenges have been making me a better developer. I can also understand Apple’s perspective. It must be crazy to manage the app stores.

It’s not saved all at once. It’s built piece-by-piece. FileManager is all over the place. I even saw some examples of people abbreviating it as “fm” to shorten their code. I skipped that part though. I did make some nice functions though, to make the creation of directories and files much easier.

This is the last piece left, but again I’m too tired to figure it out right now. I’ll probably get it done tomorrow. I found lots of info on this already. Yeah, looks like “NSImage” is probably what I’ll use. It seems transparency is an issue, so I’ll have to watch out for that too.

Wow, you know your Xcode stuff. Those were the answers. Heh, but that’s what I figured out this morning.

“Experience is something you get just after you need it.” :smile:

I’m not sure about sips though. I was using AppleScript / Terminal before, and it worked, but Apple gave me a hard time about it. So now, it’s pure Swift and the only permission used is “User Selected File” – Read only. Apple should have no excuse to reject my app now… heh, but I still get the feeling they’ll find something.

What is nice is that all this rebuilding has made the app stronger. The “Team ID” isn’t needed. So, people won’t have to fumble around to find their developer ID to make an app.


#25

Heh, I haven’t been able to figure it out yet. I like sips. It seems like it would be an ideal solution, but here’s basically what happens…

Warning: -z 512 512 /Users/photics/Desktop/wrapping-project/wrapping.png --out /Users/photics/Library/Containers/com.photics.wrapping/Data/Wrapped/test/512.png not a valid file - skipping
Error 4: no file was specified
Try ‘sips --help’ for help using this tool

I saw this tutorial…

So I added this…

let path = "/usr/bin/sips"
let arguments = [" -z 512 512 \(mainPNG) --out \(NSHomeDirectory())/\(self.targetPrefix)/\(self.appName)/512.png"]
sender.isEnabled = false
let task = Process.launchedProcess(launchPath: path, arguments: arguments)
task.waitUntilExit()
sender.isEnabled = true

So, outside of the app, sips works like it should. But when I try to use sips in the app, nothing works.

Just to be sure I’m using sips correctly, I tried the following in terminal…

Mac-mini:desktop Photics$ sips -z 512 512 wrapping.png --out 512.png

That worked. ¯\_(ツ)_/¯

I wasn’t sure if this is a sandboxing issue, but turning off sandboxing didn’t seem to fix the issue.


I added iOS support though. So, I’m really happy about that. Heh, at first I thought it was broken. I didn’t see my “Hi!” message. All I saw was a black screen. I was like… WTF? I wasted a lot of time (but not as much as yesterday’s crash) trying to figure it out. It turns out it was working, but the page background color was defaulting to the interface color. So, I set the html body (arbitrarily) to “pink” and it worked. Heh, not usually my favorite color for background colors, but I was happy to see it today.


Solution here…

Looks like the app is almost done. I’m too tired to launch it today. Probably tomorrow I’ll upload a new version to the App Store. :slight_smile:


(Jonathan Deutsch) #26

So you did get running the sips tool to work?


#27

I’m in the process of uploading the app to the App Store. I did use sips. It worked great. Well, aside from escaping spaces.

I’m pleased with the results of internal app testing. There were several trouble spots that I was concerned about… blank fields, fields with spaces, errors/warning in Xcode project… all were solved. This includes iOS support. I don’t know if it’s perfect, but it’s as good as I could get it. Also, there’s nothing left broken. All known errors were fixed. The app does what it’s supposed to do.


Heh, some last minute testing revealed some issues. I fixed those issues and uploaded the app again. I thought no entitlements were needed, but it seems “User Selected File” - “Read Only” is needed. The app stopped working when I turned it off, started working again when I turned it back on. Odd how I didn’t notice that right away. :thinking:

I also had a problem with full-screen mode. I dropped the “Team ID” field and moved the “Bundle Prefix” to the bottom left corner. But when I did that, I didn’t update the responsive settings. That minor issue was fixed. So, once again, all known issues are resolved.

I sent the app to Apple. It is waiting for review. Here’s the app link…

…I’m going to sleep. Who knows, maybe it will be approved before I even wake up. Heh, but I doubt it.


It’s in review already. Wow! I thought that was going to take a lot longer. I didn’t have a chance to add a fifth screenshot.


#28

App rejected again
App updated again
App waiting for review again

:smile:


#29

OK, Wrapping is now approved!

That was a lot of hard work. Hopefully the app is helpful and makes people happy.

Happy Valentines Day! I didn’t plan for the App to launch now, but the heart on the box works for the holiday.


#30

Congratulations! “A diamond is a piece of coal that stuck to the job.”

Honking Horn


(kerguelen) #31

Lovely !!! But unfortunately not viable in France


#32

Nice! But not available in Holland.


(Jonathan Deutsch) #33

Congratulations! I gave it a try turning a Hype export into a mac app and it worked flawlessly for me!


#34

France was added to the list of territories where this app is available.

The Netherlands was added to the list of territories where this app is available.

Flawlessly, that sounds nice. :slightly_smiling_face:


#35

It’s available now. Probably takes more time to cross the ocean.


#36

It’s a pity I’m forced to upgrade to 10.13. I’ll have to consider that.


#37

Yeah, I hated having to do that. My main computer is a Mac Mini from early 2009. It’s stuck at 10.11. Swift 4 has multiline strings, which is a big part of this app, but that meant I had to built this app on another computer. That added more stress to the project.

Best Buy was having a sale on the 13” MacBook Air. It was $800. That’s a great price for a new Mac laptop. It was a little slow, compared to the Pro line, but it was cheap. So, I pull this new laptop out of the box and start it up. It starts making woodpecker sounds. Seemed like a bad fan right out of the box. The computer went right back.


(kerguelen) #38

10.13 is needed ?
Well, I think I’ll pass for now.


#39

Apple today sent out a notice to developers letting them know that starting in April of 2018, all new apps submitted to the App Store must be built using the iOS 11 SDK, which is included in Xcode 9 or later.

I was seriously considering modifying the “Wrapping” app to support older operating systems. That seems pointless now. Apple is forcing the upgrade.


#40

Well, I found a way around for the moment. I’m using my MacBook Air for the wrapping and sent the reult to my Big Mac. A bit more work, but no problem. Your app is doing what it promises. Great job!