Marinell / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

ios new VM build error when overriding main class and use protected static Object context #1254

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a project with two packages: a free and non-free version. For the free 
version, I only made a new package within the project (free) with the same name 
of the 'main' class. I override the 'main' class, changing only the init 
function. This works well on Android, but on iOS I get a build error:

Ld build/Release-iphoneos/MyApplication.app/MyApplication normal armv7
    cd /var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
    setenv PATH "/Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode5.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
    /Applications/Xcode5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -L/var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/build/Release-iphoneos -L/var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/MyApplication-src -F/var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/build/Release-iphoneos -filelist /var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/build/MyApplication.build/Release-iphoneos/MyApplication.build/Objects-normal/armv7/MyApplication.LinkFileList -dead_strip -fobjc-link-runtime -miphoneos-version-min=6.0 -framework OpenGLES -framework CoreGraphics -framework UIKit -framework GLKit -framework Foundation -liconv -framework AdSupport -framework AddressBookUI -framework SystemConfiguration -framework MapKit -framework AudioToolbox -lxml2 -framework QuartzCore -framework AddressBook -lsqlite3 -lsqlite3.0 -framework GameKit -framework Security -framework StoreKit -framework CoreMotion -framework CoreLocation -framework MessageUI -framework MediaPlayer -framework AVFoundation -framework CoreVideo -framework QuickLook -framework iAd -framework CoreMedia -lz -lzbar -Xlinker -dependency_info -Xlinker /var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/build/MyApplication.build/Release-iphoneos/MyApplication.build/Objects-normal/armv7/MyApplication_dependency_info.dat -o /var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build3312139565011727985xxx/dist/build/Release-iphoneos/MyApplication.app/MyApplication
Undefined symbols for architecture armv7:
  "_com_mycompany_myapp_MyApplication_context", referenced from:
      _com_mycompany_myappfree_MyApplication_init___java_lang_Object in com_mycompany_myappfree_MyApplication.o
     (maybe you meant: _set_static_com_mycompany_myapp_MyApplication_context, _get_static_com_mycompany_myapp_MyApplication_context , _STATIC_FIELD_com_mycompany_myapp_MyApplication_context )
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
        Ld build/Release-iphoneos/MyApplication.app/MyApplication normal armv7
(1 failure)

What steps will reproduce the problem?
1. Make a Hello World project.
2. Add a member variable protected static Object context
3. Add in the init: HelloWorld.context = context;
4. Add a new package: com.mycompany.myapp2 and a class with the same name as 
the class in the Hello World project. 
5. Add in the init of myapp2.MyApplication: HelloWorld.context = context;
6. In the properties, set the com.mycompany.myapp2 as the package name
7. Build the package with the new iOS VM.

What is the expected output? What do you see instead?
The expected output is a 'valid' app, like on Android and the old VM. Instead I 
get the build error I stated above.

Please provide any additional information below.
I added a project file in a zip. Code of issue 1243 is also in the zip. I 
removed the .zip, .jar and .properties file from the project.

Original issue reported on code.google.com by iolar...@gmail.com on 2 Jan 2015 at 8:14

GoogleCodeExporter commented 9 years ago
I'm sorry I didn't add the .properties file, which is needed to test the build. 
I removed the certificate information and the zip and jar files from the new 
zip (added to this post).

Original comment by iolar...@gmail.com on 3 Jan 2015 at 4:09

Attachments:

GoogleCodeExporter commented 9 years ago
A workaround for this issue is to change the init implementation of the 
subclass to this:
    public void init(Object context) {
        super.init(context);
    }

Original comment by shai.almog on 8 Jan 2015 at 9:54

GoogleCodeExporter commented 9 years ago
This works, thank you.

Original comment by iolar...@gmail.com on 11 Jan 2015 at 2:26