Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3802] Problem with multiple modules and OTHER_LDFLAGS

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-05-26T18:23:08.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sRelease 1.7.0, Sprint 2011-21
ComponentsiOS
Labelsbuild, ios
ReporterJeff English
AssigneeJeff English
Created2011-04-28T07:04:20.000+0000
Updated2013-03-27T12:52:09.000+0000

Description

When building an app that includes multiple modules and each module has OTHER_LDFLAGS defined in their module.xcconfig file, only the flags for the last module are used in the build. This causes the build to fail because the flags for the first module are not included during the link step. This issue was referenced in the developer center (http://developer.appcelerator.com/question/103551/problem-with-multiple-modules-and-otherldflags) but has recently come up with a customer using a calendar module and the barcode module. Both of these modules require the use of OTHER_LDFLAGS: Barcode: OTHER_LDFLAGS=$(inherited) -liconv Calendar: OTHER_LDFLAGS=$(inherited) -framework EventKit The module.xcconfig file that is generated for the app by the build process (compiler.py) contains two #include statements that include each module's xcconfig file. However, due to a known limitation in XCode, $(inherited) does not work as expected for included xcconfig files. Only the last setting of the symbol is used as each symbol assignment replaces the previous one. One end-user workaround is to edit the module.xcconfig file for the last included module so that it contains all of the combined OTHER_LDFLAGS from all of the included modules. For example, if Calendar is the last listed module in tiapp.xml, then its module.xcconfig file could be changed to OTHER_LDFLAGS=$(inherited) -framework EventKit -liconv But this requires additional updates by the user if additional modules are added to the app or flags change for any of the modules.

Comments

  1. Kincy Clark 2011-04-28

    THis is pretty high priority. I would like to have at least a scope on this.
  2. Stephen Tramer 2011-05-06

    Pushing back to Sprint 19 so that debugger can take priority.
  3. Jeff English 2011-05-25

    This needs to be revisited as the following items are not currently handled: 1. Must handle local variable references such as: MY_FLAGS=-liconv OTHER_LDFLAGS=$(MY_FLAGS) 2. Must handle use of platform specific settings such as: OTHER_LDFLAGS[sdk=iphoneos4*]=-liconv OTHER_LDFLAGS[sdk=iphonesimulator*]=-liconv -framework EventKit in one file and OTHER_LDFLAGS=-framework GameKit in another file. This one is a little more complicated as the final OTHER_LDFLAGS needs to take into consideration the platform specific settings in the combined result.
  4. Jeff English 2011-05-26

    COMPLEX TEST CASE This test demonstrates all of the new features of the compiler, handling shared variable names, platform specific modifiers, and local variable references. 1. Modify the tiapp.xml to include multiple modules (UrbanAirship, Barcode, MagTek). Can be any modules so long as you each has a module.xcconfig file with common flag names (e.g. OTHER_LDFLAGS)
          ...
          	<modules>
       		<module version="1.0">ti.urbanairship</module>
       		<module version="1.1">ti.barcode</module>
       		<module version="1.0">ti.magtek</module>
       	</modules>
          ...
         
    2. Modify the module.xcconfig files so that they use local variable names AND also make use of platform specific modifiers.
     
            //OTHER_LDFLAGS=$(inherited) -ObjC -all_load -weak_library /usr/lib/libSystem.B.dylib -framework security -framework CoreTelephony
       FLAGS1=-ObjC -all_load
            OTHER_LDFLAGS=$(inherited) $(FLAGS1) -framework security -framework CoreTelephony
            OTHER_LDFLAGS[sdk=iphoneos4*]=-weak_library /usr/lib/libSystem.B.dylib
            OTHER_LDFLAGS[sdk=iphonesimulator4*]=/usr/lib/libSystem.B.dylib
         
            //OTHER_LDFLAGS=$(inherited) -liconv
            MY_FLAGS=-liconv
            OTHER_LDFLAGS=$(inherited) $(MY_FLAGS)
         
            //LD_FLAGS=$(inherited) -framework ExternalAccessory
            MY_FLAGS=-framework ExternalAccessory
            OTHER_LDFLAGS=$(inherited) $(MY_FLAGS)
         
    3. Build/run the project. Project should build and run successfully 4. Examine the module.xcconfig file that is generated during the build process. This module.xcconfig file is located in the build/iphone folder of the project. It should contain something like the following:
           // this is a generated file - DO NOT EDIT
       
           TI_URBANAIRSHIP_FLAGS1=-ObjC -all_load
           TI_URBANAIRSHIP_OTHER_LDFLAGS=$(inherited) $(TI_URBANAIRSHIP_FLAGS1) -framework security -framework CoreTelephony
           TI_URBANAIRSHIP_OTHER_LDFLAGS_sdk_iphoneos4__=-weak_library /usr/lib/libSystem.B.dylib
           TI_URBANAIRSHIP_OTHER_LDFLAGS_sdk_iphonesimulator4__=/usr/lib/libSystem.B.dylib
       
           TI_BARCODE_MY_FLAGS=-liconv
           TI_BARCODE_OTHER_LDFLAGS=$(inherited) $(TI_BARCODE_MY_FLAGS)
       
           TI_MAGTEK_MY_FLAGS=-framework ExternalAccessory
           TI_MAGTEK_OTHER_LDFLAGS=$(inherited) $(TI_MAGTEK_MY_FLAGS)
       
           OTHER_LDFLAGS[sdk=iphoneos4*]=$(inherited) $(TI_URBANAIRSHIP_OTHER_LDFLAGS_sdk_iphoneos4__) 
           OTHER_LDFLAGS[sdk=iphonesimulator4*]=$(inherited) $(TI_URBANAIRSHIP_OTHER_LDFLAGS_sdk_iphonesimulator4__) 
           FLAGS1=$(inherited) $(TI_URBANAIRSHIP_FLAGS1) 
           MY_FLAGS=$(inherited) $(TI_BARCODE_MY_FLAGS) $(TI_MAGTEK_MY_FLAGS) 
           OTHER_LDFLAGS=$(inherited) $(TI_URBANAIRSHIP_OTHER_LDFLAGS) $(TI_BARCODE_OTHER_LDFLAGS) $(TI_MAGTEK_OTHER_LDFLAGS) 
         
  5. Jeff English 2011-05-26

    https://github.com/appcelerator/titanium_mobile/commit/f908030b67ee5231926b6c57635d0f9b034f9eeb
  6. Natalie Huynh 2011-06-03

    Tested with Jun 2 2011 11:39 rc9515533

JSON Source