iOS ARC (Automatic Reference Counting) Support

ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
Hi,

does IceTouch 1.2 support ARC?

The generated Files are not ARC-compliant.

Is there a way to switch off ARC for the generated files?
The files are not listed under the compile sources. Is it possible
to add the compiler flag (-fno-objc-arc) to the generated files?

At the moment i switched off ARC for the whole Project.
Which is not a good solution...

Comments

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff
    Hi Arthur,

    We currently don't support automatic reference counting with Ice Touch. Adding this is on our TODO list however. There's no easy way to turn off ARC for generated files but I can think of 2 options to do it:
    • Create a static library project to compile the Slice files and generated code ARC turned off for the static library project.
    • Don't use the Xcode plugin to compile the Slice files but manually build the Ice files and add the generated sources to your project and turn ARC off on the generated files.

    Cheers,
    Benoit.
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    benoit wrote: »
    Create a static library project to compile the Slice files and generated code ARC turned off for the static library project.

    Thanks for your response Benoit.

    Anyway the project requires a static library which handles some communication..
    At the moment im trying to integrate ICE over a static Library. But im getting the following
    Error. Can you point me in the right direction?

    Libtool DerivedData/ProjWorkspace/Build/Products/Debug-iphoneos/libPushSupport.a normal armv7
    cd /Users/Arti/Projekte/Mobile/Proj/App/Proj
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool -static -arch_only armv7 -syslibroot /var/folders/81/81hAzeK8HWm2hnbJ5EHUMU+++TI/-Caches-/com.apple.Xcode.501/CompositeSDKs/iphoneos-iPhoneOS5.0-djkhsmzpagbpgpacthuebkbvnnuu -L/Users/Arti/Projekte/Mobile/Proj/App/Proj/DerivedData/ProjWorkspace/Build/Products/Debug-iphoneos -filelist /Users/Arti/Projekte/Mobile/Proj/App/Proj/DerivedData/ProjWorkspace/Build/Intermediates/PushSupport.build/Debug-iphoneos/PushSupport.build/Objects-normal/armv7/PushSupport.LinkFileList -ObjC -all_load -lstdc++ -lIceObjC -framework ExternalAccessory -framework Foundation -framework Security -framework CFNetwork -o /Users/Arti/Projekte/Mobile/Proj/App/Proj/DerivedData/ProjWorkspace/Build/Products/Debug-iphoneos/libPushSupport.a

    Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool failed with exit code 1
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi Artur,

    The problem is that Ice Touch Xcode plug-in currently do not support build static libraries, you need to manually configure the project.

    To disable the plug-in don't add IceTouch to ADDITIONAL_SDKS, you will need to add /Developer/SDKs/IceTouch-1.2/$(PLATFORM_NAME)/usr/local/include to the project include directories, and you will also need to run slice2objc and add the generated files to your project. Probably you can run slice2objc from a custom build step in Xcode or you can do it manually.
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    xdm wrote: »
    Hi Artur,

    The problem is that Ice Touch Xcode plug-in currently do not support build static libraries, you need to manually configure the project.

    To disable the plug-in don't add IceTouch to ADDITIONAL_SDKS, you will need to add /Developer/SDKs/IceTouch-1.2/$(PLATFORM_NAME)/usr/local/include to the project include directories, and you will also need to run slice2objc and add the generated files to your project. Probably you can run slice2objc from a custom build step in Xcode or you can do it manually.

    I removed the ADDITIONAL_SDKS and generated and added the files with slice2objc.

    But where i have to add the path to the ICE-implementation?

    I tried it in "Framework Search Paths" , "Header Search Paths" , "User Header Search Paths"
    but still got Error with #import <Ice/Ice.h>
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    You should use "Header Search Path" note is a missing .sdk in the path of my previous post, it should be:
    /Developer/SDKs/IceTouch-1.2/$(PLATFORM_NAME).sdk/usr/local/include 
    

    Note the .sdk after $(PLATFORM_NAME)
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    Added the path with .sdk to Header Search Path,
    but still cant #import <Ice/Ice.h>

    Its strange because the error appears only if i try to import the main-header from the static library to my implementation.
    If i remove the static library import. The static library project with ICE builds without errors.
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    I moved the imports:

    #import <Ice/Ice.h>
    #import <Slice.h>

    to the .m implementation file of my static library.

    Now at least it compiles :)
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    I cheered too soon!

    If i try to instantiate my static library object i get the following linker errors:

    Undefined symbols for architecture armv7:
    "_OBJC_EHTYPE_$_ICEUserException", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEUtil", referenced from:
    xxx
    "_OBJC_METACLASS_$_ICEObject", referenced from:
    xxx
    "_ICEInternalLookupString", referenced from:
    xxx
    "_OBJC_METACLASS_$_ICEObjectPrx", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEOperationNotExistException", referenced from:
    xxx
    "_OBJC_EHTYPE_$_ICEException", referenced from:
    xxx
    "_ICEInternalCheckModeAndSelector", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEUnknownUserException", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEObject", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEObjectPrx", referenced from:
    xxx
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi Artur,

    Not sure i understand what you are doing.

    You get this problem when you include the main header of the static library project in your application. If that is the case:

    You need to configure your application to use the Ice Touch plug-in, as you need to link with Ice Touch libs not just with your static libraries. The plug-in will also take care to configure the Header Search Path.

    When you add the includes in your .m that is private for the library implementation so the applications don't see it, but you still need the plug-in so your application is linked with Ice Touch libraries.

    The linker errors are because you don't link with Ice Touch libraries, add the plug-in setting ADDITIONAL_SDKS and all should work
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    hi xdm,

    thanks for your fast reply!

    The project Im working on, uses ARC and i have a strict requirement to include ICE over a static library.

    The good thing is, that the problem with ARC would be solved if i use a static library. Because i can turn off ARC for this library and still use it in the main-project.

    But now i have this trouble with the static library.

    Is there an example implementation with a static library?
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi Artur,

    I'm afraid there isn't a demo to use Ice Touch with a static library project.

    You should try this:

    You build the generated files in a static library project with ARC disabled

    In you application with ARC enabled, you link with your static library and with Ice Touch library.

    To link with Ice Touch library the easy is to enable the plug-in, but don't add Slice files in your application project, slice files should go in your static library.

    The problem with ARC is that slice2objc generated code is not compatible with ARC, but if the generated code is in your static library where ARC is disabled there shouldn't be problems. Note that Ice Touch is just a static library compiled without ARC.
  • ArturFriesenArturFriesen Artur FriesenOrganization: personalProject: small game with push-supportMember
    xdm wrote: »
    Hi Artur,

    I'm afraid there isn't a demo to use Ice Touch with a static library project.

    You should try this:

    You build the generated files in a static library project with ARC disabled

    In you application with ARC enabled, you link with your static library and with Ice Touch library.

    To link with Ice Touch library the easy is to enable the plug-in, but don't add Slice files in your application project, slice files should go in your static library.

    The problem with ARC is that slice2objc generated code is not compatible with ARC, but if the generated code is in your static library where ARC is disabled there shouldn't be problems. Note that Ice Touch is just a static library compiled without ARC.

    If I understand you right, then "enable the plug-in" means that I add "/Developer/SDKs/IceTouch-1.2/$(PLATFORM_NAME).sdk" to Additional SDKs in my Target-Build-Settings. Add the right .frameworks. Add "$(SDKROOT)/ResourceRules.plist" to Code Signing Resource Rules Path.

    I did that and still the following errors:

    Undefined symbols for architecture armv7:
    "_OBJC_EHTYPE_$_ICEUserException", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEUtil", referenced from:
    xxx
    "_OBJC_METACLASS_$_ICEObject", referenced from:
    xxx
    "_ICEInternalLookupString", referenced from:
    xxx
    "_OBJC_METACLASS_$_ICEObjectPrx", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEOperationNotExistException", referenced from:
    xxx
    "_OBJC_EHTYPE_$_ICEException", referenced from:
    xxx
    "_ICEInternalCheckModeAndSelector", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEUnknownUserException", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEObject", referenced from:
    xxx
    "_OBJC_CLASS_$_ICEObjectPrx", referenced from:
    xxx
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)


    To make the situation a little bit clearer. I try to describe my setup:

    Im using XCode4. I have a workspace. Within this workspace there ist the main-project and another project as a static library. I just want to add the ICE-implementation to the static library project. And then use this static library in my main-project to do some communication. I did the workspace setup like described in this blog: Using Open Source Static Libraries in Xcode 4 | The Carbon Emitter

    I tried all kind of combinations and im fighting with this since 5 days. I tried to use the plugin in both, the main-project and the static library. I also tried to include "/Developer/SDKs/IceTouch-1.2/$(PLATFORM_NAME).sdk/usr/local/include" in different places. Nothing works.
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi Artur,

    I think the problem is that IceTouch XCode plug-in don't work well with workspaces, we have not tested it before, but when tested i found that this don't work well.

    To workaround the problem i see two options:

    Create a single project where you manually add generated files and turn off ARC for the generated files, don't add Slice files to the project, you can enable the plug-in to automatically link with IceTouch SDKs.

    Or create two separate projects, the lib project with no ARC, no IceTouch plug-in, and Slice files that you need to compile manually, and Header Search Path configured. And the application project with must enable the plug-in to link with IceTouch libraries, and add also your library to "Linked Frameworks and Libraries"

    Also note that your ARC enabled sources cannot direct or indirectly include Ice headers, or you will get errors similar to:
    /var/folders/0x/16rd6qxx33nct7h8qsw7rm780000gn/C/com.apple.Xcode.501/CompositeSDKs/iphonesimulator-iPhoneSimulator5.0-bsphxshsjdajccawfivcxwmfzbyb/usr/local/include/Ice/Object.h:24:39:{24:29-24:41}:
    error: must explicitly describe intended ownership of an object array
    parameter [4]
     int ICEInternalLookupString(NSString *[], size_t, NSString *);
                                 ~~~~~~~~~~^~
    1 error generated.
    

    Maybe is just easy to not use ARC and wait until IceTouch include support for it to switch to ARC.
  • rl1rl1 Rene LimbergerOrganization: Rene LimbergerProject: iOSMember
    Hi,

    what is the ETA for ARC support in IceTouch? I have a ARC project that i want to add Ice support to.

    Thanks so much,
    -r
Sign In or Register to comment.