Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Wax Issue? — Gideros Forum

Wax Issue?

ljp1203ljp1203 Member
edited October 2012 in General questions
Hi all!

I need some help with implementing Wax into my app.

I followed @bowerandy video tutorial video exactly. But every time I try to run my GiderosIOSPlayer, it says I have a sematic issue and it won't let me run and it says build failed. I've attached a screenshot of what is happening and hopefully you can help me!

Thanks!
-Landon
Screen Shot 2012-10-19 at 10.14.51 PM.png
1394 x 818 - 392K
JLS
Lead Coder and Designer
Tagged:

Comments

  • bowerandybowerandy Guru
    edited October 2012
    The "semantic" error that Xcode reports is nothing special; it's just a compile or linker error. It means you are missing a header file or you've put a file in the wrong place. It is not obvious from your screenshot what the problem is. If it was me having this problem I would start again from scratch. Have you tried that? Unpack the plugin source in the Gideros folder, download the latest wax and follow the video again.

    Best regards
  • Hi @bowerandy,

    I started again from scratch and still got the same problem. What header files would I be missing?

    Thanks!
    -Landon
    JLS
    Lead Coder and Designer
  • bowerandybowerandy Guru
    edited October 2012
    Hi @ljp1203, you have to remember that I don't work for Gideros and I don't get paid for any of this. I already said that it wasn't obvious from your screenshot what the problem was so how can I say what header file might be missing?

    Don't get me wrong, in most cases I'm happy to help out but you don't seem to be willing to put in any effort to help me (or anyone else) help you.

    Look at it like this. What do you expect me to do? I could record another, more detailed, video or I could write down step by step the process of building the plugin. Each of these would take at least an hour of my time and there would still be no guarantee of success.

    Have you thought about what you could do to make it easier for people to help you? Perhaps you could record a video of what you are doing and post that up so we can see where the problem is? Perhaps you could upload your XCode project to Dropbox so I can look at it? You could even start by saying what version of Gideros you are using or what version of Xcode?

    Sorry for the rant - maybe I've had a bad day

    Best regards
  • SimpleLoopSimpleLoop Member
    Accepted Answer
    @ljp1203 here is a link to download our iOS Player xCode project with the wax plugin already in. This is made using the latest version of xCode.
    We use this for ourselves and therefore know it works.

    https://www.dropbox.com/s/ez48j1uy5mgvvl5/GiderosiOSPlayer.zip

    Hope this helps
    If your problem persists maybe it is a problem with the version of xCode you are using, try making sure you have the latest version.

    @bowerandy and @atilim hope you don't mind me sending this as it contains both the Gideros iOS Player code by atilim and the wax plugin by bowerandy.
  • Hey @SimpleLoop ,

    I now I just have one more question, how do I add a status bar to my app?

    I used:
     
    UIApplication:sharedApplication():setStatusBarHidden_animated(false, false)
    But that didn't work. @bowerandy told me to put it into my main.lua file, but when I put it in there it doesn't build the app. It says:

    main.lua:1: attempt to index global 'UIApplication' (a nil value)
    stack traceback:
    main.lua:1: in main chunk

    If it helps, I am using SceneManager.

    Thanks!
    -Landon
    JLS
    Lead Coder and Designer
  • gorkemgorkem Maintainer
    @simpleloop nope, as long as you distribute the player for non-commercial, educational purposes. But if you accidentally make several millions out of it, remember that we are your friends >:D<
  • SimpleLoopSimpleLoop Member
    Accepted Answer
    @ljp1203 add the contents of this zip file to your Gideros Project
    https://www.dropbox.com/s/jbrseuj6ldgngos/Wax.zip

    Then add require "wax" to the top of your main.lua file

    That should fix it :)

    @gorkem thanks, I'm not sure how haha but if I do I'd be glad to invest.
  • bowerandybowerandy Guru
    edited October 2012 Accepted Answer
    But that didn't work. @bowerandy told me to put it into my main.lua file, but when I put it in there it doesn't build the app. It says:

    main.lua:1: attempt to index global 'UIApplication' (a nil value)
    stack traceback:
    main.lua:1: in main chunk
    If you look in the "init.lua" file in the BhWaxDemo project that comes with the original download you will see it says:
    -- We load the Wax system here in init before any other Lua files are loaded.
    -- This gives all other Lua files immediate access to Objective-C via Wax.
     
    require "wax"
     
    -- This metatable magic allows for undefined Lua globals to be looked up in
    -- the Wax class dictionary.
     
    setmetatable(_G, {
    	__index = function(self, key)
        local class = wax.class[key]
        if class then self[key] = class end -- cache it for future use
     
        if not class and key:match("^[A-Z][A-Z][A-Z]") then -- looks like they were trying to use an objective-c obj
          print("WARNING: No object named '" .. key .. "' found.")
        end
     
        return class
      end
    })
    In short you need to include that "init.lua" (or its contents) in any project that uses BhWax.

    BTW, I guess that Xcode project that @SimpleLoop sent you fixed the problem? Did you look back and find out what the issue was? Otherwise you are going to have the same difficulty when you try and export your own Gideros projects and deploy them.

  • @ljp1203 yes it would be interesting if you managed to track down the error.

    From reading your error message it looks like since it is saying that wax_setCurrentLuaState() is undeclared it appears that the original wax.m or .h file from the Corey Johnson wax project is not in your project.

    If you could make sure all the files that are in our Gideros iOS Players plugins/wax folder in xCode are in your project. As I think it may just be down to a missing file.
  • bowerandybowerandy Guru
    Accepted Answer
    @SimpleLoop, have you tried the latest method of adding the hotwax plugin using the static library? It's detailed here. I'd be interested to here how others get along with it. It should save a lot of file dragging.

    best regards
  • @bowerandy that's amazing :D, hadn't noticed it but just downloaded now.
    Removed the old hotwax plugin from my Gideros iOS Player and added the new static library and Linker Flag in under 10 seconds and it appears to work perfectly.

    Thank you so much for making it a static library was so much easier than finding all the bits and putting them in the right place.

    One quick question, you don't happen to know how to do UIAnimations using it do you?

    I have this function run by a button:

    function ioButtonAction(self, sender)

    frame = self.imageViewToAnimate:frame()
    frame.y = 0

    self:view():beginAnimations(nil):context(nil)
    self:view():setAnimationDuration(1000)
    self:view():setAnimationDelay(0)
    self:view():setAnimationCurve(UIViewAnimationCurveLinear)

    self.imageViewToAnimate:setFrame(frame)

    self:view():commitAnimations()
    end

    but keep getting this error in the xCode debugger:
    attempt to call method 'beginAnimations' (a nil value)
    Obviously it can't find the method beginAnimations on the view self:view().

    but as far as I can tell the function is correct as in xCode it looks like this and works without issue:

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:duration];
    [UIView setAnimationDelay:delay];
    [UIView setAnimationCurve:animCurve];

    imageViewToAnimate.frame = frame;

    [UIView commitAnimations];

    although in xCode it is UIView not an actual view but when I tried that in place of self:view() it said attempt to call global 'UIView' (a userdata value).

    Any help appreciated as always.
  • @SimpleLoop, just off to bed now but after cursory look at what you're trying to do...

    I haven't tried UIAnimations but based on the code you have at the bottom, shouldn't it be:

    UIView:beginAnimations_context(nil, nil)

    The line [UIView beginAnimations:nil context:nil] is a single message send. You can tell because it is between a single set of square braces. The message selector is beginAnimations:context:, which maps to beginAnimations_context() in the wax world.

    BTW, just in case you are playing with UIAnimations because you haven't seen it, you can also do animations with UIView controls that are compatible with the rest of Gideros by wrapping your controls in a BhUIViewFrame. Check out the BhWaxPhysicDemo files for an example. Here's the video:



    best regards

    Dislikes: bgcis

    +1 -1 (+0 / -1 )Share on Facebook
  • Hi @bowerandy @SimpleLoop ,

    I have yet another question :D

    How could I add a tab bar at the bottom of the application to allow me switch between different views?

    Thanks!
    JLS
    Lead Coder and Designer
  • @bowerandy thanks I tried that before but on self:View() changing it to

    UIView:beginAnimations_context(nil, nil)
    UIView:setAnimationDuration(1000)
    UIView:setAnimationDelay(0)
    UIView:setAnimationCurve(UIViewAnimationCurveLinear)

    imageViewToAnimate:setFrame(frame)

    UIView:commitAnimations()

    doesn't throw any errors but also doesn't seem to animate but if I go to another view then back to that one it appears to be in the new position.
    So it appears that the UIView:commitAnimations() is not working.

    I'll keep fiddling and say if I get it working.
    Thanks for all your help.

    @ljp1203 you should be able to create a UITabBarController and add it to the main view then create two UIView controllers and add them to it.

    To create the tab bar it would be something like.
    tabBarController = UITabBarController:init()
    tabBarController :setFrame(CGRect(0, 0, 320, 460))

    tabBarController:setViewControllers(array of controllers)

    self:view():addSubview(tabBarController:view())

    Hope this helps.
  • @bowerandy I feel like such an idiot right now hahaha.

    The code works perfectly now.
    The problem was that xCode does the duration in seconds rather than miliseconds so I was setting the duration to 1000 seconds therefore did not notice that it was actually doing it. After changing it to 1 second it works perfectly.

    Thanks for all your help with this.
  • bowerandybowerandy Guru
    edited October 2012
    @SimpleLoop, yes I've done that before with Timers. They use milliseconds and tweens use seconds. One can end up waiting a long time and doing a lot of head scratching after making that mistake! Still, you probably only make it once. I-)

    I'm glad you've sorted the problem and got it working.

    One thing though. You seem to have a bit of confusion over when to use :view() and when to use UIView itself. You may have worked this out but the thing to realize is that UIView is a class object and self:view() returns an instance of that class.

    In ObjectiveC classes are also objects. So if I do:

    local tvClass=UITextView
    local tvInstance=UITextView:initWithFrame(CGREct(blah, blah))

    Then tvClass is holding a pointer to the UITextView class object and tvInstance is hold the pointer to the UITextView object (the actual text view) itself. Most of the time you only deal with class objects when you want to create new instances of the class. All the initXXX methods in Wax are *class methods* because you action them off a class object. Sometimes class objects are called "factory objects" because they are used to build instances (like a factory).

    Once you have an instance object (tvInstance in the above) then you can call instance methods on it. In the IOS documentation, e.g. for UIView you can see which methods are class methods because they are marked with a "+". Instance methods are marked with a "-". So look in the docs for UIView and find the Animating Views section and you'll see that all those animation methods are class (+) methods. This means they must go to UIView itself (the class object). That's why you do:

    UIView:beginAnimations_context(nil, nil)

    rather than:

    self:view():UIView:beginAnimations_context(nil, nil)

    But @bowerandy, you say. How come I call initWithFrame: as if it is a class method? It's marked with a "-" in the docs. This is an exception because of the way Wax works. There are no calls to "alloc" in Wax because all the memory management is done for you. For this reason Corey Johnson (the inventor of Wax) chose to make all the initXXX instance methods *appear* as if they are class methods. It's confusing but once you get used to itit, it all makes sense.

    I'm sorry if you knew all this already; I just thought I'd try to clarify in case you didn't.

    best regards

    PS: At some point, if you are curious, you are going to ask yourself, "if all class objects are objects themselves and all objects have classes, them what is the class of a class object?". I warn you now, that way madness lies. You will need to bind your head with a strap to keep your brain in if you try to understand it all. :)
  • Hi @bowerandy @SimpleLoop ,

    I have yet another question :p

    How do I add native textfields to allow users to add info into them?

    Thanks!
    -Landon
    JLS
    Lead Coder and Designer
  • bowerandybowerandy Guru
    edited October 2012
    @ljp1203, the first bhWax demo program, BhWaxDemo.lua shows you how to do this. Did you not look at it? How about the function BhWaxDemo:createTitle()?
  • Hi @bowerandy

    I downloaded your sample project from https://github.com/bowerhaus/BhWax

    And whenever I would try to run it, it would give me errors saying that .lua files didn't exist and also other wax realted issues.

    Thanks!
    -Landon
    JLS
    Lead Coder and Designer
  • Here is how to add a UITextField
    You will need to make your view a UITextField Delegate
    To do this I have a separate lua file called mainView.lua

    Into this file I put

    -- This makes it into a UIViewController and UITextFieldDelegate
    waxClass{"mainView", UIViewController, protocols = {"UITextFieldDelegate"}}

    -- Init the View
    function init(self)
    self.super:init()
    return self
    end

    -- When the view loads add the stuff to it
    function viewDidLoad(self)

    -- Add a textField
    self.mainTxt = UITextField:initWithFrame(CGRect(30,30,260,80))
    -- set the delegate
    self.mainTxt:setDelegate(self)
    -- Set Border Style
    self.mainTxt:setBorderStyle(UITextBorderStyleRoundedRect)
    -- Set Placeholder text
    self.mainTxt:setPlaceholder("Main Text")
    -- Set Text Alignment
    self.mainTxt:setTextAlignment(UITextAlignmentCenter)
    -- Add to view
    self:view():addSubview(self.mainTxt)

    end

    ----- Text Field Delegate Functions -----

    function textFieldShouldBeginEditing(self, textField)
    print("textFieldShouldBeginEditing")
    return true
    end

    function textFieldDidBeginEditing(self, textField)

    end

    function textFieldShouldEndEditing(self, textField)
    print("textFieldShouldEndEditing")
    return true
    end

    function textFieldDidEndEditing(self, textField)
    print("textFieldDidEndEditing")
    end

    function textFieldShouldReturn(self, textField)
    print("textFieldShouldReturn")
    textField:resignFirstResponder()
    return true
    end

    Then in my main.lua I put

    local mainView = mainView
    getRootViewController():view():addSubview(mainView:view())

    Any problems happy to help.
  • bowerandybowerandy Guru
    edited October 2012
    I downloaded your sample project from https://github.com/bowerhaus/BhWax
    And whenever I would try to run it, it would give me errors saying that .lua files didn't exist and also other wax realted issues.
    @ljp1203, all of my libraries live in a particular directory structure that is listed in the READEME files. So that I don't have to duplicate files in each GitHaub respository you need to reproduce this structure and probably take more than one repo for any demo to run correctly. This blog article shows how it is set up.

    For the BhWax library I believe you will also require the Misc, Gideros, CoreytJohnsonWax and BhHelpers repositories on your machine. You need to make sure they go in the right directories as specified in the READMEs.

    best regards
  • Hi @bowerandy @SimpleLoop

    Thanks for the responses.

    @SimpleLoop , where could I find all of the code for things such as textfields and other native things like the code you keep giving me? Such as an API sheet.

    @bowerandy , thanks, it now works!
    JLS
    Lead Coder and Designer
  • Hi @bowerandy @SimpleLoop

    I need some help with the UIKIT Plugin.

    I am also using SceneManager by @ar2rsawseen .

    Now the issue I am getting is that every time I click on the button it doesn't change scenes at all, and I can't seem to figure out why. There are no errors whenever I run it on my iPhone.

    Here is my code:
    mainmenu = gideros.class(Sprite)
    function mainmenu:init()
     
     
    	--Create Event Button
    	local createBtn = Button.new()
     
    	createBtn:setPosition(40, 200)
    	createBtn:setSize(250,100)
     
    	--Create Event Mask
    	createBtn:setBGImage("Images/btn1.png")
    	createBtn:setImage("Images/btn1_over.png")
     
    	--The Actual Button and Listener
    	createBtn:addEventListener("click",
    	function()
    		sceneManager:changeScene("createEvent", .25, SceneManager.overFromLeftWithFade)
    	end)
     
    	addToRootView(createBtn)
     
     
    end
    Thanks!
    -Landon
    JLS
    Lead Coder and Designer
Sign In or Register to comment.