Wednesday, December 2, 2009

Xcode local SVN - setting up - 5 simple steps

The Snapshot feature in Xcode is really nice, but it isn't meant to replace a SCM. I've heard horror stories of entire projects being deleted using the snapshot feature. While it might be nice for trying something experimental out, I'd recommend setting up a real SCM also. This is how you set up a local SVN (single user, w/o server):

Using terminal, write the following:

1. svnadmin create /Full/path/to/the/Repository/you/want/to/create

I used /Users/andreas/Repository

2. Remove the build folder of your project. Otherwise you will get errors (Error: 155007, Error: 155005) *

In Xcode:

3. From the SCM menu, add a new SVN. Use "file" as scheme, and use the repository path + /projectname/trunk as path.

4. Import your current project into the SVN by clicking import in the CVS repository menu and browsing to your project.

5. Now CHECKOUT the project you imported. Once you've done this, open your checked out project. Go to project settings, and set your CVS to the one you created before.


* If you get these when trying to commit, remove the build folder from the svn (using the Xcode SCM browser), remove build from your project folder, update your project, rebuild, and then try and commit again.

Sunday, October 4, 2009

Easy HTTP file upload on iPhone SDK using wrapper

Took a while to find but eventually I did.
ASIHTTPRequest is a wrapper that makes it alot easier to deal with HTTP requests.

Found it here:
http://stackoverflow.com/questions/936855/file-upload-to-http-server-in-iphone-programming

Official website:
http://allseeing-i.com/ASIHTTPRequest/

Thursday, September 10, 2009

Mobclix library 2.x not working in iPhone simulator 3.x

Ok, brief post (just for the sake of sharing my knowledge about this on the internetz).

I recently incorporated Mobclix into my iPhone app. Since I wanted it to work with both iPhone OS 2.x and 3.x, I chose the 2.x version of the Mobclix library. However, I noticed that when running this in the 3.x simulator, the whole application would freeze. After trying to solve this in numerous different ways, I gave up and contacted Mobclix support. This is what I wrote:



[...]

I would be extremely happy if you could take a look at the code I've uploaded here (it is a small Xcode project that is very simple):

http://boomie.se/upload/mobclix%20test3.zip

This is what has been troubling my mind. If I run this on the iPhone simulator 2.x, it works just fine. However, if I run it on iPhone simulator 3.x, the app will freeze.

In this app, I've got a UILabel and a NSTimer that updates the UILabel every second. When running the application in 2.x, you can see the UILabel getting an updated text every second, but in 3.x however, the text wont update at all. There is one line that causes this, and that is:

banner.delegate = self;

in mobclix_test3AppDelegate at line #26.

If you comment out this line, the app will work in both simulator 2.x and 3.x.

Why is this? I need my app to work in both versions, but I also need to be have a delegate to know when the user has tapped the bannner ad.

[...]




And this was the reply I got:


Hi Andreas,

This is Max from Mobclix Support. I've taken a look at your code and I think I've found the solution. Looking at your project it looks like you've integrated our mobclix library for iPhone OS 2.0+. Unfortunately due to changes in the simulator 3.0 sdk our 2.0+ library will not work on the simulator set to run the 3.0 sdk. However the library runs fine on the actual device running 3.0. If you just build to your 3.0 device instead of the simulator you can see the label updates normally. If you have any other questions / problems please do not hesitate to contact support at: support at mobclix dot com.




Hope this has helped someone...

Tuesday, December 30, 2008

Flex Security error accessing url

This was a problem I encountered while trying to load an external RSS-feed with the HTTP Service in Flex 3. Amazingly I couldn't really find any good solution to this problem when googling it. Just alot about configuring some crossdomain.xml file that is supposed to be in the root directory of the DATA providing server - which really doesn't help since I don't have access to it.

So, the problem here is that the rss-feed is on another server, and that you cannot add a crossdomain.xml to that other server's root directory, right? So, is there some way we could move that feed to your own server, still having it dynamic? Yes there is!

What I ended up doing was making a script in PHP that loads the other site's feed, and then just print it, as such:


<?php

$filename = 'http://www.path.to/the/rss/feed.xml';
$handle = fopen($filename, 'r');
$contents = stream_get_contents($handle);
fclose($handle);
echo $contents;

?>



And then in the Flex application, I just load that PHP-page instead (located on the same domain):


<mx:HTTPService url="http://www.myowndomain.com/thePhpFile.php" resultformat="object">



Very ugly, yes, but it works. Make sure you reload the page "for real" (either clear browser data or use ctrl + F5) when visiting the page again.

If this really is the way to go, then preferably the php-file should also cache the data fetched from the other server.

NOTE that you still need the crossdomain.xml, but on YOUR server.


<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>




I hope this has helped you.