'Expressions are not allowed at the top level'

Hello coders, I am new to swift and trying to develop proximity beacons beased App in IOS. below is my code
//Beacons Observer Section

self.ProximityObserver = ProximityObserver(Credentials: Credentials, onError: { error in print("Oops! \(error)")})

//Defining Zones

let MintZone = ProximityZone(tag: "Mint", range: ProximityRange.near)
MintZone.onEnter = { zoneContext in
print("Entered near range of tag 'Mint'. Attachments payload: \(zoneContext.attachments)")
}
MintZone.onExit = { zoneContext in
print("Exited near range of 'Mint'. Attachment payload: \(zoneContext.attachments)")
}
MintZone.onContextChange = { context in
print("Now in range of \(context.count) contexts")
}

// Start Proximity Oberserver

self.ProximityObserver.startObserving;)([MintZone])

I am getting this error 'Expressions are not allowed at the top level' and this one 'Use of unresolved identifier 'self' too.

It would be great if you guys can guide me.

Thanks
Just the fragments of code does not make sense in programming.
It may work when existing in some appropriate contexts, it may not otherwise.

When you want to ask something about your code, you need to show the whole class or struct, at least whole methods including the lines.

I am getting this error 'Expressions are not allowed at the top level' and this one 'Use of unresolved identifier 'self' too. 

If you get such errors, you should clarify on which line it is shown. I guess some of the lines you have shown does not exist in methods.
Executable statements needs to exist in methods. (Or some other things similar to methods.)

How to fix depends on other parts of your code. Please show all relevant code.


'Expressions are not allowed at the top level'
 
 
Q