Entries Tagged 'Apple' ↓
July 20th, 2008 — Apple, OS X, Programming, Python
So, lets say you are working in XCode 3, and you are trying to build a PyObjC app but for some reason the python code you wrote isn’t getting called.
If you are seeing weird errors in the console when you run the application (specifically “Could not connect the action <your_action> to target of class <your_AppDelgate_class>”), here’s what it probably is: In the AppDelegate python file that XCode creates it uses spaces to do the indentation of the methods.
I hail from a land where tabs are used for such tasks, and the use of spaces is look down upon in much the same way that pick ones nose in public is.
At any rate, what’s happening is when the code is compiled/run the python interpreter is not recognizing the new methods that I put in (using tabs to indent) and instead of giving me a warning about inconsistent indention, it fails somewhat silently in that it groans it can’t hook the action up to the class and that’s it. It wasn’t until I turned on the invisible characters that this occurred to me that it might be the root cause of my problems.
Once setting all of the indentions to be the same, I chose tabs, everything worked like a champ.
By the way, if you are looking for some tutorials for PyObjC in XCode 3 (there are a ton of XCode 2 tutorials out there, but things have changed ever so slightly in 3), be sure to check out these links:
July 7th, 2008 — Apple, OS X, Programming
I just finished trying to use XCode 3’s built in support for Subversion. It did not end well.
For starters I created a new XCode project, ran it to make sure it could build, and then decided to check it in to svn so that I would have a “clean” starting point in case I ran into problems. This is how I normally work in other IDE’s, and I’ve never had a problem. Until today.
After setting up the repository in XCode I couldn’t find how to set the project so that XCode would “know” it was under version control (or SCM as XCode refers to it). If you look at the project’s properties, there is a drop down list the lists the available repositories (or it offers to let you set up a new one, which is a nice shortcut). However, the repository I just added is grayed out. After a half hour of trying various “obvious” things I gave up and googled around.
It turns out that XCode can’t create and then check in. The project has to be put into the repository, then checked out before XCode will recognize that it is under source control. Very unusual, but what ever, I decided to play along. I used XCode’s svn browser (which isn’t half bad) to upload the code, then deleted the project and checked it out.
And right about then is when it became obvious that I was traveling the wrong way on a one way street. Here’s an executive summary of what I found so very, very, very wrong with XCode’s SCM integration:
- I had to create the project, check it in, then check it out for XCode to realize that it was under version control.
- Although XCode has an svn repository browser that allows me check in and out the code, it doesn’t seem to know anything about XCode projects as it checked in the build directory without asking. For me (and a lot of developers I know) the last thing I want in version control are files that are going to change constantly (i.e. object files). Checking in a finished version, fine. Checking in a ba-jillion intermediate files: fail.
- After checking out the project, XCode began complaining about there not being a lock on a file in the build directory. The error message actually said “This might be a bug, please report it.” Sorry Apple, I’m a nice guy, but I’ve got limits. This seems like something that shouldn’t happen on a fresh project (i.e. all boilerplate code, I haven’t done a thing to the project yet).
- Deciding that I might be slightly smarter than the computer, I decided to delete the build directory in the repository. I tried to refresh the project to let it know there was a change it might need to be aware of. Instead I was made aware of the fact that there doesn’t seem to be one central view of what’s changed for the project. The near-useless SCM menu item in the project reported that one file had change, and I could not seem to get it to even look at the project as a whole. Maybe I’m spoiled by the way Eclipse handles this situation (which provides a bunch of clues in different areas, but all of which lead to a pretty straightforward GUI for dealing with changes). Even TextMate handles this decently (just not as good looking as Eclipse).
By this time I just gave up. I removed the repository connection from the project settings, and decided to just go Command-line for doing my updates/commits. Life’s too short to be chasing my tail on stuff like this.
April 28th, 2007 — Apple, Games, Software Development
I don’t want a copy of Photoshop. Its not that I’m cheap (that’s a whole other story!), its just that I don’t like using sledgehammers to kill mosquitoes. I’m trying to do some simple bitmap editing and it has turned into a big headache because it is hard to find a simple graphics editing program.
I was using Pixen which is highly regarded and does just what I need it too. Buuuuuut… I can’t get the program to run more than a few minutes without a crash. And that just really bums me out because it seems like the perfect program. Sadly, I’m not the only one having this problem, posting around the net seem to indicate that this is a common issue.
And unlike Windows, the Mac doesn’t seem to come with any simple programs a-la Paintbrush. What’s up with that? I realize Apple is all about minimal cruft and what-not, but this really takes it to an extreme.
For the moment I’m trying out tileeditor which is a pretty minimal editor, but at the same time seems to work pretty well. (Although as a side note I would like to point out that you need to start the editor in the same directory as your artwork, otherwise it seems to try and save to the wrong directory. Every time I did this is put _tmp and the front of the path, which of course doesn’t exist. I’m not sure if this is a Mac specific thing, but just starting the program in the art directory seemed to get around this issue.)
January 29th, 2007 — Apple, OS X, Programming
I’ve been messing around with Cocoa for a few weeks now, mostly trying to make an OpenGL program. I’ve been making good progress, but man, it does get tedious. I’m not an OpenGL expert, so I’m constantly needing to look things up to make sure I’m on the right track.
Last week at an Apple ADC Tech Talk I saw an example of Quartz Composer. I had only vaguely heard of Quartz Composer before and hadn’t really looked into it. It turns out that it is a very useful tool for building a neat GUI quickly, and is available as part of the Xcode tools. After getting home from the talk I played around with it and was able to build lots of cool demo-type apps very quickly.
And then… I discovered that it can be integrated into Cocoa apps very easily. I mean, I found this great tutorial on the Apple Dev site, and within 5 minutes I had a Quartz Composer (QC) window running in my test app along side my OpenGL test window. And not a line of code was written. The absolute bets news is that you can expose the internals of the QC window to the Cocoa framework and then manipulate the QC object from your program!
That just rocks so hard. Now I can focus on the mechanics of my program instead of worrying about the mechanics of OpenGL. Of course, the QC isn’t 100% efficient as hand tuned code, but for most of what I want to do with it, its perfect! Thank you Apple!
As a side note, if you are interested in doing Mac development and you aren’t a member of the ADC (Apple Developer Connection), you really owe it to yourself to go sign up for one of their free accounts and check it out. Its a great resource for all things Mac and OS X.
January 21st, 2007 — Apple, Blogging
My MacBook had a boo-boo. The battery wouldn’t charge, all it would do is show a battery icon with and X in it on the status bar at the top of the screen. I tried all of the tips on the Apple support pages, but nothing worked. So I decided to try my luck at the Genius bar at the local Apple store.
I don’t really know what I was expecting, probably a hard time as that’s what I usually get at stores when I try to get something fixed, but this visit was as smooth as silk. I had to wait a little bit past my appointment time, there was a ton of people in there and a couple of the problems looked bad, but once I was called up I was done in less than 10 minutes!
I explained to the “genius” (sorry, I didn’t catch his name) what was going on, and what I had tried to fix it. He booted up the Mac, confirmed the problem and then brought out a new battery. He plugged it in, booted the Mac and then it showed there was a battery and it was charging. I was so happy (I was afraid it was the logic board) and when I asked what was the problem with the battery, I was told that the chip in the battery was probably dead.
The best part about the whole experience was that the battery was covered under the warranty, so there was no money out of my pocket! Woo-Hoo!
As a side note, after the iPhone announcement the other day I heard that Apple would be providing the customer support for the phone, not Cingular. Customer support is a major undertaking, and I was really wondering how Apple would handle this. Granted, phone support is different from one-on-one support, but everyone I saw at the Apple store today was really nice. Granted most of the customers were nice also, but a few seemed on edge (since their equipment was going to have to go into the shop to get fixed). But no one was steamed or looking unhappy with how they were being treated. Contrast that with most cell phone stores, and you’ll see a big difference. Hopefully Apple will be able to maintain that level of customer satisfaction and service when the iPhone rolls out…
December 2nd, 2006 — Apple, OS X, Programming
When working with a Cocoa project (in XCode), if you decide to add a .cpp file (and it’s .h file) to the project you might notice a problem when building. I banged my head into this for about an hour before figuring it out.
When I added the file(s), I did so by clicking on “New” and selecting a C++ file under “BSD” because it was the first option that I saw. It turns out when you do this, the Cocoa project settings will attempt to compile the files as Objective-C files (which they are not). This results in cryptic messages about a “parse error before” in you .h file.
The solution is to right click on the .cpp file, select info, then change the file type to “sourcecode.cpp.objcpp”. This tells XCode to use the Objective-C++ compiler to build the files, and from then on everything *seemed* to work ok. I’ve never worked with Objective-C (or Obj-C++), so I’m figuring this out as I go. If something bad seems to happen, I’ll post a follow up to let everyone know.
September 21st, 2006 — Apple, Programming, Python, Software Development
…Or, I love it when a plan comes together. 
A while ago I wrote a small GUI app in python using Tk (Tkinter to be specific). It worked pretty good on Windows machines, which is where I was running it at the time. About a year later I tried to run it on a Mac, and the results were a little surprising. It did not look good. It seems that there are some differences between the Tk stuff on different platforms.
Every since then I’ve been wondering if there was a more platform independent way of making Python GUI apps. I’d heard a lot about wxPython, so I decided to give it a shot. The documentation is pretty good and the demos that come with it helped me get up to speed pretty quickly. (Plus the API reminded me of some work I did in the Win32 world a few years ago, and surprisingly, that helped me get things “working” faster than I think I would have otherwise.)
Anyways, I built a little app to visualize an idea I’ve been having for a few weeks ago. Again, on Windows machines it looks great. Today I remembered that I hadn’t run it on a Mac yet. With a little bit of trepidation, I grabbed the code and hit run. Lo-and-behold it runs great on the Mac. A little bit slow on the re-draw, which probably has more to do with how I wrote the event handlers, but it ran and looked just like it does on the Windows machines.
Thus I have concluded: wxPython rocks.
July 2nd, 2006 — Apple, Blogging, Java, Programming, Technology
A few weeks ago I went and got a MacBook. I’m really digging it, it feels so much faster than the MacMini. Plus I’m loving the widescreen on the MacBook, I’ve been wanting a widescreen monitor for a while, but have never had the opportunity to get one.
In case anyone out there is wondering about the pro’s and con’s of getting an ICBM (Intel Chip Based Mac), I thought I would toss out my thoughts on the topic:
- Speed- It is sooooo much faster than the old PPC machines. Don’t get me wrong, the PPC machines are fast, but the duo core aspect of the MacBook makes everything that much faster.
- Ease of Upgrade- I bought 2GB of RAM and dropped it in the machine after I got it all set up. That has made all the difference in the world. The Mini only had 512MB, and I think that really holds it back. Being able to get 2GB for less than $200 was a no brainer, and the performance is phenomenal.
- Heat - The MacBook gets hot. Real hot in some spots. The Mini is one of the best combinations of speed and coolness that I have ever seen. Most of the time I don’t have the MacBook on my lap, but I’m still concerned about heat.
- Compatibility - The Intel based machines are supposed to support the old PPC binaries, and for the most part I have found this to be good. However, I did find two glaring problems right off the bat: Eclipse and NeoOffice. Both of these programs would not start up. It turns out that Universal Binaries are right around the corner for both. I thought it was odd though that both apps (which are Java based) wouldn’t run. It turns out there is some JNI in the background and that’s where the problems were. Once the Universal builds are released (I think Eclipse is already out with its 3.2 release) that should solve those problems. Also, I’ve found that PyGame isn’t 100% functional on the MacBook, but I’m thinking I might have done something to cause that. (More on that later)
- Form Factor - Both the Mini and the MacBook are just slick looking machines. Thin, compact, yet packed with power. Its great! I recently took the MacBook on a trip and it was a breeze to bust it out and knock out some code. The built in Wi-Fi is great, though sometimes I wish I could get a little more detail out of it (Windows machines have a really good interface for its WiFi stuff, its great for users who want more advanced information).
Overall I’ve got to say the MacBook just rocks. 
June 29th, 2006 — Apple, Blogging, Technology, Web
One thing that has bugged me about Camino is that (at least compared to Firefox) there was no way to change your default search engine from Google. Or so I thought…
It turns out if you do a search for SearchURLList.plist it will bring up the config file that allows you to enter in new engines. Just follow the format, and be sure to change the “PreferredSearchEngine” value to your preferred engine. Now I can hit Ask.com straight from the search box!
April 22nd, 2006 — Apple, Blogging, Music, Probability, ipod
Its been almost a year since I started using iTunes, and in that time I’ve adapted to its way of looking at my music library. It took me a while to get used to its mangling of my music directory (I’m picky like that), but all in all things are pretty good now. I do have a few observations:
Metadata and the files
I like that when I play a song the album artwork is displayed. I think that’s neat. I was however really surprised to find out that the image of the album cover is stored in the mp3/m4p file, thus increasing its size. That struck me as really odd since if you have an album’s worth of songs, the same picture could be used for each song/file. It seems that over your entire music library that if there was only one copy of the image floating around, you’d have more file space, which is to say you could fit more songs onto your iPod.
Then I discovered the most interesting thing: The ratings that you assign for a song are not stored in the music file! They are kept in a separate file! I’m pretty sure that the MP3 file standard has a field for the user’s rating, it seems to me that setting the field (which is already there and wouldn’t add anything to size of the file) would be the way to do it, instead of storing that info in a file that if it gets corrupted will effect every rating in the library. Plus if you go an move the music file to another machine, you loose the rating info. I’ve been relying heavily on rating information lately.
Playlist fatigue
I’ve noticed lately that I’m getting really tired of my playlists, they seem to play the same songs over and over. Investigating further I found the problem is that the size of the playlists (which are mostly based off of the ratings of the song) is not as large as I thought they were. It turns out I have not rated a large portion of my music library. This means that the playlist is pulling selections from a rather limited pool. The smaller this pool, the more frequently you are going to hear a repeat.
Of course the way to get around this is to create an “unrated” playlist and force yourself to listen through it. As you listen to the songs, rate them. This will help enlarge the pool of possible songs the playlists can play from. Previous studies have shown the randomizer in iTunes does a pretty good job of picking songs randomly, so by increasing the playlist size you’ll find that you don’t have as many “I just heard that song!” moments.
Please note that the last item about the playlists applies to all music players, not just iTunes. I discovered this problem at work while using the Windows Media player. If you’ve got a small population of things to choose from, then there is a high probability that you are going to hear the same thing often.