How to embed ParseKit as a private framework in a Mac App bundle

前端 未结 4 795
后悔当初
后悔当初 2020-12-15 10:32

I need to install ParseKit to compile with cocoa under Mac Os X, I use xcode 4. I have searched online but there is only a guide for installing parse kit for iPhone. Where d

相关标签:
4条回答
  • 2020-12-15 11:02

    I managed to do this using cocoapods. Try that if your stuck still

    0 讨论(0)
  • 2020-12-15 11:11

    Developer of ParseKit here.

    I'm sorry I don't have a good answer for you. I have some outdated docs on how to use ParseKit in your iOS application using Xcode 3.

    However, I've just tried to go through the process of embedding ParseKit.framework within a Mac OS X app using Xcode 4, and I honestly could not figure out how to do it in Xcode 4. I am baffled.

    What I can say, is that embedding ParseKit.framework in your Mac app should not be very different from embedding any other framework in your Mac app. There's nothing particularly special or unusual about ParseKit in this regard. The problem is I just can't figure out how to do that at all in Xcode 4.

    Here's Apple's documentation on how to do this:

    Embedding a Private Framework in Your Application Bundle > Using Separate Xcode Projects For Each Target

    Unfortunately, Apple's docs are also out of date, and also describe the process in Xcode 3.

    I have asked a question here on Stack Overflow to try to solve this problem.

    0 讨论(0)
  • 2020-12-15 11:14
    1. Open your project in Xcode 4
    2. Make sure Project Navigator is shown
    3. Ctrl click on your project file (the blue page icon)
    4. Select Add Files to "YourProjectName"
    5. Select ParseKit.xcodeproj
    6. In Project Navigator select your project file
    7. Go to Build Phases
    8. Disclose Link Binary With Libraries and either add ParseKit.framework by clicking + or drag'n'drop it from Project Navigator's Products directory of ParseKit.framework
    9. Add Copy File phase by clicking bottom right Add Build Phase button.
    10. Set destination to frameworks
    11. Repeat 8, but for new build phase

    You may also need to add Target Dependency: repeat step 8, but for this phase. But looks like Xcode can sort out them itself.

    I also recommend you to create a Workspace, it makes managing of subproject much easier and looks like this fixes most part of potential problems, because if Xcode fails to resolve dependencies, you can always add script to copy files manually, since products of projects will share the same build directory.

    0 讨论(0)
  • Developer of ParseKit here.

    OK, after working through a tricky issue in Xcode 4, I have figured out my preferred way to do this: Create a new Workspace ("MySuite") which contains two sub-Projects

    • Your Mac Cocoa Application Project ("MyApp")
    • The ParseKit Framework Project ("ParseKit")

    You can choose different names than "MyApp" and "MySuite" of course.

    There's a few different ways to make this happen. Here's one way:

    1. First, make sure you update to the very latest version of the ParseKit from the Google Code trunk. I have recently modernized the Xcode project for Xcode 4.3.1.

      svn checkout http://parsekit.googlecode.com/svn/trunk/ parsekit-trunk

    2. Make sure you do not have the ParseKit Xcode Project window open. This is an issue in Xcode up to version 4.3.1 (and maybe later, not sure).

    3. Create a Mac "Cocoa Application" Project named "MyApp". File > New > Project…. (You may have already created your app. That's fine. Then skip this step.)
    4. Drag the ParseKit.xcodeproj file from the Finder to the very top of the Project Navigator in the "MyApp" Xcode Project window. NOTE: make sure you drop the file at the very top of the Project Navigator tree. Otherwise it will not work. Drag ParseKit Project To MyApp Project Navigator

    5. Xcode will present a dialog: "Do you want to save this project in a new workspace?" Click "Save" and name the Workspace something like "MySuite". Save Workspace

    6. Select the "MyApp" Project in the Project Navigtor.
    7. Select the "MyApp" Target in the "Targets" list.
    8. Select the "Build Phases" tab.
    9. Click the disclosure triangle next to "Target Dependencies" to open the list.
    10. Click the "+" button at the bottom of the list.
    11. Select "ParseKit.framework" from the resulting dialog and click "Add" to add ParseKit as a dependency of your target. This ensures ParseKit is built before your target.
    12. Click the disclosure triangle next to "Link Binary With Libraries" to open the list.
    13. Click the "+" button at the bottom of the list.
    14. Select "ParseKit.framework" from the resulting dialog and click "Add".
    15. Click the disclosure triangle next to "Link Binary With Libraries" to open the list.
    16. Click the "+" button at the bottom of the list.
    17. Select "ParseKit.framework" from the resulting dialog and click "Add".enter image description here

    18. See "ParseKit.framework" in the "Link Binary With Libraries" list. enter image description here

    19. Click the "Add Build Phase" Button, choose "Copy Files" in the popup.Add Build Phase
    20. In the new "Copy Files" build phase, select "Frameworks" in the "Destination" popup.Choose Frameworks in the Destination popup
    21. Drag "ParseKit.framework" from the Project Navigator to the list in the new "Copy Files" build phase.Drag ParseKit.framework to Copy Files build phase
    22. In MyAppDelegate.m, import the ParseKit header:

      #import <ParseKit/ParseKit.h>

    23. In -[MyAppDelegate applicationDidFinishLaunching:] do:

      NSString *g = @"@start = Word+;";
      PKParser *p = [[PKParserFactory factory] parserFromGrammar:g assembler:self error:nil];
      NSError *err = nil;
      id result = [p parse:@"foo bar baz" error:&err];
      NSLog(@"%@", result);

    24. Build and run.

    For more info on this topic, see:

    • Apple's docs
    • Chapter 16 of Mastering Xcode 4 by Joshua Nozzi
    0 讨论(0)
提交回复
热议问题