Difficulty Instantiating SUUpdater

Asked by scottjmchugh

Hi all,
I am attempting to add sparkle to a Java-Cocoa application, using Xcode 2.5 under OS X 10.4.11. The first few steps of the process seem to be alright- I added the Sparkle framework to my app's linked frameworks list and copy files build phase. I can build the app and run it normally, and the sparkle framework exists inside the app's package.

However, when I create an instance of the class using interface builder (after parsing the SUUpdater.h file), then try to run my app, I receive an "Unknown class `SUUpdater' in nib file, using `NSObject' instead." error in the Run log.

From what I've read, this implies that the framework isn't loading correctly- even though it appears within my app's package. I read through Apple's doc's on linking a framework (http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#//apple_ref/doc/uid/20002258-106880-BAJJBIEF) , and everything seems correct as far as I can tell.

Thank you in advance for any pointers on what I'm missing!
-Scott

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Hofman (cmhofman) said :
#1

So does the Sparkle framework appear in the Link Binary With Libraries build phase of the app's target? The Linked Frameworks group is pretty irrelevant, as it's just an ordinary group.

Revision history for this message
Andy Matuschak (andymatuschak) said :
#2

I've gotten reports of the same problem from another user, who's created a tiny test app by following the tutorial. This app has the same problem, and I couldn't figure out why for the longest time. I'll bet you're having the same problem, though.

First, I ran otool -L on the binary to verify that it wasn't linking Sparkle.framework. Seeing it wasn't, I checked the build logs and found:

ld warning: in /Users/andym/Development/Build Products/Debug/Sparkle.framework/Sparkle, file is not of required architecture

This app was linking against my debug-build framework, which was only built for x86_64, but the *app* was building for i386. So, it just silently didn't link. That's probably your problem! Make sure it's linking against the *real* Sparkle.framework.

Revision history for this message
Hofman (cmhofman) said :
#3

Are you following the Xcode docs to link the framework? That could explain it, as that does not work! You should *not* link and copy the product from the cross-project (the one you see after clicking the triangle before the Sparkle Xcode project icon), because that will often choose the wrong version (Xcode 3.1.1 seems to finally fix this in my tests, but officially it's not fixed).

You need to set a shared build location in Xcode's Building preferences. Then add the Sparkle framework directly from the build directory, make sure it's set as relative to the build product.

You can check using the Get Info panel of the framework in the Copy Files and Link Binary With Libraries build phases. If it only has the Comments tab, it's wrong.

Revision history for this message
scottjmchugh (mchughs) said :
#4

Thanks for the quick replies!

>>"does the Sparkle framework appear in the Link Binary With Libraries build phase of the app's target?"
Yep, Sparkle is listed under both build phases, and if I Get Info on it, it shows that it's included in my app's one target.

When I run otool on my app's main binary, all I see is:
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10)

There's also a sparkle framework folder inside my app pkg, but since it's not listed when I run otool (assuming I ran otool on the correct binary :P), this means it's a linking error I take it. I checked my build logs, and I didn't see any errors similar to the one mentioned above. I'm attempting to build it in 'Deployment' mode (equivalent to 'Release' mode in Xcode 3.x I believe)

>>"Make sure it's linking against the *real* Sparkle.framework."
Ah, how do I go about checking this? (new to adding in frameworks, pardons the likely simple question)

Thanks for your help!
-Scott

Revision history for this message
Hofman (cmhofman) said :
#5

>> I'm attempting to build it in 'Deployment' mode (equivalent to 'Release' mode in Xcode 3.x I believe)
You shouldn't use Deployment, that's an old and deprecated name for Release. You should rename that.

>>>>"Make sure it's linking against the *real* Sparkle.framework."
>>Ah, how do I go about checking this? (new to adding in frameworks, pardons the likely simple question)

I described how to do that. Select Sparkle.framework in the build phase and use Get Info. If it only has a Comments tab, it's wrong. BTW, if it shows a path to the framework in the Get Info window, that may point to the build location for a different build config; that's an annoying bug (still present in 3.x), but fortunately it does not affect building, linking, or copying.

1. In Xcode's Building prefs, choose a customized build location (not the project directory).
2. Add the build Sparkle.framework from the shared build location, using Add > Existing Frameworks... or drag/drop from Finder.
3. Drag this item to the "Link Binary With Libraries" build phase.
4. Drag this item to the new "Copy Files" build phase (pointing to Frameworks).
5. Make sure you add the Sparkle project as a cross-project your app's project, and add Sparkle as a dependency to your app's target.

Revision history for this message
Andy Matuschak (andymatuschak) said :
#6

I'm not sure even that works correctly: "Link Binary with Libraries" just adds -framework Sparkle as far as I can tell, which can still mess you up if your framework search paths are off. Make sure the framework search paths for your target aren't anything weird.

Revision history for this message
scottjmchugh (mchughs) said :
#7

Thanks for the clarification- when I select the sparkle.framework>Get Info, it shows three tabs (General, Targets, and Comments), with my app's target listed and checked on the Targets tab.

I went through Steps 1-4 (all seemed good), though I'm not certain on step 5- since my app only has one target, it seems to implicitly assume that anything I add to that target is a dependency (so I can't choose Get Info on my target and modify the dependency tab- the little plus is grayed out). Might be missing something though.

I checked my project's current build mode framework search paths- it's set to the value below (recursive not checked):
$(inherited)

Is there another search path I ought to add? (some key for the app's pkg?) (googled, but didn't see anything obvious)

I have a feeling the error below likely indicates what I'm missing- it only appears the first time I build my app after adding in sparkle, but not on any subsequent build attempts (unless I clean the target):
pbxcp: warning: couldn't strip: /Users/mchughs/Desktop/Kanji5/build/Deployment/Kanji Go.app/Contents/Frameworks/Sparkle-with-GC.framework/Versions/A/Resources/relaunch: No such file or directory

Thanks for your continued aid!
-Scott

Revision history for this message
Hofman (cmhofman) said :
#8

>> I went through Steps 1-4 (all seemed good), though I'm not certain on step 5- since my app only has one target, it seems to implicitly assume that anything I add to that target is a dependency (so I can't choose Get Info on my target and modify the dependency tab- the little plus is grayed out). Might be missing something though.

You need to add the Sparkle project as a cross-project to your app's project. Choose Project > Add To Project, and select Sparkle.xcodeproj. After that, the "+" button should be enabled and you should be able to add Sparkle as a dependency.

>> Is there another search path I ought to add? (some key for the app's pkg?) (googled, but didn't see anything obvious)
I've never had to add any search paths, and it has always worked for me following the steps I described.

Revision history for this message
scottjmchugh (mchughs) said :
#9

Gotcha- I went back and added the sparkle xcode project to my app's project, and placed the framework in the Link Binary and Copy Files build phases. I can build the project without error at this point. Once I add sparkle as a dependency of my main target, I get the error below when I attempt to build it:
Checking DependenciesThe configuration settings file ConfigRelaunchRelease.xcconfig will not be used due to an error: 'MACOSX_DEPLOYMENT_TARGET[arch' isn't a valid variable name.
Build setting $(PRODUCT_NAME) undefined

My first thought was that perhaps the added project had its own build settings- but as far as I can tell it appears to share those of its parent project, which defines Product Name (as 'Kanji Go', rather than arch).

Thanks for your patience!
-Scott

Revision history for this message
Hofman (cmhofman) said :
#10

Wait, you're saying you were building on Xcode 2.5? And you're using Sparkle 1.5b5? This project requires Xcode 3.x, because architecture dependent build settings are not supported on 2.x. You need to edit ConfigCommon.xcconfig before you can build it on Tiger. Replace the "MACOSX_DEPLOYMENT_TARGET[arch=xxx]" with a single "MACOSX_DEPLOYMENT_TARGET = 10.4" and remove the "GCC_FAST_OBJC_DISPATCH[arch=ppc]" line. Also Sparkle-with-GC requires Leopard and Xcode 3.

Revision history for this message
Hofman (cmhofman) said :
#11

And moreover you need to change SDKROOT to MacOSX10.4u.sdk, and ARCHS to "ppc i386" in ConfigCommonRelease.xcconfig. I don't know if that's enough though.

Can you help with this problem?

Provide an answer of your own, or ask scottjmchugh for more information if necessary.

To post a message you must log in.