how to add a private framework?

Discussion in 'iOS Programming' started by MACloop, Jul 12, 2010.

  1. macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #1
    Hello,
    I have downloaded a framework in order to be able to handle auth on the iPhone. I have problems though to add this framework to my projects...
    This is how I did it:
    I checked out the project here
    I got a map with all files. As I understand I have to build the framework to be able to use it? So I opened the file MPOAuth.xcodeproj in xcode. Under the targets I then chose the framework and build. That was sucessfull regarding to Xcode. I took the framwork and dragged and droped it into my project and I right-clicked on the target in order to set a new build-phase. I chose Frameworks and dragged and dropped the added private framework as path. In the target hierarchy a new group was added called copy Files and into this group I dragged and dropped the framework. (I followed this tutorial)

    When I try to build and run the project I get 6 errors and they are all like this one:
    Code:
     in /Users/xxxxx/Desktop/test_MPO/Classes/MPOAuth.framework/MPOAuth, file was built for unsupported file format which is not the architecture being linked (i386)
    "_MPOAuthNotificationAccessTokenReceived", referenced from:
     _MPOAuthNotificationAccessTokenReceived$non_lazy_ptr in RootViewController.o
         (maybe you meant: _MPOAuthNotificationAccessTokenReceived$non_lazy_ptr)
    Does any one know what it means? What do I do wrong?
    MACloop
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Looks like you build the framework for the device (ARM) and are trying to use it in the simulator (i386).
     
  3. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #3
    ups...yes that might be right... Do I have to make one build for the simulator aswell in order to be abel to test it on the simulator?
     
  4. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #4
    So I did the same as above except for that I picked the Base SDK to be iPhone Simulator 3.1.3 adn when building the framework I got this error:

    Code:
    target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform
    
    Internal error occurred while creating dependency graph: ASSERTION FAILURE in /SourceCache/DevToolsBase/DevToolsBase-1648/pbxcore/Target.subproj/PBXTargetBuildContext.m:2061
    Details:  Assertion failed: [filePath isAbsolutePath]
    Object:   <PBXTargetBuildContext:0x201212e80>
    Method:   -setHeadermapToolInvocation:forFilePath:
    Thread:   <NSThread: 0x200ff46e0>{name = (null), num = 8}
    Backtrace:
      0  0x00000001002b517f -[PBXTargetBuildContext(DependencyGraphEvents) handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DevToolsCore)
      1  0x0000000100311c1a _XCAssertionFailureHandler (in DevToolsCore)
      2  0x00000001002b17d8 -[PBXTargetBuildContext setHeadermapToolInvocation:forFilePath:] (in DevToolsCore)
      3  0x0000000100153f23 -[XCCompilerSpecification computeDependenciesForFilePath:ofType:outputDirectory:inTargetBuildContext:] (in DevToolsCore)
      4  0x00000001003c9447 -[XCBuildRuleDGSnapshot(DependencyGraphCreation) computeDependenciesForFilePath:ofType:forBuildFileReference:withOutputDirectory:additionalProperties:inTargetBuildContext:] (in DevToolsCore)
      5  0x0000000100152987 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) _computeDependenciesForFilePath:ofType:forBuildFileReference:usingBuildRule:inTargetBuildContext:processedPaths:] (in DevToolsCore)
      6  0x0000000100152348 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForFilePath:ofType:forBuildFileReference:usingBuildRule:inTargetBuildContext:] (in DevToolsCore)
      7  0x000000010014fe72 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:inTargetBuildContext:] (in DevToolsCore)
      8  0x000000010014f2eb -[XCBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesInTargetBuildContext:] (in DevToolsCore)
      9  0x000000010014ee76 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesInTargetBuildContext:] (in DevToolsCore)
     10  0x000000010014b51d -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesInTargetBuildContext:] (in DevToolsCore)
     11  0x000000010013d81f -[XCProductTypeSpecification computeDependenciesInTargetBuildContext:] (in DevToolsCore)
     12  0x0000000100138a74 -[XCNativeTargetDGSnapshot(DependencyGraphCreation) computeDependenciesInTargetBuildContext:] (in DevToolsCore)
     13  0x00000001001344d1 -[PBXTargetBuildContext createDependencyGraphWithTargetDGSnapshot:] (in DevToolsCore)
     14  0x00000001001333d6 -[PBXTargetBuildContext(DependencyGraphEvents) dg_setTargetSnapshot:] (in DevToolsCore)
     15  0x00007fff80b19d2c __invoking___ (in CoreFoundation)
     16  0x00007fff80b19bfd -[NSInvocation invoke] (in CoreFoundation)
     17  0x0000000100132d3f -[PBXTargetBuildContext(DependencyGraphEvents) processDependencyGraphEvents] (in DevToolsCore)
     18  0x00007fff80b19d2c __invoking___ (in CoreFoundation)
     19  0x00007fff80b19bfd -[NSInvocation invoke] (in CoreFoundation)
     20  0x00000001001328f7 -[XCInvocationQueue _processNextInvocationInThreadSlotNumber:] (in DevToolsCore)
     21  0x0000000100132626 -[XCInvocationQueue _processInvocationsInThreadSlotNumber:] (in DevToolsCore)
     22  0x00007fff885eee8d __NSThread__main__ (in Foundation)
     23  0x00007fff844ed456 _pthread_start (in libSystem.B.dylib)
     24  0x00007fff844ed309 thread_start (in libSystem.B.dylib)
    How would you describe the way to add a private framework? Why is it not working like in the tutorial?
     
  5. macrumors 68020

    Joined:
    Oct 12, 2006
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    I've had a thought: you should go and check the documentation: you cannot use your own Frameworks on the iPhone (simulator or device).
     
  7. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #7
    I know! It is a third part framework and I thought this one was ok? So this means - every developer has to write this rather un-trivial stuff for auth. self? Is that effective?

    What do you mean by the framework not being a private one? Is it ok or not to use? I am a bit confused now... The code you told me to use seem to be equal to the one I hacve used. What is the difference and why should the one recommmended by you work better?
     
  8. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    A Private Framework is an Apple supplied/shipped one that is not part of the public API. You should never use these as Apple may change them at any time and will reject your app.

    A Third-Party Framework is a non-Apple supplied framework that is not supplied with the OS.

    Apple do not support dynamic linking for App Store app. This means you cannot include Third-Party frameworks in your app. You can statically link with third-party libraries which would enable you to link against a third-party auth library.
     
  9. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #9
    I do not understand wht you mean about this? May or may I not use third-part frameworks? If not, there is no use going on with my tests. The I have to write my own classes to solve this
     
  10. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #10
    You may not use a third-party framework but you may use a third-party, statically-linked library. A framework is not the same thing as a library. I can't really make it any simpler than that.
     
  11. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #11
    ok thanks
    so, if the developer self call it a framework i suppose it is one.
     
  12. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #12
    As I have all the source code, I suppose I could use the classes as they are, in my project? The alternative about statically-linked library is perhaps a easier way to reuse code? I mean, if I integrate the code from the framework into my code, it would be rather complicated. So, is there a better way to reuse code? How do I statically-link libraries?

    MACloop
     
  13. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #13
  14. thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #14

Share This Page