Results 1 to 9 of 9

Thread: Mac OS X app bundle can't find bundled framework files

  1. #1

    Mac OS X app bundle can't find bundled framework files

    I'm trying to make a bundle of my Mac OS X app compiled by Free Pascal through Xcode. I've got SDL2, SDL2_mixer and SDL2_image in the Frameworks folder of my app bundle. But the app can't find them. The SDL2 binaries all have "@rpath/SDL2.framework/Version/A/SDL2" as their install names, so setting "Runtime Search Paths" in Xcode to "@executable_path/../Frameworks" should mean that the compiled binary can find the frameworks. But it still can't. So is there some issue with compiler parameters set in Xcode not being passed on to Free Pascal?
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  2. #2
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Don't know about Xcode, it is a pre-requisite but I'm pretty sure that the Xcode development environment itself and any configuration are totally ignored by Freepascal + Lazarus. I believe Freepascal makes use of the linker, debug symbols etc that come with Xcode and that's it. (for IOS development you're using XCode in the chain given the deployment restrictions)

    What I do know for certain is that using Lazarus on OSX, I had no problem at all using libs packaged inside the bundle.

    Due to using Lazarus as my IDE and not having any such problems, I've not looked into how these paths are defined during the compilation process.

    It is almost certainly the case that you're looking to set Freepascal options and not Xcode options - Freepascal is the compiler and I can't think of any good reason why it would read Xcode configurations over defining its own. In an ideal world Xcode wouldn't be needed at all - They'd be working to be free of the dependency, not get further in bed with it.

    So look into Freepascal and OSX platform specifics - It'll be some compiler parameter or other and don't expect Xcode to have any knowledge of Freepascal in order to pass the parameter. I may be wrong of course but given you're doing it by the book in Xcode and it's still not working? I'm probably right.

    If XCode can support third party compilers it'll have functionality to pass parameters, set environment variables etc which you can make use of - perhaps even the "Runtime search paths" as a variable you can pass as the relevant option to the compiler.
    Last edited by phibermon; 19-02-2015 at 09:20 AM.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  3. #3
    Thanks for you reply. Yeah, it definitely does seem like I have to pass this stuff on to Free Pascal manually. I'll look into it.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  4. #4
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Sorry I couldn't give you specifics.

    Ascii Sector is seriously cool by the way
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  5. #5
    Thanks! I'm going insane trying to get the new version to work on Mac OS X, though.

    From advise elsewhere, it does seem like Xcode's linking phase should have an affect, which makes sense, since I believe the whole point of doing this through Xcode is to use its linker. So now I'm stuck again.
    Last edited by Christian Knudsen; 19-02-2015 at 11:11 AM.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  6. #6
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Hmm. I've googled like a mad man and I've only managed to find the following pages that bare any resemblance to your problem :

    http://stackoverflow.com/questions/9...d-by-xcode-app

    http://forum.lazarus.freepascal.org/...?topic=20252.0

    along with the compiler directive {$linklib}

    also I had a problem with relative paths in bundles long ago during debugging/executing from my IDE (but it was my data files and not a lib) does it still happen when you run the bundle directly?

    Try an absolute path to a point in your file-system rather than the relative "@executable_path/../Frameworks"

    If an absolute path doesn't work then either the SDL2 libs you have are not valid (32bit vs 64bit?) or that directory is simply not being passed to the linker.

    Perhaps installing Lazarus and compiling there - see if you can replicate the problem. Also while it can't find the libs in the path you specify, perhaps it is looking elsewhere, try placing them at the root of the bundle, next to the binary etc. Perhaps the default path will be one of these.

    I think it would be worth eliminating those dynamic libs as the source of the problem (although to be fair they're likely fine) perhaps an existing SDL2 mac game/program that you can examine/swap files in.

    Can OSX have shared libraries in a system location? if so, try putting the SDL2 libs there which should definitely work - I know you want to bundle it all together but it will at least confirm this is a path issue and not something we're not guessing.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  7. #7
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    It would help if we understood the nature of the relative paths etc

    it might be worth getting an existing SDL2 bundle online and just swapping in your binary - perhaps the path isn't compiled into the binary at all, perhaps it's defined in some other file in the bundle.

    If needs be I'll fire up my Hackintosh and attempt to replicate your conditions
    Last edited by phibermon; 19-02-2015 at 01:54 PM.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  8. #8
    Everything runs fine if I have the SDL2 frameworks in /Library/Frameworks.

    But trying to find en existing SDL2 bundle and see if I can just use the frameworks from that is a brilliant idea. I'll see if I can find one. (Though I'm just using the SDL2 frameworks downloaded directly from libsdl.org and if they can't be bundled with my app, it must be a problem with my app and not the frameworks?)
    Last edited by Christian Knudsen; 19-02-2015 at 02:25 PM.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  9. #9
    Yes!

    Adding -k"-rpath @executable_path/../Frameworks" as a custom linker option for FPC did it!



    So the linker parameters weren't passed on from Xcode to Free Pascal. At this point I'm wonder what exactly I'm using Xcode for?!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •